I have some problems with my Native Activity application. It works fine on 99% of devices. But sometimes users get the following error:
java.lang.RuntimeException: Unable to start activity ComponentInfo{nightradio.sunvox/nightradio.sunvox.MyNativeActivity}:
java.lang.IllegalArgumentException: Unable to find native library: sundog
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2070)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2095)
at android.app.ActivityThread.access$600(ActivityThread.java:134)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1203)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4830)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:556)
at dalvik.system.NativeStart.main(Native Method)
...
I can't understand why. The app have all necessary libraries in the armeabi, armeabi-v7a and x86 folders. And it has been tested on many devices with different architectures.
android:hasCode="true" option exists.
Also i noticed, that the most of these problematic devices has Rockchip CPU (RK3066, RK2928, RK2926). But not all. The latest one has Huawei K3V2 CPU and a lot of free memory. Another Native Activity apps (not mine) don't work on the latest device too.
You will need to read the logcat output to see what happened prior to the crash, which prevented the native library from loading. I use Acra for my apps (generates crash reports containing logcat output), but as a quick solution to get the logcat output without implementing a whole crash reporting system, you could use something like this in a test build, and have the user run it:
try
{
Process process = Runtime.getRuntime().exec( "logcat -d" );
BufferedReader bufferedReader = new BufferedReader(
new InputStreamReader( process.getInputStream() ) );
StringBuilder log = new StringBuilder();
String line = "";
while( ( line = bufferedReader.readLine() ) != null ) {
log.append( line );
}
// Output available via log.toString().. do whatever with it
}
catch( IOException e ) {}
If you look at the source code for NativeActivty, this exception you are seeing gets thrown in the onCreate() method (see line 171), so if you override that method in a derived class of NativeActivity, you can catch it and grab the logcat output from there. Then you could save the log to a file and have a user with an affected device run the test and email the file to you, for example.
Another good thing about overriding onCreate(), is it will also allow you to reproduce some of what goes on behind the scenes, with more debug logging to help you track down the problem.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With