Like I said ... Even if you never actually execute the code that's causing the problem, the verifier will reject it, since it's doing a static check and can't tell what code is or isn't executed.
If you want to include some code in your application that is optionally loaded (because it's not compatible with all versions of the platform) you need to use the "factory" approach where you write a factory method that explicitly loads the class with ClassLoader calls and then does a newInstance on the loaded class (and returns the result of the newInstance). Externally you only reference the class by interface or superclass, so that the problematic class isn't loaded while verifying the referencing code. On Oct 19, 8:24 pm, Alex Xin <[email protected]> wrote: > Thank you! Now I know where I can get those messages. > > 10-20 09:18:14.973: WARN/dalvikvm(210): VFY: unable to resolve static field > 0 (CONTENT_URI) in Landroid/provider/ContactsContract$CommonDataKinds$Phone; > 10-20 09:18:14.982: WARN/dalvikvm(210): VFY: rejecting opcode 0x62 at > 0x0012 > 10-20 09:18:14.982: WARN/dalvikvm(210): VFY: rejected > Lxcxin/mysecret/mainSecretActivity;.processContact > (Landroid/database/Cursor;)V > 10-20 09:18:14.982: WARN/dalvikvm(210): Verifier rejected class > Lxcxin/mysecret/mainSecretActivity; > > Now I know where I am wrong, ContactsContract.CommonDataKinds is only > available on API Level 5 or higher. > > Thank you all > > Alex > > On Wed, Oct 20, 2010 at 7:39 AM, DanH <[email protected]> wrote: > > Right ***above*** the exception trace should > > be some arcane-looking messages with "VFY" in them. > > > On Oct 19, 6:36 pm, Alex Xin <[email protected]> wrote: > > > Hi, thanks for helping me, here's the logcat, you could see it crashes > > prior > > > to call my onCreate() method. > > > > 10-20 07:32:27.490: ERROR/AndroidRuntime(204): java.lang.VerifyError: > > > xcxin.mysecret.mainSecretActivity > > > 10-20 07:32:27.490: ERROR/AndroidRuntime(204): at > > > java.lang.Class.newInstanceImpl(Native Method) > > > 10-20 07:32:27.490: ERROR/AndroidRuntime(204): at > > > java.lang.Class.newInstance(Class.java:1472) > > > 10-20 07:32:27.490: ERROR/AndroidRuntime(204): at > > > android.app.Instrumentation.newActivity(Instrumentation.java:1097) > > > 10-20 07:32:27.490: ERROR/AndroidRuntime(204): at > > > android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2316) > > > 10-20 07:32:27.490: ERROR/AndroidRuntime(204): at > > > android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2417) > > > 10-20 07:32:27.490: ERROR/AndroidRuntime(204): at > > > android.app.ActivityThread.access$2100(ActivityThread.java:116) > > > 10-20 07:32:27.490: ERROR/AndroidRuntime(204): at > > > android.app.ActivityThread$H.handleMessage(ActivityThread.java:1794) > > > 10-20 07:32:27.490: ERROR/AndroidRuntime(204): at > > > android.os.Handler.dispatchMessage(Handler.java:99) > > > 10-20 07:32:27.490: ERROR/AndroidRuntime(204): at > > > android.os.Looper.loop(Looper.java:123) > > > 10-20 07:32:27.490: ERROR/AndroidRuntime(204): at > > > android.app.ActivityThread.main(ActivityThread.java:4203) > > > 10-20 07:32:27.490: ERROR/AndroidRuntime(204): at > > > java.lang.reflect.Method.invokeNative(Native Method) > > > 10-20 07:32:27.490: ERROR/AndroidRuntime(204): at > > > java.lang.reflect.Method.invoke(Method.java:521) > > > 10-20 07:32:27.490: ERROR/AndroidRuntime(204): at > > > com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791) > > > 10-20 07:32:27.490: ERROR/AndroidRuntime(204): at > > > com.android.internal.os.ZygoteInit.main(ZygoteInit.java:549) > > > 10-20 07:32:27.490: ERROR/AndroidRuntime(204): at > > > dalvik.system.NativeStart.main(Native Method) > > > > On Wed, Oct 20, 2010 at 7:11 AM, fadden <[email protected]> wrote: > > > > On Oct 19, 2:25 am, Alex Xin <[email protected]> wrote: > > > > > I have an app that runs perfect on 2.2 and 2.2 but always getting > > > > > VerifyError on 1.6 while startup, I don't think that my app cannot > > run > > > > under > > > > > 1.6 because I don't call any APIs that don't support 1.6. > > > > > Post the output from logcat. Right above the exception trace should > > > > be some arcane-looking messages with "VFY" in them. > > > > > -- > > > > You received this message because you are subscribed to the Google > > > > Groups "Android Developers" group. > > > > To post to this group, send email to > > [email protected] > > > > To unsubscribe from this group, send email to > > > > [email protected]<android-developers%[email protected]> > > <android-developers%[email protected]<android-developers%[email protected]> > > > > > For more options, visit this group at > > > >http://groups.google.com/group/android-developers?hl=en > > > -- > > You received this message because you are subscribed to the Google > > Groups "Android Developers" group. > > To post to this group, send email to [email protected] > > To unsubscribe from this group, send email to > > [email protected]<android-developers%[email protected]> > > For more options, visit this group at > >http://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

