0

After I set android:targetSdkVersion to 15, application doest work in 1.6 emulator. It throws java.lang.VerifyError.

Edit: The app is crashing because I'm calling invalidateOptionsMenu, which came in API 11. Now even I check before calling it (if (VERSION.SDK_INT >= 11)). It still throws same error.

prolink007
  • 33,872
  • 24
  • 117
  • 185
xmen
  • 1,947
  • 2
  • 25
  • 47
  • I doubt it is because you changed your `targetSdkVersion`. A `VerifyError` is `thrown when the "verifier" detects that a class file, though well formed, contains some sort of internal inconsistency or security problem.` – Kazekage Gaara Jun 07 '12 at 13:08
  • I successfully ran the application before converting target version to 15. Even log cat doesn't pinpoint the correct location. – xmen Jun 07 '12 at 13:10
  • Hmm.. Have a look at [this](http://stackoverflow.com/questions/668788/android-java-lang-verifyerror) – Kazekage Gaara Jun 07 '12 at 13:16
  • As a side note, I would strongly encourage you to drop support for 1.6 if you can. It can be a real mess when doing more advanced layouts, and it is an extremely small target audience. – pgsandstrom Jun 07 '12 at 13:27
  • Alright, but the method I need to use only exists in 3.0. And according to http://developer.android.com/resources/dashboard/platform-versions.html 2.3.3 is on top. – xmen Jun 07 '12 at 13:33

3 Answers3

0

Just set up a new emulator!

For this you can simply use your AVD Manager (Android Virtual Device)!

It's like as you would run your 4.0 App on a 1.6 Device. If you don't have to set your apiLevel to 15 (i.e. you don't need the new APIs) you should think about setting it to the lowest level possible.

Edit:

There IS a difference between the minSDK Version and the API level of the project:
MinLevel: what devices are able to run the app
ApiLevel: what APIs are able to use in your project in eclipse

Try to make sure you don't mix them up, so that your MinLevel hopefully matches your ApiLevel. Doing so will ensure your App does not get such errors,

Alex Lockwood
  • 83,063
  • 39
  • 206
  • 250
Thkru
  • 4,218
  • 2
  • 18
  • 37
  • so why minSdkVersion exists ? even docs says setting minSdkVersion will support old versions – xmen Jun 07 '12 at 13:16
  • yes but how do I call method of higher API if they exists ? check my edited question – xmen Jun 07 '12 at 13:29
0

You probably forgot to set your project build to version 4.0.3.

  1. Right click your project in the project explorer.
  2. Click properties.
  3. Click Android.
  4. Click the check box next to 4.0.3.
Alex Lockwood
  • 83,063
  • 39
  • 206
  • 250
  • +1 Cool short post, but but isn't his APIlevel not already 4.0.3? – Thkru Jun 07 '12 at 13:22
  • I can't tell for sure, but my guess is that he *only* changed the target version integer in the Android manifest. It would make sense that a `VerrifyError` exception is thrown if this were the case. – Alex Lockwood Jun 07 '12 at 13:27
0

Nice trick in this answer. Brilliant. Thanks everyone.

Community
  • 1
  • 1
xmen
  • 1,947
  • 2
  • 25
  • 47