0

I've created a java annotation processor in a project (which I'll call JavaLibrary) that makes use of android.os.Bundle. As such, the project has the following line in its gradle.build dependencies:

compile 'com.google.android:android:4.1.1.4'

In gradle.build, sourceCompatibility and targetCompatibility are both set to version 1.6 and this project compiles just fine on its own.

I have also created an Android Library project (which I'll call AndroidLibrary) that depends on JavaLibrary. I'm expecting JavaLibrary to process some annotations used in AndroidLibrary and generate some code.

However, when I try to compile AndroidLibrary, I get the following error:

java.lang.NoClassDefFoundError: android/os/Bundle

The stack trace shows the line where the android.os.Bundle is referenced in JavaLibrary.

Why is this happening and how do I get these two projects to compile together?

Nathan Taylor
  • 879
  • 1
  • 9
  • 16

1 Answers1

0

I'm not sure with gradle parts. The Android OS jars we build against are just API stubs and should not be exported since they are "provided" by the device.

To use Android classes in Java projects, you can copy the Java source files you need into your Java project so long as they (and their dependencies) don't reference native or internal code.

Not sure why you need a bundle in there, but here's a link to GrepCode's copy of it's source:

http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/2.2.1_r1/android/os/Bundle.java

CodeShane
  • 6,480
  • 1
  • 18
  • 24