Wednesday 10 October 2012

Error: Could not find class 'com.woodenhero.android.core.CoreClass', referenced from method com.woodenhero.android.cafebabe.MainActivity.onCreate

Has it happened to you? You're building an Android app with another project on the build path and the app crashes with a stack trace like this:


Could not find class 'com.woodenhero.android.core.CoreClass', referenced from method com.woodenhero.android.cafebabe.MainActivity.onCreate
VFY: unable to resolve new-instance 426 (Lcom/woodenhero/android/core/CoreClass;) in Lcom/woodenhero/android/cafebabe/MainActivity;
VFY: replacing opcode 0x22 at 0x0008
DexOpt: unable to opt direct call 0x0bd5 at 0x0a in Lcom/woodenhero/android/cafebabe/MainActivity;.onCreate


This is how you fix it.


Select your referenced project in Package Explorer and go Project -> Properties

Select Android on the left hand pane

In the Library section, check "Is Library"


Select your app project in Package Explorer and go Project -> Properties

Select Android on the left hand pane

In the Library section, click Add...

Select the app of your referenced project

Click OK then OK again to close the Properties dialog



Clean, compile and run again. You should be good to go.