Reputation: 10583
I have a project in Android and I want to add MapView to it. I did the following:
When I try to reach the activity with the map view, I get
....................
12-16 20:57:44.620: ERROR/AndroidRuntime(792): Caused by: java.lang.IllegalAccessError: cross-loader access from pre-verified class
12-16 20:57:44.620: ERROR/AndroidRuntime(792): at dalvik.system.DexFile.defineClass(Native Method)
12-16 20:57:44.620: ERROR/AndroidRuntime(792): at dalvik.system.DexFile.loadClass(DexFile.java:193)
............
What am I doing wrong?
Upvotes: 1
Views: 1898
Reputation: 1314
I had this exact problem today. My problem was that I added maps.jar to my project, instead of changing the Build Path to include Google APIs [android-2.1-update1]
instead of the standard android-2.1-update1
. Just including maps.jar in your project will throw an IllegalAccessException when <uses-library>
is in the right place, and a RuntimeException (stub)
when it's in the wrong place. The APIs have to be loaded through the Android API target.
Upvotes: 0
Reputation: 3391
If using Maven's Android plug-in, make sure you declare the test project's dependency on the Application-Under-Test's APK to be in 'provided' scope, like the AUT's JAR:
<dependency>
<groupId>com.example</groupId>
<artifactId>my-application</artifactId>
<type>jar</type>
<version>1.0.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.example</groupId>
<artifactId>my-application</artifactId>
<type>apk</type>
<version>1.0.0-SNAPSHOT</version>
<scope>provided</scope> <!-- ADD THIS -->
</dependency>
The Maven examples (at the time of writing) all make the test APK depend on the application APK with default (i.e. 'compile') scope, causing any libraries that the application gives 'compile' scope to be packaged into the test APK too.
Upvotes: 0
Reputation: 86
If using Eclipse, make sure that you don't have multiple references to the maps.jar on your Project Build Path. This includes any direct reference to the maps.jar, or implicit reference through the Google APIs Library (Google APIs [Android 1.5]). In fact, only having the Google APIs Library on your Project Build Path should be sufficient.
http://andmobidev.blogspot.com
Upvotes: 3