I am trying to run a java app via adb using dalvikvm -cp. It works in case of simple apps, but as soon as I want to use android native classes, e.g. do this (and include the android.jar in the classpath of javac to handle dependencies):
import android.view.KeyCharacterMap;
...
KeyCharacterMap kcm = KeyCharacterMap.load(KeyCharacterMap.VIRTUAL_KEYBOARD);
and run the app from adb using dalvikvm -cp I get this error:
java.lang.UnsatisfiedLinkError: Native method not found: com.android.internal.os.BinderInternal.getContextObject:()Landroid/os/IBinder;
at com.android.internal.os.BinderInternal.getContextObject(Native Method)
at android.os.ServiceManager.getIServiceManager(ServiceManager.java:39)
at android.os.ServiceManager.getService(ServiceManager.java:55)
at android.hardware.input.InputManager.getInstance(InputManager.java:187)
at android.view.KeyCharacterMap.load(KeyCharacterMap.java:331)
And in logcat:
java.lang.UnsatisfiedLinkError: Native method not found: com.android.internal.os.BinderInternal.getContextObject:()Landroid/os/IBinder;
at com.android.internal.os.BinderInternal.getContextObject(Native Method)
at android.os.ServiceManager.getIServiceManager(ServiceManager.java:39)
at android.os.ServiceManager.getService(ServiceManager.java:55)
at android.hardware.input.InputManager.getInstance(InputManager.java:187)
at android.view.KeyCharacterMap.load(KeyCharacterMap.java:331)
W/dalvikvm(22137): No implementation found for native Lcom/android/internal/os/BinderInternal;.getContextObject:()Landroid/os/IBinder;
W/dalvikvm(22137): threadid=1: thread exiting with uncaught exception (group=0x4092f2a0)
D/dalvikvm(22137): GC_CONCURRENT freed 19K, 89% free 118K/1024K, paused 0ms+0ms, total 1ms
W/dalvikvm(22137): No implementation found for native Lcom/android/internal/os/BinderInternal;.handleGc:()V
E/System (22137): Uncaught exception thrown by finalizer
E/System (22137): java.lang.UnsatisfiedLinkError: Native method not found: com.android.internal.os.BinderInternal.handleGc:()V
E/System (22137): at com.android.internal.os.BinderInternal.handleGc(Native Method)
E/System (22137): at com.android.internal.os.BinderInternal$GcWatcher.finalize(BinderInternal.java:45)
E/System (22137): at java.lang.Daemons$FinalizerDaemon.doFinalize(Daemons.java:186)
E/System (22137): at java.lang.Daemons$FinalizerDaemon.run(Daemons.java:169)
E/System (22137): at java.lang.Thread.run(Thread.java:856)
I looked at sources of apps such as am or input and they successfully use binding, so what should I do to use it in my adb java app?
Related
Receiving this error on Android 4.4 device when starting my app. App immediately crashes. However I don't have this error on Android 5.1 device. Any clue?
10-15 22:35:06.306 14072-14072/com D/dalvikvm﹕ VFY: replacing opcode 0x71 at 0x0000
10-15 22:35:06.306 14072-14072/com D/AndroidRuntime﹕ Shutting down VM
10-15 22:35:06.306 14072-14072/com W/dalvikvm﹕ threadid=1: thread exiting with uncaught exception (group=0x4304b160)
10-15 22:35:06.306 14072-14072/com E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process:com., PID: 14072
java.lang.NoClassDefFoundError: com.google.android.gms.internal.zzmp
at com.google.android.gms.measurement.internal.zzz.zzj(Unknown Source)
at com.google.android.gms.measurement.internal.zzv.(Unknown Source)
at com.google.android.gms.measurement.internal.zzz.zzAq(Unknown Source)
at com.google.android.gms.measurement.internal.zzv.zzaL(Unknown Source)
at com.google.android.gms.measurement.AppMeasurementContentProvider.onCreate(Unknown Source)
at android.content.ContentProvider.attachInfo(ContentProvider.java:1591)
at android.content.ContentProvider.attachInfo(ContentProvider.java:1562)
at android.app.ActivityThread.installProvider(ActivityThread.java:4830)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:4425)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4365)
at android.app.ActivityThread.access$1500(ActivityThread.java:138)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1296)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:149)
at android.app.ActivityThread.main(ActivityThread.java:5061)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:787)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:603)
at dalvik.system.NativeStart.main(Native Method)
needed to add this in class that extends Application:
#Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
EDIT: I noticed this answer is becoming more popular so please note my comment on the question:
"ATTENTION To anybody reading this though! The real problem was that I was using the ENTIRE google play services framework which was forcing me into multi dex. Avoid multi dex if you can because it slows down builds. Only bring in what you need from google play services. So instead of putting "compile 'com.google.android.gms:play-services:8.1.0'", put "compile 'com.google.android.gms:play-services-location:8.1.0'" for example."
For those who have already activated MultiDex and still get this exception, it's just a stupid Android Studio / Gradle issue.
Try cleaning project, toggling Instant Run in settings, and rebuilding the project.
I had the error and i resolved it by updating the gms play-service to the latest version.
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.
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?
I am compiling some Java code, putting it into a .JAR and then running dx --dex on it. I am pushing my file to an Android device through adb but I am having problem linking my shared library at runtime.
In HostConnection.java, I have the following code to load my library:
static {
System.loadLibrary("hostConnection");
}
I am loading the application this way:
adb shell
su
export CLASSPATH=/data/local/device.jar
export LD_LIBRARY_PATH=/data/local/libhostConnection.so
exec app_process /system/bin com.device.client.Main
I am unfortunately getting the following error:
D/dalvikvm( 1616): DexOpt: load 482ms, verify 84ms, opt 10ms
D/dalvikvm( 1608): DexOpt: --- END 'device.jar' (success) ---
D/dalvikvm( 1608): DEX prep '/data/local/device.jar': unzip in 1715ms, rewrite 1287ms
W/dalvikvm( 1608): Exception Ljava/lang/UnsatisfiedLinkError; thrown during Lcom/device/client/HostConnection;.<clinit>
D/AndroidRuntime( 1608): Shutting down VM
W/dalvikvm( 1608): threadid=1: thread exiting with uncaught exception (group=0x4001d830)
I/Process ( 1608): Sending signal. PID: 1608 SIG: 9
E/AndroidRuntime( 1608): *** FATAL EXCEPTION IN SYSTEM PROCESS: main
E/AndroidRuntime( 1608): java.lang.ExceptionInInitializerError
E/AndroidRuntime( 1608): at com.device.client.Main.<init>(Main.java:27)
E/AndroidRuntime( 1608): at com.device.client.Main.main(Main.java:21)
E/AndroidRuntime( 1608): at com.android.internal.os.RuntimeInit.finishInit(Native Method)
E/AndroidRuntime( 1608): at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:235)
E/AndroidRuntime( 1608): at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime( 1608): Caused by: java.lang.UnsatisfiedLinkError: Library hostConnection not found
E/AndroidRuntime( 1608): at java.lang.Runtime.loadLibrary(Runtime.java:461)
E/AndroidRuntime( 1608): at java.lang.System.loadLibrary(System.java:557)
E/AndroidRuntime( 1620): at com.device.client.HostConnection.<clinit>(HostConnection.java:25)
The line 25 in HostConnection.java is indeed System.loadLibrary("hostConnection").
My library is called libhostConnection.so and my .jar is called device.jar. They are both stored in /data/local. I have tried moving the shared library to /system/lib but the shell does not let me copy the file (read-only).
I am not sure what I am doing wrong, but I believe it cannot find the shared library for linking when running the application. I am not sure if I am using the wrong variable in export, or if I am supposed to do something else.
Could anyone please help me? It would be much appreciated.
Thank you very much!
And why don't you just try putting your library into lib/armeabi(-v7a) directory in your eclipse project? I believe it's the recomended way of linking shared library.
I figured it out. The variable is correct, but the path should be just the folder, not the .so file for some reason:
export LD_LIBRARY_PATH=/data/local
This actually works.
Thank you.
I'm attempting to integrate JTwitter into an Android application, and I have been completely successful up until the point where I decided to regression test on older Android versions. In Android 2.x my code works great, but in Android 1.5/1.6 Dalvik throws a VerifyError on the following line:
OAuthSignpostClient oauthClient
= new OAuthSignpostClient(KEY_TWITTER, SECRET_TWITTER, "oob");
and provides this logcat output and stack trace:
Could not find method javax.swing.JOptionPane.showInputDialog, referenced from method winterwell.jtwitter.OAuthSignpostClient.askUser
VFY: unable to resolve static method 1703: Ljavax/swing/JOptionPane;.showInputDialog (Ljava/lang/Object;)Ljava/lang/String;
VFY: rejecting opcode 0x71 at 0x0000
VFY: rejected Lwinterwell/jtwitter/OAuthSignpostClient;.askUser (Ljava/lang/String;)Ljava/lang/String;
Verifier rejected class Lwinterwell/jtwitter/OAuthSignpostClient;
Shutting down VM
threadid=3: thread exiting with uncaught exception (group=0x4001aa28)
Uncaught handler: thread main exiting due to uncaught exception
java.lang.VerifyError: winterwell.jtwitter.OAuthSignpostClient
at com.wirelessdesigns.android.AuthActivity.onCreate(AuthActivity.java:37)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1123)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2364)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2417)
at android.app.ActivityThread.access$2100(ActivityThread.java:116)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1794)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:4203)
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:791)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:549)
at dalvik.system.NativeStart.main(Native Method)
I'm trying to figure out what may have changed in the underlying implementation between the Android versions that would affect this and what the workaround might be? A similar question was answered a while back, but the answer was in the form of a now-dead link to a forum post.
Any thoughts?
Before Android 2.0, the verifier would immediately reject classes when something wasn't right. In 2.0 and later, reporting of certain failures is deferred until the code is actually executed. Attempting to call a nonexistent or inaccessible method is one such case.
This is an example of why the verifier behavior was changed. Even though you're not calling the absent function, the whole class that's trying to call it is getting rejected.
Some workarounds can be found here, but it sounds like you've found one on your own.