简体   繁体   English

带有Android Maven插件的java.lang.NoClassDefFoundError

[英]java.lang.NoClassDefFoundError with Android Maven Plugin

I got my android maven plugin running today and now I want to debug my apk on a real Android Device. 我今天运行了我的android maven插件,现在我想在真实的Android设备上调试我的apk。

When I execute 当我执行

cd android-proj 
mvn clean install android:redeploy 

and start the app on my device, I stumble across this error message in the LogCat: 并在我的设备上启动应用程序,我偶然发现了LogCat中的以下错误消息:

10-27 21:16:08.857: E/AndroidRuntime(14556): java.lang.NoClassDefFoundError: de.dornathal.planyourmeals.android.database.AndroidDBHelper$SQLiteDatabaseAdapter

However I searched for solutions and came across that some libraries were not included correctly what could cause this problem. 但是,我搜索了解决方案,发现没有正确包含某些库,这可能导致此问题。 The class AndroidDBHelper is not included by an dependency in the maven pom, because it is a nested class in 'android-proj/android-apk'. Maven pom中的依赖项未包含AndroidDBHelper类,因为它是'android-proj / android-apk'中的嵌套类。 Where android-proj is the folder where Maven has 2 modules the apk and core functions. 其中android-proj是Maven包含2个apk和core函数模块的文件夹。

As the AndroidManifest.xml has no direct link to AndroidDBHelper and AndroidDBHelper is the only class that knows about the SQLiteDatabaseAdapter the apk build by Maven must work at least a bit further than only calling the MainActivity. 由于AndroidManifest.xml没有直接链接到AndroidDBHelper,并且AndroidDBHelper是唯一了解SQLiteDatabaseAdapter的类,因此Maven构建的apk必须比仅调用MainActivity至少工作一点。

MFG Dornathal MFG Dornathal

Okay I found out why I kept on having that issue, and for everyone who experienced the same thing: 好吧,我发现了为什么我继续遇到这个问题,对于经历过同样事情的每个人:

I thought I was going to redeploy something to my device, but actually it got skipped. 我以为我打算将某些东西重新部署到我的设备上,但是实际上它被跳过了。 To use the android:deploy or android:redeploy I had to move to the exact folder in which the pom defining the apk was. 要使用android:deploy或android:redeploy,我必须移至定义apk的pom所在的确切文件夹。 As I named two folders the same name I wasn't at the right spot with my Shell. 当我为两个文件夹命名时,我的Shell不在正确的位置。

my tree: 我的树:

android-app [<--- thats where I was]
   \--- android-app [<---- thats where I should have been]
       \---target (with apk)
   \--- android-app-it (the integration test)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM