No JNI_Onload() found and VM shutting down - android

I am new to Android ,
I followed the instructions on the link http://marakana.com/forums/android/examples/49.html to create the basic application using NDK.
I followed those steps exactly. I also created the shared library.
When I run the application, CatLog shows the following errors:
Trying to load lib /data/data/com.example.NDKDemo/lib/libndk_demo.so 0x4129dc18
01-30 04:50:58.856: D/dalvikvm(586): Added shared lib
/data/data/com.example.NDKDemo/lib/libndk_demo.so 0x4129dc18
01-30 04:50:58.856: D/dalvikvm(586): No JNI_OnLoad found in
/data/data/com.example.NDKDemo/lib/libndk_demo.so 0x4129dc18,
skipping init
01-30 04:50:58.866: D/AndroidRuntime(586): Shutting down VM
01-30 04:50:58.866: W/dalvikvm(586): threadid=1: thread exiting with uncaught
exception (group=0x409c01f8)
01-30 04:50:58.896: E/AndroidRuntime(586): FATAL EXCEPTION: main
01-30 04:50:58.896: E/AndroidRuntime(586): java.lang.RuntimeException:
Unable to instantiate activity ComponentInfo
{com.example.NDKDemo/com.example.NDKDemo.NativeLib}:
java.lang.ClassCastException:
com.example.NDKDemo.NativeLib cannot be cast to android.app.Activity

As mentioned, JNI_OnLoad isn't necessary. Here's your problem:
Unable to instantiate activity ComponentInfo
{com.example.NDKDemo/com.example.NDKDemo.NativeLib}:
java.lang.ClassCastException:
com.example.NDKDemo.NativeLib cannot be cast to android.app.Activity
Your bug isn't even an NDK issue, it looks like: Your class com.example.NDKDemo.NativeLib can't be cast to android.app.Activity.
The class you list in AndroidManifest.xml is the one that derives from Activity. If you created an NDKDemo class like in the example, then that's your activity, and you should name it in AndroidManifest.xml:
<activity android:name="NDKDemo" ... other options ... >

Related

Errors related to Android NDK

Running this in my android device gives me these errors.
Exception Ljava/lang/UnsatisfiedLinkError; thrown while initializing Lffvideolivewallpaper/frankandrobot/com/NativeCalls;
Shutting down VM
threadid=1: thread exiting with uncaught exception (group=0x40ed42a0)
FATAL EXCEPTION: main
java.lang.ExceptionInInitializerError
at ffvideolivewallpaper.frankandrobot.com.VideoLiveWallpaper.onSharedPreferenceChanged(VideoLiveWallpaper.java:144)
at ffvideolivewallpaper.frankandrobot.com.VideoLiveWallpaper.onCreate(VideoLiveWallpaper.java:78)
at android.app.ActivityThread.handleCreateService(ActivityThread.java:2404)
at android.app.ActivityThread.access$1600(ActivityThread.java:140)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1309)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4898)
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:1006)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.UnsatisfiedLinkError: Couldn't load avcore: findLibrary returned null
at java.lang.Runtime.loadLibrary(Runtime.java:365)
at java.lang.System.loadLibrary(System.java:535)
at ffvideolivewallpaper.frankandrobot.com.NativeCalls.(NativeCalls.java:42)
... 13 more
I think these errors are related to Android NDK. Can anyone guide me on this, keeping in mind that I have no prior knowledge of Android NDK and how it works.
This may happen if we install the app on a device where the previous version was already installed we always get this kind of error:
Just look at this similar problem : https://groups.google.com/d/topic/android-ndk/YmKly4zEMQ0/discussion
I found the reason why I was getting this error, because I did not build the native libraries. I used ndk-build and the errors got resolved.

Have an error of project by corona sdk

I hava a project from my friends,
When I run the project in the Eclipse ,will have an error printed in the LogCat
Exception Ljava/lang/UnsatisfiedLinkError; thrown while initializing Lcom/ansca/corona/JavaToNativeShim;
Exception Ljava/lang/ExceptionInInitializerError; thrown while initializing Lcom/ansca/corona/CoronaEnvironment;
threadid=1: thread exiting with uncaught exception (group=0x41b2f498)
FATAL EXCEPTION: main
java.lang.ExceptionInInitializerError
at com.uangel.corona.CoronaApplication.onCreate(CoronaApplication.java:16)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:999)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4281)
at android.app.ActivityThread.access$1300(ActivityThread.java:136)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1261)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4875)
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:804)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:571)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ExceptionInInitializerError
at com.ansca.corona.CoronaEnvironment.setLuaErrorHandler(CoronaEnvironment.java:373)
at com.ansca.corona.CoronaEnvironment.<clinit>(CoronaEnvironment.java:41)
... 13 more
Caused by: java.lang.UnsatisfiedLinkError: Couldn't load lua: findLibrary returned null
at java.lang.Runtime.loadLibrary(Runtime.java:365)
at java.lang.System.loadLibrary(System.java:535)
at com.ansca.corona.JavaToNativeShim.<clinit>(JavaToNativeShim.java:94)
... 15 more
I can't make it. Please help me.
I recommend seeing if you can build one of the corona sample projects first to see if you can build those.
Also some helpful information you can give us:
What version of corona are you using?

getting stragne unexpected error sometime using ActionBarSherlock

I am using ActionBarShelock and some time get force close with this error cant find how to handle it .
FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.sps/com.sps.ui.activities.HomeActivity}: java.lang.NullPointerException
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
at android.app.ActivityThread.access$600(ActivityThread.java:130)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4745)
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:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at android.support.v4.app._ActionBarSherlockTrojanHorse.onCreatePanelMenu(_ActionBarSherlockTrojanHorse.java:52)
at com.actionbarsherlock.ActionBarSherlock.callbackCreateOptionsMenu(ActionBarSherlock.java:556)
at com.actionbarsherlock.internal.ActionBarSherlockNative.dispatchCreateOptionsMenu(ActionBarSherlockNative.java:60)
at com.actionbarsherlock.app.SherlockFragmentActivity.onCreatePanelMenu(SherlockFragmentActivity.java:154)
at com.android.internal.policy.impl.PhoneWindow.preparePanel(PhoneWindow.java:393)
at com.android.internal.policy.impl.PhoneWindow.invalidatePanelMenu(PhoneWindow.java:747)
at com.android.internal.policy.impl.PhoneWindow.restorePanelState(PhoneWindow.java:1677)
at com.android.internal.policy.impl.PhoneWindow.restoreHierarchyState(PhoneWindow.java:1627)
at android.app.Activity.onRestoreInstanceState(Activity.java:928)
at android.app.Activity.performRestoreInstanceState(Activity.java:900)
at android.app.Instrumentation.callActivityOnRestoreInstanceState(Instrumentation.java:1130)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2037)
... 11 more
In the r7 support library, the version on which the current release (4.1.0) of ActionBarSherlock is based, the FragmentManager class checked if mActive != null before dispatching menu events to the fragments contained in the mAdded list. This code was copied into ActionBarSherlock since it uses its own MenuItem type and does its own dispatching.
In a subsequent release of the support library, it was found that this check was no longer representative of whether or not mAdded had been instantiated with a list or not. Commit 464b6f3c changed the conditional check to mAdded != null.
ActionBarSherlock has not had a release since this fix was made. However, it was updated on the dev branch in commit 69fe6fd to be included in the next release.

RuntimeException: Unable to instantiate application

When I run my application, everytime I am getting the below exception in my logcat:
04-14 09:29:53.965: W/dalvikvm(1020): threadid=1: thread exiting with uncaught exception (group=0x409c01f8)
04-14 09:29:53.985: E/AndroidRuntime(1020): FATAL EXCEPTION: main
04-14 09:29:53.985: E/AndroidRuntime(1020): java.lang.RuntimeException: Unable to instantiate application android.app.Application: java.lang.NullPointerException
04-14 09:29:53.985: E/AndroidRuntime(1020): at android.app.LoadedApk.makeApplication(LoadedApk.java:482)
04-14 09:29:53.985: E/AndroidRuntime(1020): at android.app.ActivityThread.handleBindApplication(ActivityThread.java:3938)
04-14 09:29:53.985: E/AndroidRuntime(1020): at android.app.ActivityThread.access$1300(ActivityThread.java:123)
04-14 09:29:53.985: E/AndroidRuntime(1020): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1185)
04-14 09:29:53.985: E/AndroidRuntime(1020): at android.os.Handler.dispatchMessage(Handler.java:99)
04-14 09:29:53.985: E/AndroidRuntime(1020): at android.os.Looper.loop(Looper.java:137)
04-14 09:29:53.985: E/AndroidRuntime(1020): at android.app.ActivityThread.main(ActivityThread.java:4424)
04-14 09:29:53.985: E/AndroidRuntime(1020): at java.lang.reflect.Method.invokeNative(Native Method)
04-14 09:29:53.985: E/AndroidRuntime(1020): at java.lang.reflect.Method.invoke(Method.java:511)
04-14 09:29:53.985: E/AndroidRuntime(1020): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
04-14 09:29:53.985: E/AndroidRuntime(1020): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
04-14 09:29:53.985: E/AndroidRuntime(1020): at dalvik.system.NativeStart.main(Native Method)
04-14 09:29:53.985: E/AndroidRuntime(1020): Caused by: java.lang.NullPointerException
04-14 09:29:53.985: E/AndroidRuntime(1020): at android.app.LoadedApk.initializeJavaContextClassLoader(LoadedApk.java:362)
04-14 09:29:53.985: E/AndroidRuntime(1020): at android.app.LoadedApk.getClassLoader(LoadedApk.java:305)
04-14 09:29:53.985: E/AndroidRuntime(1020): at android.app.LoadedApk.makeApplication(LoadedApk.java:474)
04-14 09:29:53.985: E/AndroidRuntime(1020): ... 11 more
Note: When I uninstall the app from the emulator and run it, then I don't get this exception but when I re-run the installed application in emulator, I am getting this. Please help.
This is a verbose error message raised by underlying framework when dalvik re-install .apk file and trying to reuse or recycle the previous opened activity/view from the same package (if you haven't closed the previous installed app yet). It has nothing to do with your app, moreover, it is very unlikely that your app will get freezed or crashed cause by this verbose error message on end user's device.
It seems that this dalvik verbose error log only happend on Android 4.0 system, I've tested it myself on Android 3.2 and 2.3.3 running environment, where you cannot replicate to get this message shown on neither of them. A similar question has been discussed before at here and someone has filled a bug report in Android Issues Tracker.
I don't think you should concern too much about this verbose error log at the moment, if you look more logs before and after this red error in Logcat, you can see the full story and find that the previous opened activity/view (which are marked as died state) get killed and the newly re-installed one get poped ultimately.
I realise it's a very old question, but this may be useful anyway. I've found that when I observe this error in my own development, it's due to the previously running instance of my app not closing down neatly, for example by shutting down background threads prior to exit.
I have been getting same error when I tried connect to the internet with JSOUP inside my application class.
It was tricky, because application run on emulator but not on actual device.
It turned out, that I just used JSOUP library wrong. Loading page in new thread solved my problem.
Hope I helped someone.
Hope this helps someone.
Go to the running apps on your emulator by clicking this:
Close the app you are trying to install and then run it again. NO need to uninstall/reinstall app or clean project.
For me it helped to clean the Project.
In Eclipse:
- Project --> Clean
Please control that Project --> Build Automatically is CHECKED
If the gen-Folder is empty after that, there's a mistake in the res-folder. Often, mistakes in the res-folder aren't shown by the red cross!
Good luck and greetings
Simple Solution:
Just Restart your emulator or mobile device. And the problem is gone!
Reason for this issue was due to a previous app activity was wrongly halted.
In my case this error appear after I've imported Android Maven project into new workspace, and SRC folder was not automatically added to build path.
Right click on the project/Build path/Configure build path/Source - check if there missing sources.
I got the same problem. Cleaning the project worked for me.
Select project go to Project --> Clean
In my case logcat show me it coudn't find the initial activity, but the Dex Path was different, it was ".../data/app/myapp-1" instead of ".../data/app/myapp".
I soved this making click on the elcipse project name "myapp" in the Package explorer window. Then right click on it, ->refactor->rename...
I set the project name to myapp-1, and then, ->refactor->rename... and back again to "myapp".
Then it worked... some kinf of bug in eclipse?
I got the same problem. Uninstalling my app then reinstalling it solved the issue.
I experienced this when I imported my project which was built from a different machine.
Just Invalidate caches and restart
File>Invalidate Caches/Restart>Invalidate and restart
I changed the applicationId to something different on (Module:app) build.gradle file, run the app again on my device. Then, I undo the change and run the app again and everything works. It works on Android Studio 2.3.1 and 4 different devices I have here, from 5.0 to 7.0.
I meet this question.
When use gradle clean,gradle installDebug it work ok!
AndroidRuntime D Shutting down VM
E FATAL EXCEPTION: main
E Process: tv.panda.live.broadcast, PID: 4685
E java.lang.RuntimeException: Unable to instantiate application tv.panda.live.broadcast.PandaApplication: java.lang.ClassNotFoundException: Didn't find class "tv.panda.live.broadcast.PandaApplication" o
n path: DexPathList[[zip file "/data/app/tv.panda.live.broadcast-1/base.apk"],nativeLibraryDirectories=[/data/app/tv.panda.live.broadcast-1/lib/arm, /vendor/lib, /system/lib]]
E at android.app.LoadedApk.makeApplication(LoadedApk.java:572)
E at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4883)
E at android.app.ActivityThread.access$1500(ActivityThread.java:178)
E at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1573)
E at android.os.Handler.dispatchMessage(Handler.java:111)
E at android.os.Looper.loop(Looper.java:194)
E at android.app.ActivityThread.main(ActivityThread.java:5691)
E at java.lang.reflect.Method.invoke(Native Method)
E at java.lang.reflect.Method.invoke(Method.java:372)
E at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:959)
E at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:754)
E Caused by: java.lang.ClassNotFoundException: Didn't find class "tv.panda.live.broadcast.PandaApplication" on path: DexPathList[[zip file "/data/app/tv.panda.live.broadcast-1/base.apk"],nativeLibraryDi
rectories=[/data/app/tv.panda.live.broadcast-1/lib/arm, /vendor/lib, /system/lib]]
E at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
E at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
E at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
E at android.app.Instrumentation.newApplication(Instrumentation.java:988)
E at android.app.LoadedApk.makeApplication(LoadedApk.java:567)
E ... 10 more
E Suppressed: java.lang.ClassNotFoundException: tv.panda.live.broadcast.PandaApplication
E at java.lang.Class.classForName(Native Method)
E at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
E at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
E at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
E ... 13 more
E Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available
I received this error when using ksp instead of kapt when adding hilt dependency
Change
ksp "com.google.dagger:hilt-compiler:$hilt_verson"
to
kapt "com.google.dagger:hilt-compiler:$hilt_verson"
Hope that helps

Error When creating an Application class in Android

I followed the advice given on the internet regarding working with Application classes in android.
I also added a field "android:name=.Session" to my Application object in the manifest.
The application is called "Session".
What do you think is the error? This is happening even before the my App starts.
This is the error stack:
**java.lang.RuntimeException: Unable to instantiate application com.appfire.Session: java.lang.InstantiationException: com.appfire.Session**
at android.app.ActivityThread$PackageInfo.makeApplication(ActivityThread.java:523)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:3996)
at android.app.ActivityThread.access$2900(ActivityThread.java:119)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1901)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:4363)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
at dalvik.system.NativeStart.main(Native Method)
**Caused by: java.lang.InstantiationException: com.appfire.Session**
at java.lang.Class.newInstanceImpl(Native Method)
at java.lang.Class.newInstance(Class.java:1479)
at android.app.Instrumentation.newApplication(Instrumentation.java:957)
at android.app.Instrumentation.newApplication(Instrumentation.java:942)
at android.app.ActivityThread$PackageInfo.makeApplication(ActivityThread.java:518)
Make sure your Session class is public, is not static, and does not have a default constructor.
public class Session extends Application {}
In the Manifest application tag, make sure you include the fully-qualified class name of your custom Application object:
<application
android:name="com.mycompany.myapp.Session"
.... />
The Android docs do say the class name must be fully qualified:
http://developer.android.com/guide/topics/manifest/application-element.html#nm
(This is not the case for Activity class names that are included in the activity tag of the Manifest. Those can be relative, preceded with a '.').
My solution was to delete the whole project from Eclipse and load it again from SVN. Now it works

Categories

Resources