Ali Shafai
Ali Shafai

Reputation: 5161

Gradle: how to add a jar to build but not export it


I'm using the Open Mobile API (SEEK API) in my project by adding the jar file to my gradle build:

dependencies {compile files('libs/org.simalliance.openmobileapi.jar')}

it gives me this exception:

        java.lang.IllegalAccessError: Class ref in pre-verified class resolved to unexpected implementation
        at dalvik.system.DexFile.defineClassNative(Native Method)
        at dalvik.system.DexFile.defineClass(DexFile.java:222)
        at dalvik.system.DexFile.loadClassBinaryName(DexFile.java:215)
        at dalvik.system.DexPathList.findClass(DexPathList.java:322)
        at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:65)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:457)

My understanding is I need to include the jar in compile process but exclude it in the linking and don't export it to my APK. this is normally done with a simple checkbox in eclipse, but I can't find a way to do it with gradle.

any help is appreciated.

Upvotes: 4

Views: 1736

Answers (1)

Langusten Gustel
Langusten Gustel

Reputation: 11002

To not export your .jar THIS is maybe helpful. (reads well)

Additionally:

Try this to get rid of the error:

Go to modules -> dependencies, then set scope of the lib to 'Provided'.

here is my source

Upvotes: 4

Related Questions