JTwitter VerifyError in Android pre-2.0 - android

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.

Related

java.lang.NoClassDefFoundError: com.google.android.gms.internal.zzmp

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.

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.

Cannot deploy my apps since updating SDK tools today [duplicate]

This question already has answers here:
Libraries do not get added to APK anymore after upgrade to ADT 22
(7 answers)
Closed 9 years ago.
This morning I updated various SDK components from Eclipse. I think it was
- Android SDK or Platform tools
- Google APIs 17 update
- Android Support Library
- Google Play Services
Now, my apps won't deploy. They build ok (eventually, after an hour of reconfiguring and rebuilding) but now when I deploy to the device, I get the following:
VFY: unable to find class referenced in signature (Landroid/support/v4/app/Fragment;)
VFY: unable to find class referenced in signature (Landroid/support/v4/app/Fragment;)
VFY: unable to find class referenced in signature (Landroid/support/v4/app/Fragment;)
Unable to resolve superclass of Lcom/com/myapp/MainActivity; (81)
Link of class 'Lcom/com/myapp/MainActivity;' failed
VFY: replacing opcode 0x71 at 0x0006
VFY: unable to find class referenced in signature (Landroid/support/v4/app/Fragment;)
Unable to resolve superclass of Lcom/com/myapp/MainActivity; (81)
Link of class 'Lcom/com/myapp/MainActivity;' failed
Shutting down VM
threadid=1: thread exiting with uncaught exception (group=0x40015560)
FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.myapp/com.myapp.MainActivity}: java.lang.ClassNotFoundException: com.myapp.MainActivity in loader dalvik.system.PathClassLoader[/data/app/com.myapp.apk]
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1680)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1784)
at android.app.ActivityThread.access$1500(ActivityThread.java:123)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:939)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3835)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:864)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:622)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: com.myapp.MainActivity in loader dalvik.system.PathClassLoader[/data/app/myapp.apk]
at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1672)
... 11 more
Bear in mind that this project, and others, have been happily running for months, so this isn't just some daft error like the activity missing from the manifest file.
I'm really wishing I hadn't bothered with the update now... any ideas welcome!
I faced this issue couple of days before.
Right click your project, Go to properties->Java Build path->Order and Export
Check Android Private Library->Click Ok
Clean the project and run it.it will work.
sdk\extras\android\support\v4 inside there is a jar file android-support-v4.jar add this to the external jars

No JNI_OnLoad found skipping init > Application shutdown

Folks,
I am working on an android application where I need a third party .so library. I built
this third party library (with ndk-build) as per their instructions and was then looking
to include this .so in to my Android project.
Therefore I followed the steps described in docs/PREBUILTS.html and successfully build the
new .so in the jni/prebuilt directory. Now I tried leveraging the .so facilities by using it in a simple test android app. So what i do is :
static {
Log.i("load so > ","load so");
System.loadLibrary("xyz");
}
/* The native functions */
private static native int openFile(String filename);
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
try{
String path = getPathForDownloadDirectoryFile();
Log.i("file path> ", path);
int num= openFile(path);
}catch(Exception e){
Log.e(">", "could not open the file");
}
}
Now when I run my app I get a debug message saying :
No JNI_OnLoad found in /data/data/com.example.myfirstapp/lib/xyz.so 0x411e6738, skipping init
and then the application shuts down.
For More Info, Here is the error log :
No JNI_OnLoad found in /data/data/com.example.mysecondapp/lib/xyz.so 0x411e67a0, skipping init
W/dalvikvm( 570): No implementation found for native Lcom/example/mysecondapp/MainActivity;.openFile:(Ljava/lang/String;)I
D/AndroidRuntime( 570): Shutting down VM
W/dalvikvm( 570): threadid=1: thread exiting with uncaught exception (group=0x40a13300)
E/AndroidRuntime( 570): FATAL EXCEPTION: main
E/AndroidRuntime( 570): java.lang.UnsatisfiedLinkError: Native method not found: com.example.mysecondapp.MainActivity.openFile:(Ljava/lang/String;)I
E/AndroidRuntime( 570): at com.example.mysecondapp.MainActivity.openFile(Native Method)
E/AndroidRuntime( 570): at com.example.mysecondapp.MainActivity.onCreate(MainActivity.java:31)
E/AndroidRuntime( 570): at android.app.Activity.performCreate(Activity.java:5008)
E/AndroidRuntime( 570): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
E/AndroidRuntime( 570): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
E/AndroidRuntime( 570): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
E/AndroidRuntime( 570): at android.app.ActivityThread.access$600(ActivityThread.java:130)
E/AndroidRuntime( 570): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
E/AndroidRuntime( 570): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime( 570): at android.os.Looper.loop(Looper.java:137)
E/AndroidRuntime( 570): at android.app.ActivityThread.main(ActivityThread.java:4745)
E/AndroidRuntime( 570): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 570): at java.lang.reflect.Method.invoke(Method.java:511)
E/AndroidRuntime( 570): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
E/AndroidRuntime( 570): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
E/AndroidRuntime( 570): at dalvik.system.NativeStart.main(Native Method)
W/ActivityManager( 146): Force finishing activity com.example.mysecondapp/.MainActivity
As I could see that native implementation for the openFile() method was not found but the same xyz.so lib worked pretty neat with the original sample app from the third party. I am pretty much a starter with Android-ndk world.
Java-Android-NDK Ninjas ..any guess on what I might be missing ?
I'll highly appreciate any help here :)
As guycole said "No JNI_OnLoad" is just a warning , your problem lies elsewhere .
As you mentioned you successfully compiled your "so" file , the problem may lie in your function signatures inside your c/C ++ code it should be something like this
JNIEXPORT jint JNICALL Java_com_your_package_class_method(JNIEnv *d, jobject e, jstring f)
{
//some action
}
The function signatures comes from the header file which is generated using javah tool.You need to generate header file and use the function signature with your package name. For different package and class names the header file and corresponding function signature will change .
worked pretty neat with the original sample app from the third party
This might be the reason its running on the sample app and not on your app.
refer: https://thenewcircle.com/s/post/49/using_ndk_to_call_c_code_from_android_apps
The "No JNI_OnLoad" message is just a warning. JNI_OnLoad is an optional initialization hook.
I guess your problem is inside the openFile() method. Try commenting out the call from Java and see how far you get.
I have a blog post about JNI and some sample code at http://guycole.blogspot.com/2012/03/yet-another-android-ndk-blog-posting.html - perhaps you will find it useful.
Good luck.
It also comes with this log
??-?? ??:??:??.???: INFO/(): java.lang.UnsatisfiedLinkError: Couldn't load *: findLibrary returned null
right??
I think it's the problem of android.mk files.
1:try to swith to armabi v7.
2:load funciton will call open(). check permission of the so.
As mentioned in the previous answers, No JNI_OnLoad is only a warning.
I had got similar problem, I figured the problem is because of file operations.
My app was not having external storage write permission.After adding the below code in
manifest it was working fine

Dalvik mess with library code and project cannot runs anymore

After updating ADT and Android SDK on my machine, all my projects get errors.
Now I have this:
PS: This error happens when running the project that have a jar as dependency (it was compiled with proguard and we dont have the original sourcecode to compile it again).
W/dalvikvm(3497): VFY: unable to resolve static field 994 (storeicon) in Lcom/ww/dgs/R$drawable;
D/dalvikvm(3497): VFY: replacing opcode 0x60 at 0x0042
W/dalvikvm(3497): VFY: unable to resolve static field 987 (libraryicon) in Lcom/ww/dgs/R$drawable;
D/dalvikvm(3497): VFY: replacing opcode 0x60 at 0x0060
W/dalvikvm(3497): VFY: unable to resolve static field 1069 (mainframe) in Lcom/ww/dgs/R$layout;
D/dalvikvm(3497): VFY: replacing opcode 0x60 at 0x00b1
I/dalvikvm(3497): DexOpt: unable to optimize static field ref 0x0467 at 0x16 in Lcom/ww/sharedlibrary/e;.a
D/AndroidRuntime(3497): Shutting down VM
W/dalvikvm(3497): threadid=1: thread exiting with uncaught exception (group=0x400f8760)
E/AndroidRuntime(3497): FATAL EXCEPTION: main
E/AndroidRuntime(3497): java.lang.NoClassDefFoundError: com.ww.dgs.R$layout
E/AndroidRuntime(3497): at com.ww.mainframe.MainFrame.onCreate(Unknown Source)
E/AndroidRuntime(3497): at com.ww.iba.DigiMag.onCreate(DigiMag.java:27)
E/AndroidRuntime(3497): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1048)
E/AndroidRuntime(3497): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1715)
E/AndroidRuntime(3497): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1767)
E/AndroidRuntime(3497): at android.app.ActivityThread.access$1500(ActivityThread.java:122)
E/AndroidRuntime(3497): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1005)
E/AndroidRuntime(3497): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(3497): at android.os.Looper.loop(Looper.java:132)
E/AndroidRuntime(3497): at android.app.ActivityThread.main(ActivityThread.java:4028)
E/AndroidRuntime(3497): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(3497): at java.lang.reflect.Method.invoke(Method.java:491)
E/AndroidRuntime(3497): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:844)
E/AndroidRuntime(3497): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602)
E/AndroidRuntime(3497): at dalvik.system.NativeStart.main(Native Method)
I/dalvikvm(3497): threadid=4: reacting to signal 3
I/dalvikvm(3497): Wrote stack traces to '/data/anr/traces.txt'
The code from com.ww is inside a jar that I used on the other builds.
I am getting this too now and am able to get around it by removing all external jars from the project. You can add them back in after it's been cleaned. I'm assuming you have access to the original project source code...
Rightclick on project, go to Java Build Path, and remove all external jars other than your Android libs. Then clean.
Got this error after updating to the Android Platform Tools preview 15 rc5 and Android Tools 21 rc5, plus running the "check for updates..." in eclipse.
LogCat error
java.lang.NoClassDefFoundError: com.someapplicationlibrary.lib.R$layout
Eclipse compiler error:
Errors occurred during the build.
Errors running builder 'Android Pre Compiler' on project 'myApplication'.
String index out of range: -51
Errors running builder 'Android Pre Compiler' on project 'someapplicationlibrary'.
String index out of range: -54
Tried to revert to the stabel Android Tools... but ending up with even more errors.
My solution was to load the workspace in a eclipse version that was not updated with the "check for updates..." in the eclipse Help menu.
Then it compiled correct, and the application worked again, hope this helps:)

Categories

Resources