App crashes while parsing data from google sheet - java

I) Below is code for parsing data async from google sheet and works fine as long as the internet speed is good but crashes on slow speed. How to address this? I have fixed for no internet.
II) If the google sheet is opened for update ( one a row at a time), the system crashes on trying to open. How can I skip the rows which are not assessible ( or updating) ?
III) Is there any way to find time when the google sheet was last updated ?
IV) How to tell google maps not to open the map till the parsing is done?
protected void ReadGoogleSheetAsync(){
new DownloadWebpageTask(new AsyncResult() {
#Override
public void onResult(JSONObject object) {
processJson(object);
}
}).execute("https://spreadsheets.google.com/tq?key=mykey");
}
private void processJson(JSONObject object) {
try {
JSONArray rows = object.getJSONArray("rows");
for (int r = 0; r < rows.length(); ++r) {
JSONObject row = rows.getJSONObject(r);
JSONArray columns = row.getJSONArray("c");
UserData ud = new UserData();
ud.setId(columns.getJSONObject(0).getString("f"));
ud.setName(columns.getJSONObject(1).getString("v"));
ud.setState(columns.getJSONObject(2).getString("v"));
}
catch (JSONException e) {
e.printStackTrace();
}
}
This is based on DownloadWebpageTask.java from git.
Stacktrace:
08/03 06:41:06: Launching 'MapsActivity' on vivo vivo 1902.
$ adb shell am start -n "com.example.fmtxstatus/com.example.fmtxstatus.MapsActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER Waiting for process to come online... Connected to process 6659 on device 'vivo-vivo_1902-CIEMU8KRPFLFHEBU'. Capturing and displaying logcat messages from application. This behavior can be disabled in the "Logcat output" section of the "Debugger" settings page. D/VivoTheme: load old package name start I/mple.fmtxstatu: The ClassLoaderContext is a special shared library. W/mple.fmtxstatu: JIT profile information will not be recorded: profile file does not exits.
JIT profile information will not be recorded: profile file does not exits. D/NightModeController: com.example.fmtxstatus = true
disable nightmode package:com.example.fmtxstatus I/FtBuild: getRomVersion mRomVer=9.0 D/VivoPhoneWindow: DEBUG_ALIENSCREEN:getRotation mRotation=0 I/PhoneWindow: initSystemUIColor I/zzbz: Making Creator dynamically W/mple.fmtxstatu: Unsupported class loader W/mple.fmtxstatu: Skipping duplicate class check due to unsupported classloader I/DynamiteModule: Considering local module com.google.android.gms.maps_dynamite:0 and remote module com.google.android.gms.maps_dynamite:202614000 I/DynamiteModule: Selected remote version of com.google.android.gms.maps_dynamite, version >= 202614000 V/DynamiteModule: Dynamite loader version >= 2, using loadModule2NoCrashUtils I/DynamiteLoaderV2: [71] Mapsdynamite W/mple.fmtxstatu: Unsupported class loader W/mple.fmtxstatu: Skipping duplicate class check due to unsupported classloader I/Google Maps Android API: Google Play services client version: 12451000 I/Google Maps Android API: Google Play services package version: 202614029 W/mple.fmtxstatu: Accessing hidden field Ljava/nio/Buffer;->address:J (light greylist, reflection) I/mple.fmtxstatu: The ClassLoaderContext is a special shared library. E/libc: Access denied finding property "persist.vendor.log.tel_dbg" W/com.example.fmtxstatus: type=1400 audit(0.0:118917): avc: denied { read } for comm=4173796E635461736B202332 name="u:object_r:mtk_em_tel_log_prop:s0" dev="tmpfs" ino=6814 scontext=u:r:untrusted_app:s0:c252,c256,c512,c768 tcontext=u:object_r:mtk_em_tel_log_prop:s0 tclass=file permissive=0 D/NetworkSecurityConfig: No Network Security Config specified, using platform default D/OpenGLRenderer: Dumper init 4 threads <0x7a04d12b40> D/OpenGLRenderer: <com.example.fmtxstatus> is running.
Skia GL Pipeline I/SurfaceFactory: [static] sSurfaceFactory = com.mediatek.view.impl.SurfaceFactoryImpl#5b77117 D/ViewRootImpl[MapsActivity]: hardware acceleration = true , fakeHwAccelerated = false, sRendererDisabled = false, forceHwAccelerated = false, sSystemRendererDisabled = false V/PhoneWindow: DecorView setVisiblity: visibility = 0, Parent = android.view.ViewRootImpl#ff0122, this = DecorView#13807b3[MapsActivity] V/PhoneWindow: DecorView setVisiblity: visibility = 0, Parent = android.view.ViewRootImpl#ff0122, this = DecorView#13807b3[MapsActivity] I/CatcherGestureDetector: DecorView onAttached D/yuan: onVisibilityChanged----com.google.maps.api.android.lib6.impl.ci{2c1c49c G.ED..C.. ......I. 0,0-0,0} D/Surface: Surface::allocateBuffers(this=0x79f461d000) I/ConfigStore: android::hardware::configstore::V1_0::ISurfaceFlingerConfigs::hasWideColorDisplay retrieved: 0
android::hardware::configstore::V1_0::ISurfaceFlingerConfigs::hasHDRDisplay retrieved: 0 I/OpenGLRenderer: Initialized EGL, version 1.4 D/OpenGLRenderer: Swap behavior 2 D/Surface: Surface::connect(this=0x79f461d000,api=1) D/TextureView: getHardwareLayer, createNewSurface:true I/BufferQueue: [unnamed-6659-0](this:0x7a03285800,id:0,api:0,p:-1,c:-1) BufferQueue core=(6659:com.example.fmtxstatus) W/mple.fmtxstatus: type=1400 audit(0.0:118918): avc: denied { read } for name="u:object_r:graphics_debug_prop:s0" dev="tmpfs" ino=6754 scontext=u:r:untrusted_app:s0:c252,c256,c512,c768 tcontext=u:object_r:graphics_debug_prop:s0 tclass=file permissive=0 E/libc: Access denied finding property "vendor.debug.sf.stc_interval" W/mple.fmtxstatus: type=1400 audit(0.0:118919): avc: denied { read } for name="u:object_r:debug_bq_dump_prop:s0" dev="tmpfs" ino=6713 scontext=u:r:untrusted_app:s0:c252,c256,c512,c768 tcontext=u:object_r:debug_bq_dump_prop:s0 tclass=file permissive=0 E/libc: Access denied finding property "vendor.debug.bq.dump" W/System: ClassLoader referenced unknown path: system/framework/mediatek-cta.jar I/BufferQueueConsumer: [unnamed-6659-0](this:0x7a03285800,id:0,api:0,p:-1,c:6659) connect(C): consumer=(6659:com.example.fmtxstatus) controlledByApp=true E/libc: Access denied finding property "vendor.debug.bq.dump" W/mple.fmtxstatus: type=1400 audit(0.0:118920): avc: denied { read } for name="u:object_r:debug_bq_dump_prop:s0" dev="tmpfs" ino=6713 scontext=u:r:untrusted_app:s0:c252,c256,c512,c768 tcontext=u:object_r:debug_bq_dump_prop:s0 tclass=file permissive=0 I/BufferQueueConsumer: [unnamed-6659-0](this:0x7a03285800,id:0,api:0,p:-1,c:6659) setConsumerName: unnamed-6659-0 E/libc: Access denied finding property "vendor.debug.bq.line" W/mple.fmtxstatus: type=1400 audit(0.0:118921): avc: denied { read } for name="u:object_r:graphics_debug_prop:s0" dev="tmpfs" ino=6754 scontext=u:r:untrusted_app:s0:c252,c256,c512,c768 tcontext=u:object_r:graphics_debug_prop:s0 tclass=file permissive=0 E/libc: Access denied finding property "vendor.debug.bq.dump" I/BufferQueueConsumer: [SurfaceTexture-0-6659-0](this:0x7a03285800,id:0,api:0,p:-1,c:6659) setConsumerName: SurfaceTexture-0-6659-0 W/mple.fmtxstatus: type=1400 audit(0.0:118922): avc: denied { read } for name="u:object_r:debug_bq_dump_prop:s0" dev="tmpfs" ino=6713 scontext=u:r:untrusted_app:s0:c252,c256,c512,c768 tcontext=u:object_r:debug_bq_dump_prop:s0 tclass=file permissive=0 I/System.out: e:java.lang.ClassNotFoundException: com.mediatek.cta.CtaHttp I/BufferQueueConsumer: [SurfaceTexture-0-6659-0](this:0x7a03285800,id:0,api:0,p:-1,c:6659) setDefaultBufferSize: width=720 height=1404 D/OpenGLRenderer: 0x7a032fb740 setSurfaceTexture: 0x0 to 0x7a032d1800 D/Linux: [Posix_connect Debug]Process com.example.fmtxstatus :443 E/ion: ioctl c0044901 failed with code -1: Invalid argument I/GLConsumer: [SurfaceTexture-0-6659-0] attachToContext D/OpenSSLLib: OpensslErr:Module:12(177:); file:external/boringssl/src/crypto/asn1/asn1_lib.c ;Line:168;Function:ASN1_get_object D/OpenSSLLib: OpensslErr:Module:12(177:); file:external/boringssl/src/crypto/asn1/asn1_lib.c ;Line:168;Function:ASN1_get_object I/System.out: [OkHttp] sendRequest>> I/System.out: [OkHttp] sendRequest<< E/Google Maps Android API: Authorization failure. Please see https://developers.google.com/maps/documentation/android-api/start for how to correctly set up the map. E/Google Maps Android API: In the Google Developer Console (https://console.developers.google.com)
com.example.fmtxstatus W/System: ClassLoader referenced unknown path: system/framework/mediatek-cta.jar I/System.out: e:java.lang.ClassNotFoundException: com.mediatek.cta.CtaHttp D/Linux: [Posix_connect Debug]Process com.example.fmtxstatus :443 D/OpenSSLLib: OpensslErr:Module:12(177:); file:external/boringssl/src/crypto/asn1/asn1_lib.c ;Line:168;Function:ASN1_get_object D/OpenSSLLib: OpensslErr:Module:12(177:); file:external/boringssl/src/crypto/asn1/asn1_lib.c ;Line:168;Function:ASN1_get_object I/System.out: [OkHttp] sendRequest>> I/System.out: [OkHttp] sendRequest<< W/DynamiteModule: Local module descriptor class for com.google.android.gms.googlecertificates not found. I/DynamiteModule: Considering local module com.google.android.gms.googlecertificates:0 and remote module com.google.android.gms.googlecertificates:5
Selected remote version of com.google.android.gms.googlecertificates, version >= 5 I/DynamiteLoaderV2: [71] Googlecertificates W/mple.fmtxstatu: Unsupported class loader W/mple.fmtxstatu: Skipping duplicate class check due to unsupported classloader I/System.out: [OkHttp] sendRequest>> I/System.out: [OkHttp] sendRequest<< I/System.out: [OkHttp] sendRequest>> I/System.out: [OkHttp] sendRequest<< I/Choreographer: Skipped 52 frames! The application may be doing too much work on its main thread.

The issue seems to be related to poor handling of HttpURLConnection object. There are issues in the downloadUrl() method implementation in the class DownloadWebpageTask, which may be relevant to the queries 1-3, the variable responseCode is never used.
If the response is not HttpURLConnection.HTTP_OK , try reconnecting ( or till a custom timeout) or return a null string. On slow internet or bad connection, the response will not be HttpURLConnection.HTTP_OK, hence trying to reference the json-object may lead to undefined behavior.
private String downloadUrl(String urlString) throws IOException {
/*...*/
conn.connect();
responseCode = conn.getResponseCode();
if( responseCode == HttpURLConnection.HTTP_OK)
{
// do something
}
else
{
// retry or return null string
}
}
The function processJson(object) in the snippet should be called only if json-object is not null. Issues under queries 1 to 3 should be taken care of with these modifications.
protected void ReadGoogleSheetAsync(){
new DownloadWebpageTask(new AsyncResult() {
#Override
public void onResult(JSONObject object) {
if(object) processJson(object);
}
}).execute("https://spreadsheets.google.com/tq?key=mykey");
}
For query 4 related to google maps api, OnMapReadyCallback is called when the map is ready to be used. Override onMapReady() method to find if the map is ready or not.

Related

Can't Connect to SQL Database Hosted of Microsoft Azure on Real Device, Works on Emulator Fine Pixel 4A (Android Studio)

am relatively new here so please bare with me,
(min sdk target is 25
buildsdk is 29)
This is my connection method that I used in my app and tested on emulator which worked and fetched the data correctly in the if block on emulator pixel 4A ,
try {
Class.forName("net.sourceforge.jtds.jdbc.Driver");
ConnURL = getResources().getString(R.string.url);
conn = DriverManager.getConnection(ConnURL);
} catch (SQLException se) {
Log.e("ERROR", se.getMessage());
error.setText("SQLException");
err_flag=false;
} catch (ClassNotFoundException e) {
Log.e("ERROR", e.getMessage());
error.setText("ClassNotFoundException");
err_flag=false;
} catch (Exception e) {
Log.e("ERROR", e.getMessage());
error.setText("Exception");
err_flag=false;
}
if(conn!=null)
{
/
/
}
else
{
progressBar.setVisibility(View.GONE);
//error.setText("Conn is NULL");
Toast.makeText(getContext(),"Error Encountered, Try Again",Toast.LENGTH_LONG).show();
}
My Connect URL is as following:
jdbc:jtds:sqlserver://moons.database.windows.net:1433;DatabaseName=****;user=****;password=****;encrypt=true;trustServerCertificate=false;hostNameInCertificate=*.database.windows.net;loginTimeout=30;ssl=request
Firewall Settings of Azure Server
When I tested the app on my Huawei Y9 prime Android 10 (real device) (works fine on android studio emulator api 31 Pixel 4A), I am getting this error in the log Cat and the connection is returned Null
Log Cat Error:
This exception is thrown by first Catch block (SQLException se)
E/ERROR: Network error IOException: SSL handshake aborted: ssl=0x738d986cc8: I/O error during system call, Broken pipe.
Complete Log Cat:
09/05 20:01:37: Launching 'app' on HUAWEI STK-L21.
Install successfully finished in 2 s 676 ms.
$ adb shell am start -n "com.example.fyp/com.example.fyp.Splash" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Connected to process 28785 on device 'huawei-stk_l21-TMFNW19926007079'.
Capturing and displaying logcat messages from application. This behavior can be disabled in the "Logcat output" section of the "Debugger" settings page.
I/com.example.fy: QarthPatchMonintor::Init
QarthPatchMonintor::StartWatch
QarthPatchMonintor::WatchPackage: /data/hotpatch/fwkhotpatch/
QarthPatchMonintor::CheckAndWatchPatch: /data/hotpatch/fwkhotpatch/com.example.fyp
QarthPatchMonintor::CheckAndWatchPatch: /data/hotpatch/fwkhotpatch/all
QarthPatchMonintor::Run
I/com.example.fy: QarthPatchMonintor::Reading
QarthPatchMonintor::CheckNotifyEvent
QarthPatchMonintor::CheckNotifyEvent before read
I/HwApiCacheMangerEx: apicache path=/storage/emulated/0 state=mounted key=com.example.fyp#10185#256
I/HwApiCacheMangerEx: apicache path=/storage/emulated/0 state=mounted key=com.example.fyp#10185#0
I/AwareBitmapCacher: init processName:com.example.fyp pid=28785 uid=10185
I/FirebaseApp: Device unlocked: initializing all Firebase APIs for app [DEFAULT]
E/AwareLog: AtomicFileUtils: readFileLines file not exist: android.util.AtomicFile#ed05212
I/FirebaseInitProvider: FirebaseApp initialization successful
I/FirebaseAuth: [FirebaseAuth:] Preparing to create service connection to fallback implementation
V/ActivityThread: callActivityOnCreate
V/HwWidgetFactory: : successes to get AllImpl object and return....
W/com.example.fy: Accessing hidden method Landroid/view/View;->computeFitSystemWindows(Landroid/graphics/Rect;Landroid/graphics/Rect;)Z (greylist, reflection, allowed)
W/com.example.fy: Accessing hidden method Landroid/view/ViewGroup;->makeOptionalFitsSystemWindows()V (greylist, reflection, allowed)
D/ActivityThread: add activity client record, r= ActivityRecord{4f702be token=android.os.BinderProxy#35d7d5e {com.example.fyp/com.example.fyp.Splash}} token= android.os.BinderProxy#35d7d5e
D/HiTouch_PressGestureDetector: onAttached, package=com.example.fyp, windowType=1, mHiTouchRestricted=false
I/iGraphics: [0020080c] pn: com.example.fyp, p: 28785
[0030080c] no spt app: com.example.fyp
D/mali_winsys: EGLint new_window_surface(egl_winsys_display *, void *, EGLSurface, EGLConfig, egl_winsys_surface **, EGLBoolean) returns 0x3000
W/Gralloc3: mapper 3.x is not supported
E/: APS:IFLoad:importExternalFunctions, search function createNewHwApsUtils failed, dlsym err:undefined symbol: createNewHwApsUtils
D/: APS:importExternalFunctions OK
I/HwViewRootImpl: removeInvalidNode jank list is null
D/HwFrameworkSecurityPartsFactory: HwFrameworkSecurityPartsFactory in.
I/HwFrameworkSecurityPartsFactory: add HwFrameworkSecurityPartsFactory to memory.
W/ActivityThread: handleWindowVisibility: no activity for token android.os.BinderProxy#6d9bc7a
V/ActivityThread: callActivityOnCreate
D/ActivityThread: add activity client record, r= ActivityRecord{cb8ffa8 token=android.os.BinderProxy#6d9bc7a {com.example.fyp/com.example.fyp.login}} token= android.os.BinderProxy#6d9bc7a
D/HiTouch_PressGestureDetector: onAttached, package=com.example.fyp, windowType=1, mHiTouchRestricted=false
D/mali_winsys: EGLint new_window_surface(egl_winsys_display *, void *, EGLSurface, EGLConfig, egl_winsys_surface **, EGLBoolean) returns 0x3000
I/HwViewRootImpl: removeInvalidNode all the node in jank list is out of time
W/ActivityThread: handleWindowVisibility: no activity for token android.os.BinderProxy#92f9933
V/ActivityThread: callActivityOnCreate
I/OverScrollerOptimization: start init SmartSlideOverScroller and get the overscroller config
get the overscroller config
D/HwGalleryCacheManagerImpl: mIsEffect:false
D/ActivityThread: add activity client record, r= ActivityRecord{1161bf1 token=android.os.BinderProxy#92f9933 {com.example.fyp/com.example.fyp.MainActivity}} token= android.os.BinderProxy#92f9933
D/HiTouch_PressGestureDetector: onAttached, package=com.example.fyp, windowType=1, mHiTouchRestricted=false
W/com.example.fy: Accessing hidden method Landroid/view/View;->getViewRootImpl()Landroid/view/ViewRootImpl; (greylist, reflection, allowed)
Accessing hidden field Landroid/view/View$AttachInfo;->mVisibleInsets:Landroid/graphics/Rect; (greylist, reflection, allowed)
Accessing hidden field Landroid/view/ViewRootImpl;->mAttachInfo:Landroid/view/View$AttachInfo; (greylist, reflection, allowed)
E/1st:ERROR: Network error IOException: SSL handshake aborted: ssl=0x73905b3648: I/O error during system call, Broken pipe
D/mali_winsys: EGLint new_window_surface(egl_winsys_display *, void *, EGLSurface, EGLConfig, egl_winsys_surface **, EGLBoolean) returns 0x3000
I/OpenGLRenderer: Davey! duration=1434ms; Flags=1, IntendedVsync=33031788804864, Vsync=33032172138182, OldestInputEvent=9223372036854775807, NewestInputEvent=0, HandleInputStart=33032185699125, AnimationStart=33032185749125, PerformTraversalsStart=33032185986104, DrawStart=33033136778292, SyncQueued=33033148383500, SyncStart=33033149005896, IssueDrawCommandsStart=33033149223604, SwapBuffers=33033219219958, FrameCompleted=33033223873604, DequeueBufferDuration=229000, QueueBufferDuration=1636000,
I/Choreographer: Skipped 61 frames! The application may be doing too much work on its main thread.
I/HwViewRootImpl: removeInvalidNode jank list is null
D/AwareBitmapCacher: handleInit switch not opened pid=28785
I/OpenGLRenderer: Davey! duration=1104ms; Flags=1, IntendedVsync=33032204365039, Vsync=33033221031665, OldestInputEvent=9223372036854775807, NewestInputEvent=0, HandleInputStart=33033227853292, AnimationStart=33033228129333, PerformTraversalsStart=33033231209542, DrawStart=33033286090271, SyncQueued=33033293707979, SyncStart=33033294293917, IssueDrawCommandsStart=33033294511104, SwapBuffers=33033303533500, FrameCompleted=33033309802771, DequeueBufferDuration=141000, QueueBufferDuration=3064000,
D/mali_winsys: EGLint new_window_surface(egl_winsys_display *, void *, EGLSurface, EGLConfig, egl_winsys_surface **, EGLBoolean) returns 0x3000
W/libEGL: EGLNativeWindowType 0x73adb07e10 disconnect failed
W/libEGL: EGLNativeWindowType 0x74188f1a90 disconnect failed
D/ActivityThread: Remove activity client record, r= ActivityRecord{4f702be token=android.os.BinderProxy#35d7d5e {com.example.fyp/com.example.fyp.Splash}} token= android.os.BinderProxy#35d7d5e
W/libEGL: EGLNativeWindowType 0x738f9f5510 disconnect failed
W/Settings: Setting device_provisioned has moved from android.provider.Settings.Secure to android.provider.Settings.Global.
V/HiTouch_HiTouchSensor: User setup is finished.
D/HwAutofillHelper: recordCurrentInfo:0
D/HwAutofillHelper: inputType = 65537
I/HwViewRootImpl: removeInvalidNode all the node in jank list is out of time
E/SpannableStringBuilder: SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a zero length
I/chatty: uid=10185(com.example.fyp) identical 2 lines
E/SpannableStringBuilder: SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a zero length
V/AudioManager: querySoundEffectsEnabled...
E/ERROR: Network error IOException: SSL handshake aborted: ssl=0x738f845048: I/O error during system call, Broken pipe
I/HwViewRootImpl: removeInvalidNode jank list is null
Sorry If am missing anything, I'll add more info if needed by any user. Thank you for understanding.

Firebase google authentication sign in using android

In the project I made on Android studio, I put a button on the user login page to log in with a google account.The account name appears in the Choose an account section.
In the Authentication section, the name does not appear as an account login.The user's mail and password have been entered and saved.When I log into the application with that account, I want it to redirect to the other page, but it does not redirect to the MainActivity2.java page. I would be glad if you could help.
Run:
Connected to process 18504 on device 'emulator-5556'.
Capturing and displaying logcat messages from application. This behavior can be disabled in the "Logcat output" section of the "Debugger" settings page.
D/NetworkSecurityConfig: No Network Security Config specified, using platform default
D/NetworkSecurityConfig: No Network Security Config specified, using platform default
I/MultiDex: VM with version 2.1.0 has multidex support
Installing application
VM has multidex support, MultiDex support library is disabled.
I/ple.geziprojec: Waiting for a blocking GC ClassLinker
I/ple.geziprojec: WaitForGcToComplete blocked ClassLinker on ClassLinker for 176.388ms
W/ple.geziprojec: Verification of void com.google.android.gms.common.internal.StringResourceValueReader.<init>(android.content.Context) took 177.170ms (118.53 bytecodes/s) (1040B approximate peak alloc)
W/ComponentDiscovery: Class com.google.firebase.dynamicloading.DynamicLoadingRegistrar is not an found.
I/FirebaseApp: Device unlocked: initializing all Firebase APIs for app [DEFAULT]
I/FirebaseInitProvider: FirebaseApp initialization successful
D/libEGL: loaded /vendor/lib/egl/libEGL_emulation.so
D/libEGL: loaded /vendor/lib/egl/libGLESv1_CM_emulation.so
D/libEGL: loaded /vendor/lib/egl/libGLESv2_emulation.so
I/DynamiteModule: Considering local module com.google.android.gms.measurement.dynamite:20 and remote module com.google.android.gms.measurement.dynamite:21
Selected remote version of com.google.android.gms.measurement.dynamite, version >= 21
V/DynamiteModule: Dynamite loader version >= 2, using loadModule2NoCrashUtils
W/ple.geziprojec: Verification of void com.google.android.gms.common.api.internal.GoogleApiManager$zaa.connect() took 107.853ms (806.65 bytecodes/s) (2328B approximate peak alloc)
W/ple.geziprojec: Accessing hidden method Landroid/view/View;->computeFitSystemWindows(Landroid/graphics/Rect;Landroid/graphics/Rect;)Z (greylist, reflection, allowed)
W/ple.geziprojec: Accessing hidden method Landroid/view/ViewGroup;->makeOptionalFitsSystemWindows()V (greylist, reflection, allowed)
W/ple.geziprojec: Verification of void com.google.android.gms.common.internal.BaseGmsClient.zza(int, android.os.IInterface) took 133.587ms (3346.13 bytecodes/s) (5928B approximate peak alloc)
I/ple.geziprojec: The ClassLoaderContext is a special shared library.
I/ple.geziprojec: The ClassLoaderContext is a special shared library.
I/FirebaseAuth: [FirebaseAuth:] Preparing to create service connection to fallback implementation
I/DynamiteModule: Considering local module com.google.android.gms.signinbutton_dynamite:0 and remote module com.google.android.gms.signinbutton_dynamite:2
Selected remote version of com.google.android.gms.signinbutton_dynamite, version >= 2
W/ple.geziprojec: Verification of int com.google.android.gms.common.internal.GmsClientSupervisor$zza.zzq() took 161.972ms (18.52 bytecodes/s) (720B approximate peak alloc)
V/FA: onActivityCreated
D/HostConnection: HostConnection::get() New Host Connection established 0xe9121d40, tid 18553
D/HostConnection: HostComposition ext ANDROID_EMU_CHECKSUM_HELPER_v1 ANDROID_EMU_native_sync_v2 ANDROID_EMU_native_sync_v3 ANDROID_EMU_native_sync_v4 ANDROID_EMU_dma_v1 ANDROID_EMU_direct_mem ANDROID_EMU_host_composition_v1 ANDROID_EMU_host_composition_v2 ANDROID_EMU_YUV_Cache ANDROID_EMU_async_unmap_buffer GL_OES_vertex_array_object GL_KHR_texture_compression_astc_ldr ANDROID_EMU_gles_max_version_2
W/OpenGLRenderer: Failed to choose config with EGL_SWAP_BEHAVIOR_PRESERVED, retrying without...
D/EGL_emulation: eglCreateContext: 0xe9124ba0: maj 2 min 0 rcv 2
D/EGL_emulation: eglMakeCurrent: 0xe9124ba0: ver 2 0 (tinfo 0xe9455f70) (first time)
I/Gralloc4: mapper 4.x is not supported
D/HostConnection: createUnique: call
D/HostConnection: HostConnection::get() New Host Connection established 0xe9123ef0, tid 18553
D/goldfish-address-space: allocate: Ask for block of size 0x100
allocate: ioctl allocate returned offset 0x3fe83c000 size 0x2000
D/HostConnection: HostComposition ext ANDROID_EMU_CHECKSUM_HELPER_v1 ANDROID_EMU_native_sync_v2 ANDROID_EMU_native_sync_v3 ANDROID_EMU_native_sync_v4 ANDROID_EMU_dma_v1 ANDROID_EMU_direct_mem ANDROID_EMU_host_composition_v1 ANDROID_EMU_host_composition_v2 ANDROID_EMU_YUV_Cache ANDROID_EMU_async_unmap_buffer GL_OES_vertex_array_object GL_KHR_texture_compression_astc_ldr ANDROID_EMU_gles_max_version_2
W/ple.geziprojec: Verification of void ic.e() took 123.348ms (6809.95 bytecodes/s) (11464B approximate peak alloc)
W/ple.geziprojec: Verification of void ie.<init>(jc) took 152.305ms (98.49 bytecodes/s) (968B approximate peak alloc)
I/OpenGLRenderer: Davey! duration=771ms; Flags=1, IntendedVsync=4143801720841, Vsync=4143835054173, OldestInputEvent=9223372036854775807, NewestInputEvent=0, HandleInputStart=4143845992300, AnimationStart=4143846040000, PerformTraversalsStart=4143846105800, DrawStart=4144157390900, SyncQueued=4144354861800, SyncStart=4144360117400, IssueDrawCommandsStart=4144360507700, SwapBuffers=4144536078100, FrameCompleted=4144578165500, DequeueBufferDuration=318500, QueueBufferDuration=1625500, GpuCompleted=0,
W/ple.geziprojec: Verification of void lt.B() took 115.481ms (207.83 bytecodes/s) (992B approximate peak alloc)
I/Choreographer: Skipped 49 frames! The application may be doing too much work on its main thread.
I/OpenGLRenderer: Davey! duration=988ms; Flags=0, IntendedVsync=4143851699017, Vsync=4144668365651, OldestInputEvent=9223372036854775807, NewestInputEvent=0, HandleInputStart=4144680002300, AnimationStart=4144680060000, PerformTraversalsStart=4144680717500, DrawStart=4144727417500, SyncQueued=4144728390300, SyncStart=4144731782000, IssueDrawCommandsStart=4144731852000, SwapBuffers=4144734026400, FrameCompleted=4144844020200, DequeueBufferDuration=279000, QueueBufferDuration=16261600, GpuCompleted=0,
W/ple.geziprojec: Verification of void rc.<clinit>() took 163.597ms (378.98 bytecodes/s) (1416B approximate peak alloc)
V/FA: App measurement collection enabled
V/FA: App measurement enabled for app package, google app id: com.example.geziproject, 1:1088981466528:android:40238883a0fda69fa1f8c5
I/FA: App measurement initialized, version: 34027
I/FA: To enable debug logging run: adb shell setprop log.tag.FA VERBOSE
I/FA: To enable faster debug mode event logging run:
adb shell setprop debug.firebase.analytics.app com.example.geziproject
D/FA: Debug-level message logging enabled
V/FA: Connecting to remote service
V/FA: Connection attempt already in progress
V/FA: Connection attempt already in progress
V/FA: Activity resumed, time: 4143853
I/FA: Tag Manager is not found and thus will not be used
V/FA: Connection attempt already in progress
V/FA: Connection attempt already in progress
D/FA: Connected to remote service
V/FA: Processing queued up service tasks: 5
V/FA: Recording user engagement, ms: 4309
V/FA: Activity paused, time: 4148164
V/FA: onActivityCreated
V/FA: Activity resumed, time: 4148325
V/FA: Screen exposed for less than 1000 ms. Event not sent. time: 214
V/FA: Activity paused, time: 4148556
D/FA: Application going to the background
D/CompatibilityChangeReporter: Compat change id reported: 147798919; UID 10154; state: ENABLED
V/FA: Activity resumed, time: 4154166
V/FA: Inactivity, disconnecting from the service
W/ConnectionTracker: Exception thrown while unbinding
java.lang.IllegalArgumentException: Service not registered: ls#9d99311
at android.app.LoadedApk.forgetServiceDispatcher(LoadedApk.java:1757)
at android.app.ContextImpl.unbindService(ContextImpl.java:1874)
at android.content.ContextWrapper.unbindService(ContextWrapper.java:792)
at ci.f(:com.google.android.gms.dynamite_measurementdynamite#204713100#20.47.13 (150700-0):1)
at ci.d(:com.google.android.gms.dynamite_measurementdynamite#204713100#20.47.13 (150700-0):2)
at lt.E(:com.google.android.gms.dynamite_measurementdynamite#204713100#20.47.13 (150700-0):9)
at ld.a(:com.google.android.gms.dynamite_measurementdynamite#204713100#20.47.13 (150700-0):3)
at ef.run(:com.google.android.gms.dynamite_measurementdynamite#204713100#20.47.13 (150700-0):3)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:462)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at iy.run(:com.google.android.gms.dynamite_measurementdynamite#204713100#20.47.13 (150700-0):5)
Gradle dependencies:
dependencies {
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.2.1'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation 'com.google.firebase:firebase-auth:20.0.1'
implementation 'com.google.firebase:firebase-database:19.6.0'
implementation 'androidx.navigation:navigation-fragment:2.3.2'
implementation 'androidx.navigation:navigation-ui:2.3.2'
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.2.0'
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
testImplementation 'junit:junit:4.+'
implementation platform('com.google.firebase:firebase-bom:26.2.0')
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
implementation 'me.everything:providers-android:1.0.1'
implementation 'com.google.android.gms:play-services-auth:19.0.0'
implementation 'com.google.firebase:firebase-auth'
implementation 'com.google.firebase:firebase-core:18.0.0'
}
apply plugin: 'com.google.gms.google-services'
LoginActivity.java:
public class LoginActivity extends AppCompatActivity {
private SignInButton signInButton;
private GoogleSignInClient mGoogleSignInClient;
private FirebaseAuth mAuth;
private Button signout;
private final static int RC_SIGN_IN=123;
protected void onStart() {
super.onStart();
FirebaseUser user=mAuth.getCurrentUser();
if(user!=null){
Intent intent= new Intent(getApplicationContext(),MainActivity2.class);
startActivity(intent);
}
}
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
createRequest();
signInButton=findViewById(R.id.signin);
mAuth=FirebaseAuth.getInstance();
signout=findViewById(R.id.sign_out);
signInButton.setOnClickListener(v -> signIn());
}
private void createRequest() {
GoogleSignInOptions gso= new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestIdToken(String.valueOf(R.string.default_web_client_id))
.requestEmail()
.build();
mGoogleSignInClient= GoogleSignIn.getClient(this,gso);
}
private void signIn() {
Intent signInIntent = mGoogleSignInClient.getSignInIntent();
startActivityForResult(signInIntent, RC_SIGN_IN);
}
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if(requestCode==RC_SIGN_IN){
Task<GoogleSignInAccount> task=GoogleSignIn.getSignedInAccountFromIntent(data);
//handleSignInResult(task);
try{
GoogleSignInAccount account=task.getResult(ApiException.class);
Toast.makeText(getApplicationContext(),"giriş başarılı",Toast.LENGTH_LONG).show();
firebaseAuthWithGoogle(account);
} catch (ApiException e) {
Toast.makeText(this,e.getMessage(),Toast.LENGTH_LONG).show();
}
}
}
private void firebaseAuthWithGoogle(GoogleSignInAccount acct) {
AuthCredential credential = GoogleAuthProvider.getCredential(acct.getIdToken(), null);
mAuth.signInWithCredential(credential)
.addOnCompleteListener(this, task -> {
if (task.isSuccessful()) {
// Sign in success, update UI with the signed-in user's information
FirebaseUser user = mAuth.getCurrentUser();
Intent intent= new Intent(getApplicationContext(),MainActivity2.class);
startActivity(intent);
} else {
Toast.makeText(LoginActivity.this,"başarısız",Toast.LENGTH_LONG).show();
}
});
}
MainActivity2.java:
public class MainActivity2 extends AppCompatActivity {
TextView name,mail;
Button logout;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main2);
logout= findViewById(R.id.logout);
name=findViewById(R.id.name);
mail=findViewById(R.id.email);
GoogleSignInAccount signInAccount= GoogleSignIn.getLastSignedInAccount(this);
if(signInAccount!=null){
name.setText(signInAccount.getDisplayName());
mail.setText(signInAccount.getEmail());
}
logout.setOnClickListener(v -> {
FirebaseAuth.getInstance().signOut();
Intent intent=new Intent(getApplicationContext(),LoginActivity.class);
startActivity(intent);
});
}
}

Firebase Authentication suddenly stopped working

I have an android app that does not require a log in, but I do have Anonymous sign-in enabled so that I can retrieve the userID from Firebase and use it to log specific events. I have the feeling that it just stopped retrieving the UID from Firebase.
What I've done to resolve the issue is the following:
updated all the dependencies
updated the emulator
Installed a new emulator
re-added the google services plugin
re-added google-services.json file
updated Android Manifest
I've tried to create a login-activity for the sake of testing, where through a button with an onclicklisterer, the user get's anoynmously logged in.
I've doubled checked Local History in Android Studio to see whether big changes were made to the code, not the case. See screenshot
Enabled and disabled anonymous login from the Firebase Console.
Re-written the entire code based on documentation from Firebase.
I've basically tried every solution there is
My Manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.superawesome.metime">
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/wazzup"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".Cardview" />
<activity android:name=".cardviewactivity" />
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="ca-app-pub-xxx" />
<activity
android:name=".MainActivity"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.google.firebase.auth.internal.FederatedSignInActivity"
tools:replace="android:launchMode"
android:launchMode="standard" />
<service
android:name=".MyFirebaseInstanceIDService">
<intent-filter>
<action android:name="com.google.firebase.INSTANCE_ID_EVENT"/>
</intent-filter>
</service>
</application>
</manifest>
My code:
#Override
public boolean onOptionsItemSelected(#NonNull MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
NavUtils.navigateUpFromSameTask(this);
return true; // go back to the first screen
case R.id.cardoverview:
startActivity(new Intent(this, cardviewactivity.class));
return true; //go to the screen where all the swiped right activities are stored
}
return super.onOptionsItemSelected(item);
}
#Override
protected void onStart() {
super.onStart();
mAuth.addAuthStateListener(mAuthListener);
}
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
FirebaseInstanceId.getInstance().getInstanceId()
.addOnCompleteListener(new OnCompleteListener<InstanceIdResult>() {
#Override
public void onComplete(#NonNull Task<InstanceIdResult> task) {
if (!task.isSuccessful()) {
Log.w("This Tag", "getInstanceId failed", task.getException());
return;
} else {
Log.d("This tag", "We need this");
}
}
});
swipeDb = FirebaseDatabase.getInstance().getReference().child("Users");
final FirebaseFirestore db = FirebaseFirestore.getInstance();
//Anonymous user login to be registered in Firebase
mAuth = FirebaseAuth.getInstance();
mCurrentUser = mAuth.getCurrentUser(); // save the UID of the user in users in Firebase without having to log in
final String UID = mCurrentUser.getUid();
DatabaseReference currentUserDb = FirebaseDatabase.getInstance().getReference().child("Users").child("UID");
currentUserDb.setValue(UID); //save the User UID to the Firebase Realtime database
// Calling to the AdMob API to add advertisements to the banner in the main view.Gotta make that dough
// Change this to big cards in the future
final AdView adView = findViewById(R.id.adView);
final AdRequest adRequest = new AdRequest.Builder()
//.addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
.build();
Screenshot to Firebase Authentication
Error I'm receiving from the logcat:
W/DynamiteModule: Local module descriptor class for com.google.firebase.auth not found.
I/FirebaseCrashlytics: Initializing Crashlytics 17.0.0
I/FirebaseInitProvider: FirebaseApp initialization successful
I/FirebaseAuth: [FirebaseAuth:] Preparing to create service connection to gms implementation
D/libEGL: loaded /vendor/lib/egl/libEGL_emulation.so
D/libEGL: loaded /vendor/lib/egl/libGLESv1_CM_emulation.so
D/libEGL: loaded /vendor/lib/egl/libGLESv2_emulation.so
V/FA: onActivityCreated
W/rawesome.metim: Accessing hidden method Landroid/view/View;->computeFitSystemWindows(Landroid/graphics/Rect;Landroid/graphics/Rect;)Z (greylist, reflection, allowed)
Accessing hidden method Landroid/view/ViewGroup;->makeOptionalFitsSystemWindows()V (greylist, reflection, allowed)
V/FA: App measurement disabled via the init parameters
I/FA: App measurement initialized, version: 28000
To enable debug logging run: adb shell setprop log.tag.FA VERBOSE
To enable faster debug mode event logging run:
adb shell setprop debug.firebase.analytics.app com.superawesome.metime
D/FA: Debug-level message logging enabled
V/FA: Detected application was in foreground
D/AndroidRuntime: Shutting down VM
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.superawesome.metime, PID: 21746
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.superawesome.metime/com.superawesome.metime.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String com.google.firebase.auth.FirebaseUser.getUid()' on a null object reference
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3341)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3485)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2045)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7478)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:549)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:941)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String com.google.firebase.auth.FirebaseUser.getUid()' on a null object reference
at com.superawesome.metime.MainActivity.onCreate(MainActivity.java:118)
at android.app.Activity.performCreate(Activity.java:7989)
at android.app.Activity.performCreate(Activity.java:7978)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1309)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3316)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3485) 
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83) 
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135) 
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2045) 
at android.os.Handler.dispatchMessage(Handler.java:106) 
at android.os.Looper.loop(Looper.java:223) 
at android.app.ActivityThread.main(ActivityThread.java:7478) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:549) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:941) 
V/FA: Connecting to remote service
D/FA: Event not sent since app measurement is disabled
com.superawesome.metime.MainActivity.onCreate(MainActivity.java:118) --> final String UID = mCurrentUser.getUid();
I've been trying to resolve this issue for over a week now with no success
Edit:
I know I can add listeners to see if the user is anonymously signed in or not. The whole problem around this is that the user is not being signed in anymore at all.
Edit2:
From logcat:
2020-05-30 12:39:53.655 23257-23297/com.superawesome.metime I/DynamiteModule: Selected remote version of com.google.android.gms.ads.dynamite, version >= 21600
2020-05-30 12:39:53.658 23257-23297/com.superawesome.metime V/DynamiteModule: Dynamite loader version >= 2, using loadModule2NoCrashUtils
2020-05-30 12:39:53.770 23257-23311/com.superawesome.metime I/TetheringManager: registerTetheringEventCallback:com.superawesome.metime
2020-05-30 12:39:53.818 23257-23303/com.superawesome.metime W/DynamiteModule: Local module descriptor class for com.google.firebase.auth not found.
2020-05-30 12:39:54.025 23257-23303/com.superawesome.metime I/FirebaseAuth: [FirebaseAuth:] Preparing to create service connection to gms implementation
2020-05-30 12:39:54.076 23257-23257/com.superawesome.metime I/FirebaseCrashlytics: Initializing Crashlytics 17.0.0
2020-05-30 12:39:54.220 23257-23257/com.superawesome.metime I/FirebaseInitProvider: FirebaseApp initialization successful
2020-05-30 12:39:54.332 23257-23332/com.superawesome.metime D/libEGL: loaded /vendor/lib/egl/libEGL_emulation.so
2020-05-30 12:39:54.342 23257-23332/com.superawesome.metime D/libEGL: loaded /vendor/lib/egl/libGLESv1_CM_emulation.so
2020-05-30 12:39:54.362 23257-23332/com.superawesome.metime D/libEGL: loaded /vendor/lib/egl/libGLESv2_emulation.so
2020-05-30 12:39:54.527 23257-23315/com.superawesome.metime V/FA: App measurement disabled via the init parameters
2020-05-30 12:39:55.234 23257-23315/com.superawesome.metime I/FA: App measurement initialized, version: 28000
2020-05-30 12:39:55.247 23257-23315/com.superawesome.metime I/FA: To enable debug logging run: adb shell setprop log.tag.FA VERBOSE
2020-05-30 12:39:55.267 23257-23315/com.superawesome.metime I/FA: To enable faster debug mode event logging run:
adb shell setprop debug.firebase.analytics.app com.superawesome.metime
2020-05-30 12:39:55.274 23257-23315/com.superawesome.metime D/FA: Debug-level message logging enabled
2020-05-30 12:39:57.009 23257-23315/com.superawesome.metime V/FA: Detected application was in foreground
2020-05-30 12:39:57.995 23257-23315/com.superawesome.metime V/FA: Connecting to remote service
2020-05-30 12:40:23.846 23257-23311/com.superawesome.metime W/FirebaseInstanceId: Token retrieval failed: SERVICE_NOT_AVAILABLE. Will retry token retrieval
2020-05-30 12:41:23.931 23257-23311/com.superawesome.metime W/FirebaseInstanceId: Token retrieval failed: SERVICE_NOT_AVAILABLE. Will retry token retrieval
2020-05-30 12:42:54.030 23257-23311/com.superawesome.metime W/FirebaseInstanceId: Token retrieval failed: SERVICE_NOT_AVAILABLE. Will retry token retrieval

Why location doesn't work in app with android 10?

I have an app which streams video and it ensure making photos from another device. It is saving location of device in photo information. It works correctly on older android versions for example 6.0 Unfortunately it doesn't work on android 10 even after updating an app to SDK 29. Do you have any ideas?
When I switch off gps in android 10 phone everything goes well.
Below errors from android studio:
E/i.aoiAgent11EN: Unknown bits set in runtime_flags: 0x8000
I/Perf: Connecting to perf service.
I/FeatureParser: can't find cepheus.xml in assets/device_features/,it may be in /system/etc/device_features
E/libc: Access denied finding property "ro.vendor.df.effect.conflict"
E/Perf: Fail to get file list pl.biz.aoi.aoiAgent11ENG
getFolderSize() : Exception_1 = java.lang.NullPointerException: Attempt to get length of null array
Fail to get file list pl.biz.aoi.aoiAgent11ENG
getFolderSize() : Exception_1 = java.lang.NullPointerException: Attempt to get length of null array
E/AudioPlayer: CPP is working
java.lang.IllegalStateException: Unable to retrieve AudioTrack pointer for getPosition()
at android.media.AudioTrack.native_get_position(Native Method)
at android.media.AudioTrack.getPlaybackHeadPosition(AudioTrack.java:1699)
at pl.biz.aoi.aoiAgent11ENG.media.in.audio.player.SpeakerOutputStream.getPlayed(SpeakerOutputStream.java:46)
at pl.biz.aoi.aoiAgent11ENG.media.in.audio.player.G711AudioPlayer.writeSilenceBufferIfNeeded(G711AudioPlayer.java:136)
at pl.biz.aoi.aoiAgent11ENG.media.in.audio.player.G711AudioPlayer.run(G711AudioPlayer.java:111)
at java.lang.Thread.run(Thread.java:919)
I/chatty: uid=10262(pl.biz.aoi.aoiAgent11ENG) identical 18 lines
E/AudioPlayer: CPP is working
java.lang.IllegalStateException: Unable to retrieve AudioTrack pointer for getPosition()
at android.media.AudioTrack.native_get_position(Native Method)
at android.media.AudioTrack.getPlaybackHeadPosition(AudioTrack.java:1699)
at pl.biz.aoi.aoiAgent11ENG.media.in.audio.player.SpeakerOutputStream.getPlayed(SpeakerOutputStream.java:46)
at pl.biz.aoi.aoiAgent11ENG.media.in.audio.player.G711AudioPlayer.writeSilenceBufferIfNeeded(G711AudioPlayer.java:136)
at pl.biz.aoi.aoiAgent11ENG.media.in.audio.player.G711AudioPlayer.run(G711AudioPlayer.java:111)
at java.lang.Thread.run(Thread.java:919)

AuthorizationCodeInstalledApp - Android Alternative

I'm trying to Authenticate into Google Oauth with Android, I successfully authenticate, store my credentials and auth token but then there's one particular piece of code that I am falling over at; returning an instance of AuthorizationCodeInstalledApp. The problem seems to be that this API is made for Java desktop applications and is trying to load a browser instance. Here is my GoogleCredentialsUtilityModule, a slightly refactored version of the code that is shown in the Android developer docs:
import android.content.Context
import android.os.AsyncTask
import com.example.bluelightlite.constants.CREDENTIALS_FILE_PATH
import com.example.bluelightlite.constants.JSON_FACTORY
import com.example.bluelightlite.constants.SCOPES
import com.example.bluelightlite.constants.TOKENS_DIRECTORY_PATH
import com.google.api.client.auth.oauth2.Credential
import com.google.api.client.extensions.java6.auth.oauth2.AuthorizationCodeInstalledApp
import com.google.api.client.extensions.jetty.auth.oauth2.LocalServerReceiver
import com.google.api.client.googleapis.auth.oauth2.GoogleAuthorizationCodeFlow
import com.google.api.client.googleapis.auth.oauth2.GoogleClientSecrets
import com.google.api.client.http.javanet.NetHttpTransport
import com.google.api.client.util.store.FileDataStoreFactory
import java.io.File
import java.io.FileNotFoundException
import java.io.InputStream
import java.io.InputStreamReader
class GoogleCredentialsUtilityModule constructor(private val context: Context): AsyncTask<NetHttpTransport, Void, Credential>() {
/**
* Starts getting credentials on a different thread by implementing
* AsyncTask<>()
* #param params: a list of parameters
* #return Google Credentials that come from this.getCredentials()
*/
override fun doInBackground(vararg params: NetHttpTransport): Credential {
return this.getCredentials(params[0])
}
/**
* Creates an authorized Credential object.
* #param HTTP_TRANSPORT The network HTTP Transport.
* #return An authorized Credential object.
* #throws java.io.IOException If the credentials.json file cannot be found.
*/
private fun getCredentials(HTTP_TRANSPORT: NetHttpTransport): Credential {
val inputStream: InputStream = getCredentialsAsInputStream()
val clientSecrets: GoogleClientSecrets = GoogleClientSecrets.load(JSON_FACTORY, InputStreamReader(inputStream))
createTokenFolderIfMissing()
val authorisationFlow: GoogleAuthorizationCodeFlow = getAuthorisationFlow(HTTP_TRANSPORT, clientSecrets)
val receiver: LocalServerReceiver = LocalServerReceiver.Builder()
.setPort(8888)
.build()
return AuthorizationCodeInstalledApp(authorisationFlow, receiver).authorize("user") //falls over here
}
/**
* Gets the /credentials.json file
* #return InputStream
*/
private fun getCredentialsAsInputStream(): InputStream {
return this.javaClass.getResourceAsStream(CREDENTIALS_FILE_PATH)
?: throw FileNotFoundException("Resource Not found: $CREDENTIALS_FILE_PATH")
}
/**
* Creates the Tokens Folder for Google Authentication
* Uses the current context for the folder path from
* Context.getExternalFilesDir()
*/
private fun createTokenFolderIfMissing() {
val tokenFolder = getTokenFolder()
if (!tokenFolder.exists()) {
tokenFolder.mkdir()
}
}
/**
* gets External storage directory from the
* current context
* #return File
*/
private fun getTokenFolder(): File {
return File(this.context.getExternalFilesDir("")?.absolutePath + TOKENS_DIRECTORY_PATH)
}
/**
* Gets authorisation flow so that the application can authenticate into Google Calendars
* #param HTTP_TRANSPORT allows the app to use HTTP connections
* #param clientSecrets secrets for authentication into Google
* #return GoogleAuthorizationCodeFlow
*/
private fun getAuthorisationFlow(HTTP_TRANSPORT: NetHttpTransport, clientSecrets: GoogleClientSecrets): GoogleAuthorizationCodeFlow {
return GoogleAuthorizationCodeFlow.Builder(
HTTP_TRANSPORT, JSON_FACTORY, clientSecrets, SCOPES)
.setDataStoreFactory(FileDataStoreFactory(getTokenFolder()))
.setAccessType("offline")
.build()
}
}
Here is my error message:
02/21 20:04:33: Launching 'app' on Pixel 3 XL API 29.
$ adb shell am start -n "com.example.bluelightlite/com.example.bluelightlite.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Connected to process 9795 on device 'Pixel_3_XL_API_29 [emulator-5554]'.
Capturing and displaying logcat messages from application. This behavior can be disabled in the "Logcat output" section of the "Debugger" settings page.
D/libEGL: Emulator has host GPU support, qemu.gles is set to 1.
W/RenderThread: type=1400 audit(0.0:48): avc: denied { write } for name="property_service" dev="tmpfs" ino=6831 scontext=u:r:untrusted_app:s0:c133,c256,c512,c768 tcontext=u:object_r:property_socket:s0 tclass=sock_file permissive=0 app=com.example.bluelightlite
W/libc: Unable to set property "qemu.gles" to "1": connection failed; errno=13 (Permission denied)
D/libEGL: loaded /vendor/lib/egl/libEGL_emulation.so
D/libEGL: loaded /vendor/lib/egl/libGLESv1_CM_emulation.so
D/libEGL: loaded /vendor/lib/egl/libGLESv2_emulation.so
W/System.err: 2020-02-21 20:04:39.683:INFO::Logging to STDERR via org.mortbay.log.StdErrLog
2020-02-21 20:04:39.684:INFO::jetty-0.0
W/System.err: 2020-02-21 20:04:39.805:INFO::Started SocketConnector#localhost:8888
I/System.out: Please open the following address in your browser:
https://accounts.google.com/o/oauth2/auth?access_type=offline&client_id=475059597551-bugt3i0nnfe7unsoqt8ghu2ovm7dfrqg.apps.googleusercontent.com&redirect_uri=http://localhost:8888/Callback&response_type=code&scope=https://www.googleapis.com/auth/calendar.readonly
W/System.err: 2020-02-21 20:04:39.823:INFO::Stopped SocketConnector#localhost:8888
D/AndroidRuntime: Shutting down VM
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.bluelightlite, PID: 9795
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.bluelightlite/com.example.bluelightlite.MainActivity}: java.util.concurrent.ExecutionException: java.lang.NoClassDefFoundError: Failed resolution of: Ljava/awt/Desktop;
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3270)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3409)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2016)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7356)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
Caused by: java.util.concurrent.ExecutionException: java.lang.NoClassDefFoundError: Failed resolution of: Ljava/awt/Desktop;
at java.util.concurrent.FutureTask.report(FutureTask.java:123)
at java.util.concurrent.FutureTask.get(FutureTask.java:193)
at android.os.AsyncTask.get(AsyncTask.java:602)
at com.example.bluelightlite.models.GoogleCalenderCredentials.<init>(GoogleCalanderCredentials.kt:15)
at com.example.bluelightlite.modules.GoogleCalendarsServiceModule.<init>(GoogleCalendarsServiceModule.kt:11)
at com.example.bluelightlite.MainActivity.onCreate(MainActivity.kt:25)
at android.app.Activity.performCreate(Activity.java:7802)
at android.app.Activity.performCreate(Activity.java:7791)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1299)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3245)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3409) 
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83) 
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135) 
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2016) 
at android.os.Handler.dispatchMessage(Handler.java:107) 
at android.os.Looper.loop(Looper.java:214) 
at android.app.ActivityThread.main(ActivityThread.java:7356) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930) 
Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Ljava/awt/Desktop;
at com.google.api.client.extensions.java6.auth.oauth2.AuthorizationCodeInstalledApp.browse(AuthorizationCodeInstalledApp.java:129)
at com.google.api.client.extensions.java6.auth.oauth2.AuthorizationCodeInstalledApp.onAuthorization(AuthorizationCodeInstalledApp.java:113)
at com.google.api.client.extensions.java6.auth.oauth2.AuthorizationCodeInstalledApp.authorize(AuthorizationCodeInstalledApp.java:81)
at com.example.bluelightlite.modules.GoogleCredentialsUtilityModule.getCredentials(GoogleCredentialsUtilityModule.kt:52)
at com.example.bluelightlite.modules.GoogleCredentialsUtilityModule.doInBackground(GoogleCredentialsUtilityModule.kt:31)
at com.example.bluelightlite.modules.GoogleCredentialsUtilityModule.doInBackground(GoogleCredentialsUtilityModule.kt:22)
at android.os.AsyncTask$3.call(AsyncTask.java:378)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:289)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:919)
Caused by: java.lang.ClassNotFoundException: Didn't find class "java.awt.Desktop" on path: DexPathList[[zip file "/data/app/com.example.bluelightlite-6neG3BDx7D1LEKBl_6YMYg==/base.apk"],nativeLibraryDirectories=[/data/app/com.example.bluelightlite-6neG3BDx7D1LEKBl_6YMYg==/lib/x86, /system/lib, /system/product/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:196)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at com.google.api.client.extensions.java6.auth.oauth2.AuthorizationCodeInstalledApp.browse(AuthorizationCodeInstalledApp.java:129) 
at com.google.api.client.extensions.java6.auth.oauth2.AuthorizationCodeInstalledApp.onAuthorization(AuthorizationCodeInstalledApp.java:113) 
at com.google.api.client.extensions.java6.auth.oauth2.AuthorizationCodeInstalledApp.authorize(AuthorizationCodeInstalledApp.java:81) 
at com.example.bluelightlite.modules.GoogleCredentialsUtilityModule.getCredentials(GoogleCredentialsUtilityModule.kt:52) 
at com.example.bluelightlite.modules.GoogleCredentialsUtilityModule.doInBackground(GoogleCredentialsUtilityModule.kt:31) 
at com.example.bluelightlite.modules.GoogleCredentialsUtilityModule.doInBackground(GoogleCredentialsUtilityModule.kt:22) 
at android.os.AsyncTask$3.call(AsyncTask.java:378) 
at java.util.concurrent.FutureTask.run(FutureTask.java:266) 
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:289) 
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) 
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) 
at java.lang.Thread.run(Thread.java:919) 
I/Process: Sending signal. PID: 9795 SIG: 9
I can't seem to find any alternative to AuthorizationCodeInstalledApp. Any advice? Should I write my own Authentication code? Is there an Android version of AuthorizationCodeInstalledApp that I can use? I'm finding the documentation so vague and hard to read.
Developing on API 29 using a Google Pixel 3 XL.
I copied dnsiv's answer and overridden AuthorizationCodeInstalledApp and I now have the following code:
private fun getCredentials(HTTP_TRANSPORT: NetHttpTransport): Credential {
val inputStream: InputStream = getCredentialsAsInputStream()
val clientSecrets: GoogleClientSecrets = GoogleClientSecrets.load(JSON_FACTORY, InputStreamReader(inputStream))
createTokenFolderIfMissing()
val authorisationFlow: GoogleAuthorizationCodeFlow = getAuthorisationFlow(HTTP_TRANSPORT, clientSecrets)
val ab: AuthorizationCodeInstalledApp =
object : AuthorizationCodeInstalledApp(authorisationFlow, LocalServerReceiver()) {
#Throws(IOException::class)
override fun onAuthorization(authorizationUrl: AuthorizationCodeRequestUrl) {
val url = authorizationUrl.build()
val browserIntent = Intent(Intent.ACTION_VIEW, Uri.parse(url))
context.startActivity(browserIntent)
}
}
return ab.authorize("user").setAccessToken("user")
Hmm - looks like you are running a loopback web server on port 8888, which is more of a desktop solution than a mobile one.
You are likely to get a more user friendly and reliable solution by logging in via a Chrome Custom Tab and using Google AppAuth libraries. It is not easy though.
Maybe have a look at my Tutorial + Code Sample which may at least give you something to compare against.

Categories

Resources