I came back to work today and I started debugging my app using the emulator (KitKat), and my app runs ok. I had made some changes since last Friday, but not much.
Then I moved to the device (Gingerbread) and notices the app, that was working last week, had started to crash right on main activity's setContentView(). Here are the warning/error messages:
W/ActivityThread﹕ Application com.example.myapp is waiting for the debugger on port 8100...
W/dalvikvm﹕ VFY: unable to resolve static method 790: Landroid/net/TrafficStats;.setThreadStatsTag (I)V
W/dalvikvm﹕ VFY: unable to resolve instance field 50
W/dalvikvm﹕ VFY: unable to resolve virtual method 95: Landroid/app/Activity;.getFragmentManager ()Landroid/app/FragmentManager;
W/dalvikvm﹕ Unable to resolve superclass of Lmaps/aj/r; (671)
W/dalvikvm﹕ Link of class 'Lmaps/aj/r;' failed
W/dalvikvm﹕ Unable to resolve superclass of Lmaps/ay/an; (6382)
W/dalvikvm﹕ Link of class 'Lmaps/ay/an;' failed
W/dalvikvm﹕ Unable to resolve superclass of Lmaps/c/i; (6613)
W/dalvikvm﹕ Link of class 'Lmaps/c/i;' failed
E/dalvikvm﹕ Could not find class 'maps.c.i', referenced from method maps.e.al.a
W/dalvikvm﹕ VFY: unable to resolve new-instance 6818 (Lmaps/c/i;) in Lmaps/e/al;
All these messages appear after the setContentView method.
I noticed that it mentions getFragmentManager, however that's not part of my app. Since it has API 9 compatibility, I'm using the AppCompat v7, getSupportFragmentManager and including the Supporteverywhere it is needed.
I've undone the changes I did earlier today, but it still doesn't work.
Is it possible that the appcompat lib was updated recently? I'm using Gradle to get most of them:
dependencies {
compile 'com.android.support:appcompat-v7:+'
compile 'com.google.android.gms:play-services:+#aar'
compile 'com.google.code.gson:gson:+#jar'
compile 'com.google.zxing:android-integration:+#jar'
compile 'com.googlecode.libphonenumber:libphonenumber:+#jar'
compile 'com.intellij:annotations:12.0'
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':Facebook')
}
I don't know how to debug these VFY errors. What can I do to try to solve them?
I don't know how to debug these VFY errors
They are not errors. They are warnings. The "W" in the beginning of each line is short for "warning".
Those warnings are merely noting classes, methods, and other symbols that Dalvik saw when loading classes from your APK that it could not resolve. So long as you do not actually execute any code that contains any of that missing stuff, everything will be fine. Moreover, they are largely unavoidable, as they are a natural side-effect of application and library code using newer capabilities on newer devices where those capabilities are supported.
Related
now i have a project, which is compiled with API 14. By "is compiled", i mean the project.properties file has a line "target=android-14". But, i defined the android:minSDK=8 in the AndroidManifest.xml.
In this project, i used the high api features, like android.animation.ValueAnimator, android.app.ActionBar. The project, of course, will run perfectly in high api device.
Since the minSDK is 8, so we can install the apk in 2.x devices, but what will happen then? the ValueAnimator and ActionBar will be erased? or we actually cannot install the apk in 2.x devices?
if your app is loaded into memory the logcat will get warnings if classes/methods cannot be resolved. Example:
I/dalvikvm﹕ Could not find method java.lang.String.isEmpty, referenced from method eu.lp0.slf4j.android.LoggerFactory.getConfig
W/dalvikvm﹕ VFY: unable to resolve virtual method 524: Ljava/lang/String;.isEmpty ()Z
D/dalvikvm﹕ VFY: replacing opcode 0x6e at 0x0010
D/dalvikvm﹕ VFY: dead code 0x0013-0044 in Leu/lp0/slf4j/android/LoggerFactory;.getConfig (Ljava/lang/String;)Leu/lp0/slf4j/android/LoggerConfig;
If your app is trying to execute code that is not supported by your device you get an exception NoSuchMethodError or ClassNotFoundException
W/dalvikvm﹕ Exception Ljava/lang/NoSuchMethodError; thrown during Lde/k3b/android/cellinfo/demo/CellInfoDemoActivity;.
Here is a complete example logcat: https://github.com/lp0/slf4j-android/issues/2
To avoid calling methods/classes that your device does not support
you can use code like this
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
// call method/class that is only available in HONEYCOMB and later
}
For more details see https://developer.android.com/guide/practices/compatibility.html
If you are not using the corresponding classes from the support library, but the native ones that are only included in later versions of Android, your app will crash with a ClassNotFoundException or a NoSuchMethodError.
A workaround would be to either switch to the support libraries (if there are any depending on what features you use), or disable certain functionality of the app depending of the API version the app runs on.
I'm not sure where this error is generating from. My application works fine and I've not come across any crashing; however I receive the below in my LogCat.
My application uses an ActionBar and ListView. Anyone come across this before?
EDIT: Seems to be only happening when running on Android 2.x
Could not find method android.widget.LinearLayout$LayoutParams., referenced from method android.support.v7.internal.view.menu.ActionMenuView$LayoutParams.
VFY: unable to resolve direct method 8309: Landroid/widget/LinearLayout$LayoutParams;. (Landroid/widget/LinearLayout$LayoutParams;)V
VFY: replacing opcode 0x70 at 0x0000
VFY: dead code 0x0003-0007 in Landroid/support/v7/internal/view/menu/ActionMenuView$LayoutParams;. (Landroid/support/v7/internal/view/menu/ActionMenuView$LayoutParams;)V
This sounds like those classes are missing from your apk. Make sure to include the necessary Jars into your Apk (sounds like the support library).
Also in relation to this error, this is due to the Class Loader trying to resolve the reference in your code to actual operation codes (opcode) that the OS can recognize.
I had somewhat a similar issue. But later I found that I was trying to call a menu which does not exist.
Eclipse is seemingly having intense difficulties adding** 8 libraries to my project. Is there an unspoken maximum of 7 libraries per project that I haven't heard of?
I am getting issues saying that the compiler "Could not find class *"
An example is this:
favorite
I have a project that runs perfectly fine on newer devices and API levels, however, I'm getting some issues on emulators. When I load up the application on an emulator, I get this issue:
02-22 18:36:11.584: W/dalvikvm(652): VFY: unable to resolve exception class 872 (Lcom/google/zxing/WriterException;)
02-22 18:36:11.584: W/dalvikvm(652): VFY: unable to find exception handler at addr 0x7da
02-22 18:36:11.584: W/dalvikvm(652): VFY: rejected Lcom/example/myapp/Card;.getFrontView (Landroid/content/Context;)Landroid/widget/LinearLayout;
02-22 18:36:11.584: W/dalvikvm(652): VFY: rejecting opcode 0x0d at 0x07da
02-22 18:36:11.584: W/dalvikvm(652): VFY: rejected Lcom/example/myapp/Card;.getFrontView (Landroid/content/Context;)Landroid/widget/LinearLayout;
02-22 18:36:11.584: W/dalvikvm(652): Verifier rejected class Lcom/example/myapp/Card;
At first I thought it may have been either my library or how I was adding** it, but I've recently cleared*** all of my libraries and readded them and I'm getting the same issues on a different library.
02-25 21:03:45.379: E/dalvikvm(12018): Could not find class 'org.apache.commons.validator.routines.UrlValidator', referenced from method com.example.myapp.Card
02-25 21:03:45.379: W/dalvikvm(12018): VFY: unable to resolve new-instance 1054 (Lorg/apache/commons/validator/routines/UrlValidator;) in Lcom/example/myapp/Card;
These errors mean that the project doesn't have proper access to my library's classes, right? But why is the error inconsistent for which library it is? I've tried removing*** and readding the libraries the exact same way that the other libraries were added, but there's no luck on library #8.
What do I do?
** Adding: I've tried adding the libraries to a User Library (includes all of the existing documents that I have) and just simply copying the .jar to the libs folder.
* Removing: To get rid of the library, if it is inside a User Library, I will edit my User Library containing the .jar I'm looking to remove and use the "remove" option. Otherwise, I will simply right click and "delete" the library from the libs directory.
As for a "User Library"
I try to implement a Backup Agent in my Android app, and I've got a weird issue every times it restore (at first launch) :
Unable to resolve superclass of Lcom/actionbarsherlock/app/SherlockMapActivity; (916)
Link of class 'Lcom/actionbarsherlock/app/SherlockMapActivity;' failed
Unable to resolve superclass of Lnet/myapp/activity/impl/MapActivity; (674)
Link of class 'Lnet/myapp/activity/impl/MapActivity;' failed
Could not find class 'net.myapp.activity.impl.MapActivity', referenced from method net.myapp.helper.SlidingMenuHelper.<clinit>
VFY: unable to resolve const-class 1520 (Lnet/myapp/activity/impl/MapActivity;) in Lnet/myapp/helper/SlidingMenuHelper;
VFY: replacing opcode 0x1c at 0x0081
Exception Ljava/lang/NoClassDefFoundError; thrown while initializing Lnet/myapp/helper/SlidingMenuHelper;
Complete log here : https://gist.github.com/romainguefveneu/1acc78cabbed65fba4b7
The restore process works just fine, when I open a second time the app, my data are correctly restored.
It seems to be an issue with the loading of SherlockMapActivity, I use all those libs in my project :
actionbarsherlock-plugin-maps-4.2.0.jar
bugsense-3.0.1.jar
commons-io-2.0.1.jar
gson-2.2.2.jar
joda-time-2.1.jar
ocpsoft-pretty-time-1.0.7.jar
Does someone has an idea ?
Everything was working fine in my app. Then, I did a small refactoring and a key component stopped working. When I looked at the LogCat output, this is what I found:
WARN/dalvikvm(488): VFY: unable to resolve virtual method 10830: Ljava/lang/String;.getBytes (Ljava/nio/charset/Charset;)[B
DEBUG/dalvikvm(488): VFY: replacing opcode 0x6e at 0x000e
DEBUG/dalvikvm(488): VFY: dead code 0x0011-0015 in Lcom/appiancorp/tempo/android/service/CommentXmlHttpMessageConverter;.writeInternal (Lcom/appiancorp/tempo/android/model/EntryComment;Lorg/springframework/http/HttpOutputMessage;)V
This was ... surprising, to say the least. I looked at the documentation and the method is there, what gives?
The getBytes(Charset) exists in API9 and later. Make sure you are building against this version of the SDK or use the getBytes(String charsetName) which exists in API1.
You can also you the "filter by API level" checkbox in online SDK documentation to gray out methods not available in the version you are building against.