ANRs & crashes (help to read log) - android

I did my first app(called Tumch in Google Play if someone wants to search it kk) and has few users, most of the users use the app with no problems, but there are users crashing.
That is the log on Play console:
java.lang.RuntimeException:
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2426)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2490)
at android.app.ActivityThread.-wrap11(ActivityThread.java:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1354)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5443)
at java.lang.reflect.Method.invoke(Native Method:0)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:728)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
Caused by: java.lang.NullPointerException:
at android.util.Log.println_native_inner(Native Method:0)
at android.util.Log.println_native(Log.java:290)
at android.util.Log.d(Log.java:323)
at example.mostliked.UserPage.onCreate(Unknown Source:0)
at android.app.Activity.performCreate(Activity.java:6245)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1130)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2379)
What does it mean? How can I solve that problem? Cause in tests in my phones I didn't find errors.

It looks like you're feeding a null String to Log.d.
Try adding a null check before logging, ex:
Log.d(TAG, objectToLog == null ? "null" : objectToLog.toString());
You might also just consider removing, pro-guarding, or commenting out logs for the production build.

Related

AndroidStudio doesn't run app on device [duplicate]

This question already has answers here:
What is a NullPointerException, and how do I fix it?
(12 answers)
Closed 5 years ago.
I'm developing an Android application with Android Studio and since today I can no longer run the app because when Android Studio installs the apk on my device, the package installer crashes with the following message "Unfortunately, package installer has stopped". The strange thing is that when I run the application I can see for a second the main activity and its components but then everything crashes.
This is the exception:
10-15 22:16:48.185 1793-1793/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.android.packageinstaller, PID: 1793
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.android.packageinstaller/com.android.packageinstaller.permission.ui.GrantPermissionsActivity}: java.lang.NullPointerException: Attempt to get length of null array
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2434)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2494)
at android.app.ActivityThread.access$900(ActivityThread.java:153)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1347)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5451)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: java.lang.NullPointerException: Attempt to get length of null array
at com.android.packageinstaller.permission.ui.GrantPermissionsActivity.computePermissionGrantState(GrantPermissionsActivity.java:312)
at com.android.packageinstaller.permission.ui.GrantPermissionsActivity.updateDefaultResults(GrantPermissionsActivity.java:362)
at com.android.packageinstaller.permission.ui.GrantPermissionsActivity.onCreate(GrantPermissionsActivity.java:105)
at android.app.Activity.performCreate(Activity.java:6323)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1108)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2387)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2494) 
at android.app.ActivityThread.access$900(ActivityThread.java:153) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1347) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:148) 
at android.app.ActivityThread.main(ActivityThread.java:5451) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Thank you very much in advance
You have an issue with "granted permissions on runtime", basically you must grant permissions to use specific functionalities.
Have a look here: https://developer.android.com/training/permis
Have a look at you manifest and check which of the "user-permissions" are required to check in runtime, if you have not user-permissions added, then now is the time https://developer.android.com/guide/topics/manifest/uses-permission-element.html.
Then use the code provided in the first link after to check runtime permissions.
Remember: ask permissions on runtime is required for Android 6.0 (API level 23) and above. On lower SDK (<=22), is enough adding the "user-permissions" into the manifest.

Unity Android 6 Fragment$InstantiationException

recently (past few weeks maybe) most of the android 6 users of my app started to suffer from crashes. UnityPlayerActivity failed to start with exception logged: android.app.Fragment$InstantiationException.
Stack trace:
java.lang.RuntimeException:
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2450)
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2510)
android.app.ActivityThread.-wrap11(ActivityThread.java:0)
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1363)
android.os.Handler.dispatchMessage(Handler.java:102)
android.os.Looper.loop(Looper.java:148)
android.app.ActivityThread.main(ActivityThread.java:5461)
java.lang.reflect.Method.invoke(Native Method:0)
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: android.app.Fragment$InstantiationException:
android.app.Fragment.instantiate(Fragment.java:628)
android.app.FragmentState.instantiate(Fragment.java:106)
android.app.FragmentManagerImpl.restoreAllState(FragmentManager.java:1858)
android.app.FragmentController.restoreAllState(FragmentController.java:122)
android.app.Activity.onCreate(Activity.java:918)
com.unity3d.player.UnityPlayerActivity.onCreate(Unknown Source:0)
android.app.Activity.performCreate(Activity.java:6251)
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1108)
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2403)
Initially my first thought was permissions problem but I can't reproduce this error on any of my android 6 devices even if I deny permission (WRITE_EXTERNAL_STORAGE).
Is there is any workaround for this problem(if this problem is a common for Unity on Android 6)?
Thanks in advance!
PS:
Unity version 5.5.0f3,
Android version from crush reports 6.0

When I import Google`s UniversalMusicPlayer to my android studio, it crashed

I am a newcomer who want to learn android.My friend suggested me to read the code of that player,but when I imported the project and compiled it,it crashed...
12-22 20:58:07.755 4870-4870/com.example.android.uamp
E/AndroidRuntime: FATAL EXCEPTION: main Process:
com.example.android.uamp, PID: 4870 java.lang.RuntimeException: Unable
to start activity
ComponentInfo{com.example.android.uamp/com.example.android.uamp.ui.MusicPlayerActivity}:
java.lang.RuntimeException: com.google.android.gms.internal.zzsb$zza:
No acceptable module found. Local version is 0 and remote version is
0. at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2448)
at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2510)
at android.app.ActivityThread.access$1200(ActivityThread.java:163) at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1371)
at android.os.Handler.dispatchMessage(Handler.java:102) at
android.os.Looper.loop(Looper.java:135) at
android.app.ActivityThread.main(ActivityThread.java:5595) at
java.lang.reflect.Method.invoke(Native Method) at
java.lang.reflect.Method.invoke(Method.java:372) at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:960)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755) Caused
by: java.lang.RuntimeException:
com.google.android.gms.internal.zzsb$zza: No acceptable module found.
Local version is 0 and remote version is 0. at
com.google.android.gms.internal.zzni.zzbg(Unknown Source) at
com.google.android.gms.internal.zzni.zza(Unknown Source) at
com.google.android.gms.cast.framework.CastContext.(Unknown
Source) at
com.google.android.gms.cast.framework.CastContext.getSharedInstance(Unknown
Source) at
com.example.android.uamp.ui.ActionBarCastActivity.onCreate(ActionBarCastActivity.java:141)
at
com.example.android.uamp.ui.BaseActivity.onCreate(BaseActivity.java:49)
at
com.example.android.uamp.ui.MusicPlayerActivity.onCreate(MusicPlayerActivity.java:57)
at android.app.Activity.performCreate(Activity.java:6100) at
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1109)
at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2401)
at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2510)
at android.app.ActivityThread.access$1200(ActivityThread.java:163) at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1371)
at android.os.Handler.dispatchMessage(Handler.java:102) at
android.os.Looper.loop(Looper.java:135) at
android.app.ActivityThread.main(ActivityThread.java:5595) at
java.lang.reflect.Method.invoke(Native Method) at
java.lang.reflect.Method.invoke(Method.java:372) at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:960)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
Caused by: com.google.android.gms.internal.zzsb$zza: No acceptable
module found. Local version is 0 and remote version is 0. at
com.google.android.gms.internal.zzsb.zza(Unknown Source) at
com.google.android.gms.internal.zzni.zzbg(Unknown Source) at
com.google.android.gms.internal.zzni.zza(Unknown Source) at
com.google.android.gms.cast.framework.CastContext.(Unknown
Source) at
com.google.android.gms.cast.framework.CastContext.getSharedInstance(Unknown
Source) at
com.example.android.uamp.ui.ActionBarCastActivity.onCreate(ActionBarCastActivity.java:141)
at
com.example.android.uamp.ui.BaseActivity.onCreate(BaseActivity.java:49)
at
com.example.android.uamp.ui.MusicPlayerActivity.onCreate(MusicPlayerActivity.java:57)
at android.app.Activity.performCreate(Activity.java:6100) at
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1109)
at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2401)
at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2510)
at android.app.ActivityThread.access$1200(ActivityThread.java:163) at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1371)
at android.os.Handler.dispatchMessage(Handler.java:102) at
android.os.Looper.loop(Looper.java:135) at
android.app.ActivityThread.main(ActivityThread.java:5595) at
java.lang.reflect.Method.invoke(Native Method) at
java.lang.reflect.Method.invoke(Method.java:372) at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:960)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
Well,when I searched for answers,the responses were not useful...
And if you have some wonderful open source project to recommend ,hope you can tell me.Thx.
Sorry for my poor english...
You need to update your google play service of device.
You can see this Bug report which already has been addressed
and possibility you will have to update your gcm dependency then appropriate modifications of code will also required mean the deprecated methods will be needed to replaced with new one in the project for e.g GoogleApiAvailability to register token etc so also make sure you are using the latest gcm dependency in your project

How to debug RealmMigrationNeededException on Android?

I use a realm database in my android project.
I've added a new column to my realm db which I generate out of a CSV and did the same in my entity file.
However, I now get a RealmMigrationNeededException if I start my app although I have uninstalled it before. So it seems like if my generated database and the entity file don't match.
I would like to know if it's possible to find out what exactly causes the exception. The stacktrace I get in Android Studio doesn't contain any clues which might help me to resolve the issue
FATAL EXCEPTION: main
Process: de.myCompany.myApp, PID: 5270
java.lang.RuntimeException: Error receiving broadcast Intent { act=android.net.conn.CONNECTIVITY_CHANGE flg=0x4000010 (has extras) } in de.myCompany.myApp.helper.WifiReceiver#2d683f50
at android.app.LoadedApk$ReceiverDispatcher$Args.run(LoadedApk.java:872)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5254)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:898)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:693)
Caused by: io.realm.exceptions.RealmMigrationNeededException: RealmMigration must be provided
at io.realm.BaseRealm.migrateRealm(BaseRealm.java:589)
at io.realm.Realm.migrateRealm(Realm.java:1224)
at io.realm.Realm.migrateRealm(Realm.java:1213)
at io.realm.Realm.createInstance(Realm.java:237)
at io.realm.RealmCache.createRealmOrGetFromCache(RealmCache.java:114)
at io.realm.Realm.getInstance(Realm.java:197)
at de.myCompany.myApp.ImageDownloadController.fillDownloadStack(ImageDownloadController.java:94)
at de.myCompany.myApp.ImageDownloadController.<init>(ImageDownloadController.java:37)
at de.myCompany.myApp.ImageDownloadController.getInstance(ImageDownloadController.java:42)
at de.myCompany.myApp.helper.WifiReceiver.onReceive(WifiReceiver.java:30)
at android.app.LoadedApk$ReceiverDispatcher$Args.run(LoadedApk.java:862)
at android.os.Handler.handleCallback(Handler.java:739) 
at android.os.Handler.dispatchMessage(Handler.java:95) 
at android.os.Looper.loop(Looper.java:135) 
at android.app.ActivityThread.main(ActivityThread.java:5254) 
at java.lang.reflect.Method.invoke(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:372) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:898) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:693)
Is there any proper way to debug a RealmMigrationNeededException except for trial and error?
If a RealmMigrationExceptionNeeded error happens, Realm automatically tries to trigger any configured migration to fix it. If no such RealmMigration exists, you instead get another RealmMigrationNeededException that overrides the underlying cause.
The fix is to just provide a dummy RealmMigration to see the real error.
I can see why it can be a bit confusing, and we should probably consider throwing a better exception message that also include the underlying cause.

issues with ttorrent with android?

i was looking for a torrent library for android and came-across ttorrent
.when i tried to add dependencty to gradle it gave me errors regarding slf4j-log4j12.
i ended up adding all jar files manually and managed to run the app using sample code.
But i am getting this error now.
ClassLoader referenced unknown path: /data/app/com.test.torrent-1/lib/arm64
android.os.NetworkOnMainThreadException
at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1273)
at java.net.InetAddress.lookupHostByName(InetAddress.java:431)
at java.net.InetAddress.getLocalHost(InetAddress.java:409)
at com.test.torrent.MainActivity.onCreate(MainActivity.java:26)
at android.app.Activity.performCreate(Activity.java:6251)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
i think it is trying to find a library but i cannot find it , that path does not exist in my mobile , any help?

Categories

Resources