开发者

NoClassDefFoundError in an Android app in IntelliJ IDE

I am seeing a whole swathe of activity subclasses that are resulting in NoClassDefFoundError exceptions when using an intent to open the activity. The app compiles fine witho开发者_如何学JAVAut any errors, but on executing I am seeing these NoClassDefFoundError exceptions. My understanding is that the compiler is working fine, but the linking and APK-building process is not including all the classes, hence the build working ok but the execution failing.

The classes that work and the ones that don't sit in the same source folder, so I cannot immediately see why they are failing. All are correctly referenced in the manifest.

What am I missing?

Code:

startActivity(new Intent(Dashboard.this, SearchResultFavourites.class));

Manifest:

<activity android:name=".activity.SearchResultFavourites" android:launchMode="singleTask" />

Exception:

Caused by: java.lang.NoClassDefFoundError: myapp.activity.SearchResultFavourites at
myapp.activity.Dashboard.dashBoardBtnClick(Dashboard.java:72)

I'm pretty sure this is an IntelliJ project config issue.


It's probably a JAR that's missing from the library dependencies or the artifacts aren't being packaged properly for deployment. You should be able to set both from the IntelliJ project settings.


The solution was rather tangential. I was building the app with the GMaps API .jar but had failed to set it as an external library. Rebuilding the project with the GMaps API .jar correctly set up as an external library resolved the issue.

I have no idea why whether a library is in the APK or not should cause that exception with completely unrelated classes, but there we go.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜