Keywords: android, log, adb
My problem is after long runnning time, my application crashes while resumes. This bug crashes abnormaly, so I cannot collect it at that time.
Right after my application crashes, I want to collect recent log of my application so I can find out the bug. How can I do it?
Any suggestion may help, thanks.
I see at least to ways to do it:
Crashlytics
To collect crash reports, I advise you to use Crashlytics. Made by Twitter, easy to maintain and use.
Here you would find more info:
https://fabric.io/kits/android/crashlytics/summary
http://try.crashlytics.com/sdk-android/
It has also an Android Studio & IntelliJ Idea plugins.
Firebase Crash Reporting
You can also use introduced by Google new Fibase feature called Firebase Crash Reporting. Check: https://firebase.google.com/docs/crash/
I've already used the first solution and I'm pretty sure that you would love this.
The answer of piotrek1543 is great.
I just add this as an situational option:
After your app crashes, there is a chance that your phone still have that log. If that is the case, you can connect your phone with usb cable then use adb shell to fetch it:
adb shell "logcat your.app.package:W -v long | grep E/AndroidRuntime" > android.log
E/AndroidRuntime is a key filter for android runtime error log, change it as you want. You will get something like:
E/AndroidRuntime( 2494): FATAL EXCEPTION: main
E/AndroidRuntime( 2494): Process: your.app.package, PID: 2494
E/AndroidRuntime( 2494): java.lang.RuntimeException: MainActivity btn_throwException
E/AndroidRuntime( 2494): at your.app.package.MainActivity$2.onClick(MainActivity.java:35)
E/AndroidRuntime( 2494): at android.view.View.performClick(View.java:4463)
E/AndroidRuntime( 2494): at android.view.View$PerformClick.run(View.java:18770)
E/AndroidRuntime( 2494): at android.os.Handler.handleCallback(Handler.java:808)
E/AndroidRuntime( 2494): at android.os.Handler.dispatchMessage(Handler.java:103)
E/AndroidRuntime( 2494): at android.os.Looper.loop(Looper.java:193)
E/AndroidRuntime( 2494): at android.app.ActivityThread.main(ActivityThread.java:5323)
E/AndroidRuntime( 2494): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 2494): at java.lang.reflect.Method.invoke(Method.java:515)
E/AndroidRuntime( 2494): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:828)
E/AndroidRuntime( 2494): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:644)
E/AndroidRuntime( 2494): at dalvik.system.NativeStart.main(Native Method)
see more here https://developer.android.com/studio/command-line/logcat.html
Related
I just recently launched my React Native Android app into production and a bunch of users are experiencing the following crash:
java.lang.NoClassDefFoundError
I'm not sure how to go about debugging this. I can't seem to reproduce it locally on any of my physical devices, and because it's Java and not JavaScript, I'm a bit unfamiliar. It looks like these users are all on Android 4.x, could that have something to do with it?
If you could help point me in the right direction, I would really appreciate it!
I had the same issue that i was not able to reproduce but i get the following error in a simulator Android 4.4
I'm not sure if it's android vitals that just return a partial error or if it's actually not the same error.
java.lang.RuntimeException:
Unable to get provider com.google.firebase.provider.FirebaseInitProvider: java.lang.ClassNotFoundException
E/AndroidRuntime( 3446): at android.app.ActivityThread.installProvider(ActivityThread.java:4793)
E/AndroidRuntime( 3446): at android.app.ActivityThread.installContentProviders(ActivityThread.java:4385)
E/AndroidRuntime( 3446): at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4325)
E/AndroidRuntime( 3446): at android.app.ActivityThread.access$1500(ActivityThread.java:135)
E/AndroidRuntime( 3446): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
E/AndroidRuntime( 3446): at android.os.Handler.dispatchMessage(Handler.java:102)
E/AndroidRuntime( 3446): at android.os.Looper.loop(Looper.java:136)
E/AndroidRuntime( 3446): at android.app.ActivityThread.main(ActivityThread.java:5017)
E/AndroidRuntime( 3446): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 3446): at java.lang.reflect.Method.invoke(Method.java:515)
E/AndroidRuntime( 3446): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
E/AndroidRuntime( 3446): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
E/AndroidRuntime( 3446): at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime( 3446): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.firebase.provider.FirebaseInitProvider"
E/AndroidRuntime( 3446): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
E/AndroidRuntime( 3446): at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
E/AndroidRuntime( 3446): at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
E/AndroidRuntime( 3446): at android.app.ActivityThread.installProvider(ActivityThread.java:4778)
E/AndroidRuntime( 3446): ... 12 more
This error was making the app crash on startup
I was able to fix it with this answer : https://stackoverflow.com/a/37317943/11170097
Use Multidex.
in your app/build.gradle
android {
...
defaultConfig {
....
multiDexEnabled true
}
...
}
dependencies {
implementation 'com.android.support:multidex:1.0.3'
...
}
in your app/src/main/java/.../MainApplication.java
...
import android.support.multidex.MultiDex;
import android.content.Context;
public class MyApplication extends ... {
...
#Override
protected void attachBaseContext(Context context) {
super.attachBaseContext(context);
MultiDex.install(this);
}
}
I have currently encountered this issue at my project. The root cause of this issue is the unavailability of certain classes at specific API level.
For my case, I used RoleManager which is only available since API 29. Even I added a runtime checking like:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
// Use `RoleManager` ...
}
The above line of codes are run smoothly in Native Android project but React Native throws me the error. This is actually caused by the line of import !
import android.app.role.RoleManager
Although I cannot find any RN official documentation about this phenomenon at the moment, I believe RN checks if all imports are valid before running developer's codes! Therefore, it is a totally different idea with Native Android programming flow!
Solution could be moving everything you're using into a Util.java / Util.kt and complete you logic in another class!
i'm using Pgs4a (Pygame Subset for Android) to build my app. This works fine, until:
Recently i integrated the Google Play Services into my app for using Admob, but unfortunately my app crashes as soon as i launch it.
I already asked in Google Group for Admob, which recommended me to ask for help here. I also saw some posts here, but didn't solve my problem.
Here is, what i think, is the important part of my logcat.log
E/dalvikvm( 7969): dlopen("/data/app-lib/com.myapp-1/libsdl_mixer.so") failed: dlopen failed: cannot locate symbol "__gnu_thumb1_case_sqi" referenced by "libsdl_mixer.so"...
W/dalvikvm( 7969): threadid=15: thread exiting with uncaught exception (group=0x417f5da0)
E/AndroidRuntime( 7969): FATAL EXCEPTION: Thread-817
E/AndroidRuntime( 7969): Process: com.myapp, PID: 7969
E/AndroidRuntime( 7969): java.lang.UnsatisfiedLinkError: dlopen failed: cannot locate symbol "__gnu_thumb1_case_sqi" referenced by "libsdl_mixer.so"...
E/AndroidRuntime( 7969): at java.lang.Runtime.loadLibrary(Runtime.java:365)
E/AndroidRuntime( 7969): at java.lang.System.loadLibrary(System.java:526)
E/AndroidRuntime( 7969): at org.renpy.android.PythonActivity.run(PythonActivity.java:280)
E/AndroidRuntime( 7969): at java.lang.Thread.run(Thread.java:841)
W/ActivityManager( 704): Force finishing activity com.myapp/org.renpy.android.PythonActivity
The libsdl_mixer.so is inside my pygs4a/libs/armeabi folder, if that helps.
Have you any ideas what i'm doing wrong?
I work on Windows 7 by the way.
Any help is much appreciated :)
I have updated to Genymotion 2.0 and downloaded/deployed the new 4.3 images (Galaxy Nexus and 10.1 Tablet) upon installing the appropriate GApps package get a devastating error upon launching a development app with the following stack trace making the device restart.
I/Process ( 3117): Sending signal. PID: 3117 SIG: 9
E/AndroidRuntime( 3117): *** FATAL EXCEPTION IN SYSTEM PROCESS: android.server.ServerThread
E/AndroidRuntime( 3117): java.lang.IllegalArgumentException: provider doesn't exisit: null
E/AndroidRuntime( 3117): at com.android.server.LocationManagerService.requestLocationUpdatesLocked(LocationManagerService.java:1323)
E/AndroidRuntime( 3117): at com.android.server.LocationManagerService.requestLocationUpdates(LocationManagerService.java:1302)
E/AndroidRuntime( 3117): at android.location.LocationManager.requestLocationUpdates(LocationManager.java:836)
E/AndroidRuntime( 3117): at android.location.LocationManager.requestLocationUpdates(LocationManager.java:461)
E/AndroidRuntime( 3117): at com.android.location.fused.FusionEngine.enableProvider(FusionEngine.java:138)
E/AndroidRuntime( 3117): at com.android.location.fused.FusionEngine.updateRequirements(FusionEngine.java:191)
E/AndroidRuntime( 3117): at com.android.location.fused.FusionEngine.setRequest(FusionEngine.java:114)
E/AndroidRuntime( 3117): at com.android.location.fused.FusedLocationProvider$2.handleMessage(FusedLocationProvider.java:98)
E/AndroidRuntime( 3117): at androi
For what I know the last update to Genymotion removed the support for google apps and google-play-service from it's images because of some disagreement with Google, you can read more about it here:
https://plus.google.com/+GenymotionEmulator/posts/jNF8Kwu5p1c
So from now on, you can't run Google Maps API V2 applications and use other features of the google-play-service like the LocationManager you are trying to use.
UPDATE:
As mentioned in the comments you could install the GApps package manually using the following guide:
http://blog.zeezonline.com/2013/11/install-google-play-on-genymotion-2-0/
I'm new to Android and App Engine, I'm trying to create an App Engine Connected Android Project, following the steps described here:
http://code.google.com/intl/es-ES/eclipse/docs/appengine_connected_android.html
but I'm not able to go through the "Say Hello" step (Run & Debug:7) using C2DM, since it prompts a SocketException ("Address family not supported by protocol") and sometimes a RuntimeException when debugging it locally... I don't get it, because I didn't customize the project yet, but after some debugging I saw that it was complaining about some libraries (included at the project creation) not having a source attachment... The most annoying part is that it complains about ThreadPoolExecutor.class, which belongs to java.util.concurrent in the Android 2.2 JAR... Weird, but anyway I attached the library to its source and it keeps complaining about the same class ("The source attachment does not contain the source for the file ThreadPoolExecutor.class")...
It seems to crash in the Util.getRequestFactory() method, at the execution of the first line. Here it calls a method in RequestFactorySource, which belongs to the requestfactory-client library, included at the project creation but again, without a source attachment... By the way, after executing that method call, the "task" variable is valued null, is it normal?
I guess it is about a small error in the configuration or something, but I've been struggling with it for days and I already don't know what to do, so any help would be appreciated :)
EDIT: I'm attaching the logcat output, I hope this makes it easier to find the bug. After googling I found out that it is a common error in the C2DM sample project, but I didn't get any appropiate solution.
I/C2dmftwActivity( 333): onCreate
I/ActivityManager( 58): Displayed activity com.c2dmftw/.C2dmftwActivity: 1281
ms (total 1281 ms)
D/dalvikvm( 126): GC_EXPLICIT freed 997 objects / 54032 bytes in 83ms
W/dalvikvm( 333): threadid=7: thread exiting with uncaught exception (group=0x4
001d800)
E/AndroidRuntime( 333): FATAL EXCEPTION: AsyncTask #1
E/AndroidRuntime( 333): java.lang.RuntimeException: An error occured while exec
uting doInBackground()
E/AndroidRuntime( 333): at android.os.AsyncTask$3.done(AsyncTask.java:20
0)
E/AndroidRuntime( 333): at java.util.concurrent.FutureTask$Sync.innerSet
Exception(FutureTask.java:273)
E/AndroidRuntime( 333): at java.util.concurrent.FutureTask.setException(
FutureTask.java:124)
E/AndroidRuntime( 333): at java.util.concurrent.FutureTask$Sync.innerRun
(FutureTask.java:307)
E/AndroidRuntime( 333): at java.util.concurrent.FutureTask.run(FutureTas
k.java:137)
E/AndroidRuntime( 333): at java.util.concurrent.ThreadPoolExecutor.runWo
rker(ThreadPoolExecutor.java:1068)
E/AndroidRuntime( 333): at java.util.concurrent.ThreadPoolExecutor$Worke
r.run(ThreadPoolExecutor.java:561)
E/AndroidRuntime( 333): at java.lang.Thread.run(Thread.java:1096)
E/AndroidRuntime( 333): Caused by: java.lang.RuntimeException: The RequestFacto
ry ValidationTool must be run for the com.c2dmftw.client.MyRequestFactory Reques
tFactory type
E/AndroidRuntime( 333): at com.google.web.bindery.requestfactory.vm.impl
.Deobfuscator$Builder.load(Deobfuscator.java:59)
E/AndroidRuntime( 333): at com.google.web.bindery.requestfactory.vm.InPr
ocessRequestFactory.<init>(InProcessRequestFactory.java:80)
E/AndroidRuntime( 333): at com.google.web.bindery.requestfactory.vm.Requ
estFactorySource.create(RequestFactorySource.java:43)
E/AndroidRuntime( 333): at com.c2dmftw.Util.getRequestFactory(Util.java:
158)
E/AndroidRuntime( 333): at com.c2dmftw.C2dmftwActivity$2$1.doInBackgroun
d(C2dmftwActivity.java:144)
E/AndroidRuntime( 333): at com.c2dmftw.C2dmftwActivity$2$1.doInBackgroun
d(C2dmftwActivity.java:1)
E/AndroidRuntime( 333): at android.os.AsyncTask$2.call(AsyncTask.java:18
5)
E/AndroidRuntime( 333): at java.util.concurrent.FutureTask$Sync.innerRun
(FutureTask.java:305)
E/AndroidRuntime( 333): ... 4 more
W/ActivityManager( 58): Force finishing activity com.c2dmftw/.C2dmftwActivit
y
W/GTalkService( 170): [GTalkConnection.13] doConnect: caught XMPPError connecti
ng to mtalk.google.com:5228.: (502)
W/GTalkService( 170): -- caused by: java.net.SocketException: The operation t
imed out
I think I had the same problem. The Validation library was missing and after adding it manually it worked.
To add it or to check if it's included do:
Right click on your project > Properties > Java Build Path > Libraries Tab > Add External JARs
Then browser to your GWT installation folder. If you installed it with eclipse it's in eclipse/plugins/com.google.gwt.eclipse.sdkbundle_/gwt-/validation-api-1.0.0.GA.jar
Clean and build your workspace and try it again.
This could happen on the client GWT side too. If that happens you have to do the same but use your GAE project and add the same jar
This is the problem
Caused by: java.lang.RuntimeException: The RequestFacto
ry ValidationTool must be run for the com.c2dmftw.client.MyRequestFactory Reques
tFactory type
If you are using GWT 2.4+, you will have to run a validation tool. You can configure Eclipse to do this for you, here is how:
http://code.google.com/p/google-web-toolkit/wiki/RequestFactoryInterfaceValidation
I've got an application which (although I'm not sure why,) requires Android 2.2 at least to work, so after getting Froyo on my phone, I tested the application and although it installs and begins to run, when I carry out a function, it results in the following error:
"The application has stopped unexpected. Please try again."
It works fine on the emulator which is also running Froyo so I can't figure out what the problem is. The error in adb logcat is the following:
W/dalvikvm( 1027): threadid=1: thread exiting with uncaught exception (group=0x2aacc8a0)
And it gives a null pointer exception, except I know that there isn't a null pointer exception as it works fine in the emulator and I can see from the System.out in adb logcat that the value won't be null.
Does anyone have any idea on what I can do to fix this?
Thank you for your time!
Edit: Here is the stack as requested:
W/dalvikvm( 861): threadid=1: thread exiting with uncaught exception (group=0x2aacc8a0)
E/AndroidRuntime( 861): FATAL EXCEPTION: main
E/AndroidRuntime( 861): java.lang.NullPointerException
E/AndroidRuntime( 861): at com.andrWow.wCraftArmory.Armory.updateUI(Armory.java:150)
E/AndroidRuntime( 861): at com.andrWow.wCraftArmory.Armory.access$2(Armory.java:140)
E/AndroidRuntime( 861): at com.andrWow.wCraftArmory.Armory$carryOutSearch.onPostExecute(Armory.java:282)
E/AndroidRuntime( 861): at com.andrWow.wCraftArmory.Armory$carryOutSearch.onPostExecute(Armory.java:1)
E/AndroidRuntime( 861): at android.os.AsyncTask.finish(AsyncTask.java:417)
E/AndroidRuntime( 861): at android.os.AsyncTask.access$300(AsyncTask.java:127)
E/AndroidRuntime( 861): at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:429)
E/AndroidRuntime( 861): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime( 861): at android.os.Looper.loop(Looper.java:123)
E/AndroidRuntime( 861): at android.app.ActivityThread.main(ActivityThread.java:4627)
E/AndroidRuntime( 861): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 861): at java.lang.reflect.Method.invoke(Method.java:521)
E/AndroidRuntime( 861): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:876)
E/AndroidRuntime( 861): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:634)
E/AndroidRuntime( 861): at dalvik.system.NativeStart.main(Native Method)
W/ActivityManager( 123): Force finishing activity com.andrWow.wCraftArmory/.Armory
Here is the code around line 150 - The second line is line 150:
PlayerCharacter toon = worker.getToons().get(latestToon[0] + "&" + latestToon[1]);
LinkedHashMap<String, LinkedHashMap<String, String>> bM = toon.getCategoryMap("baseStats");
It only gets this far if the result of assigning "toon" is not going to be null. The result of getCategoryMap with that key also shouldn't be null because it's pretty much hardcoded to adding a value with that key when it is created. getCategoryMap is a getter which checks the HashMap contains that key, if it doesn't, it would give an error into the system.out which isn't there.
Solved edit:
Thanks for your help everyone.
I really didn't think it was a fault with the code because I knew it worked on the emulator and I had it running once on the phone too but it turns out it was a fault with my code. After getting FroYo, I set it up which included adding a new keyboard which automatically changed the case of the first letter so it was a matter of me not handling upper/lower cases properly - a silly mistake.
Thanks for your time, really appreciated!
Well, the obvious answer is that PlayerCharacter toon = worker.getToons().get(latestToon[0] + "&" + latestToon[1]); is returning null.
To figure out exactly why you can break it down into a few steps. What does latestToon[0] + "&" + latestToon[1] give you? Is it what you expect? I assume getToons() returns a map of some sort? What are the contents of it?