I am also seeing this issue and I have repro steps for this.
Let's assume I have two eclipse projects:
* jar
* app (references jar)
If I directly include "jar" project as reference under "Java Build
Path"->Project. Eclipse compiles the code correctly (i.e. I can use
classes from "jar" projects). Though dexer simply ignores .class files
generated by "jar" project and never includes them in final .dex file.
Also under "Android Dependencies" there is only "annotations.jar" (no
mentions of "jar" project).
This "app" project compiles but crashes at runtime due to missing
classes from "jar" .
You can find example of this configuration here:
https://github.com/inazaruk/examples/tree/master/JarDependency/case1
*********************
Now about second case which makes these things work. If we introduce
another project called "lib" :
* jar
* lib (references jar)
* app (referneces lib)
Where "lib" is Android Library. Now you need to go to "lib" project
and add "jar" project at "Java Build Path" -> Project tab and export
it on "Order and Export" tab.
After this is done, go to "app" project and add "lib" as Andorid
Library through "Android" menu in Project properties.
This will result in working application. The interesting part: if you
now go to "lib" project and check "Android Dependencies" you won't see
"jar" there. But if you go to "app" project and look under "Android
Dependencies" you'll see both "lib" and "jar" dependencies there.
You can see an example of this configuration here:
https://github.com/inazaruk/examples/tree/master/JarDependency/case2
**************
The conclusion: direct dependency on java project (which I'm calling
"jar" here) isn't working; but transitive dependency through another
android library works just fine.
On Mar 23, 8:47 pm, Xavier Ducrohet <
x...@android.com> wrote:
> The particular problem in the original email is unreproducible by us, and
> we never got any answers to our questions.
>
> If you can't make it work, please let me know what your project set up
> looks like (after reading all ofhttp://
tools.android.com/recent/dealingwithdependenciesinandroidprojectsto
> make sure you made required changes), and we'll try to figure out what's
> going on.
>
>
>
>
>
>
>
>
>
> On Thu, Mar 22, 2012 at 1:04 AM, John M <
john.mickelo...@gmail.com> wrote:
> > So you guys were made aware of this issue before the general release and
> > didn't fix it. Thanks.
>
> > On Friday, March 9, 2012 6:43:32 AM UTC-5, alex2k8 wrote:
>
> >> ProjA - Java Project
>
> >> public class A {
> >> public void m1() {}
> >> }
>
> >> ProjB - Android Project
>
> >> Properties > Java Build Path > ProjA
>
> >> And from ProjB I am calling the class A:
>
> >> public void onCreate(Bundle savedInstanceState) {
> >> super.onCreate(**savedInstanceState);
> >> setContentView(R.layout.main);
> >> new A().m1();
> >> }
>
> >> But I get such error:
>
> >> 03-09 15:34:27.790: E/dalvikvm(7802): Could not find class
> >> 'com.test.A', referenced from method com.test.MainActivity.onCreate
> >> 03-09 15:34:27.790: W/dalvikvm(7802): VFY: unable to resolve new-
> >> instance 5 (Lcom/test/A;) in Lcom/test/MainActivity;
> >> 03-09 15:34:27.790: D/dalvikvm(7802): VFY: replacing opcode 0x22 at
> >> 0x0008
> >> 03-09 15:34:27.790: D/dalvikvm(7802): DexOpt: unable to opt direct
> >> call 0x0004 at 0x0a in Lcom/test/MainActivity;.**onCreate
> >> 03-09 15:34:27.820: D/AndroidRuntime(7802): Shutting down VM
> >> 03-09 15:34:27.820: W/dalvikvm(7802): threadid=1: thread exiting with
> >> uncaught exception (group=0x40a3b1f8)
> >> 03-09 15:34:27.820: E/AndroidRuntime(7802): FATAL EXCEPTION: main
> >> 03-09 15:34:27.820: E/AndroidRuntime(7802):
> >> java.lang.**NoClassDefFoundError: com.test.A
> >> 03-09 15:34:27.820: E/AndroidRuntime(7802): at
> >> com.test.MainActivity.**onCreate(MainActivity.java:13)
> >> ...
>
> >> How to fix this issue?
>
> --
> Xavier Ducrohet
> Android SDK Tech Lead
> Google Inc.
http://developer.android.com|
http://tools.android.com