java.lang.NoClassDefFoundError的:Android Studio中添加新的模块时,android.support.v4.app.NavUtilsJB错误 [英] java.lang.NoClassDefFoundError: android.support.v4.app.NavUtilsJB error when adding new module in Android Studio
问题描述
我有一个奇怪的错误添加新的模块( https://github.com/lomza/android - 颜色选取器)到我的项目。如果没有这个模块项目运行良好,但如果这个项目作为模块添加到我的主要项目,并编译它 - 一切看起来不错,但应用程序启动和关闭的力量瞬间给我这个错误:
I have a strange error adding new module (https://github.com/lomza/android-color-picker) to my project. Without this module project runs fine, but if add this project as module to my main project and compile it - everything looks good, but app starts and force closes instantly giving me this error:
FATAL EXCEPTION: main
java.lang.NoClassDefFoundError: android.support.v4.app.NavUtilsJB
at android.support.v4.app.NavUtils$NavUtilsImplJB.getParentActivityName(NavUtils.java:125)
at android.support.v4.app.NavUtils.getParentActivityName(NavUtils.java:302)
at android.support.v4.app.NavUtils.getParentActivityName(NavUtils.java:281)
at android.support.v7.app.ActionBarActivityDelegateBase.onCreate(ActionBarActivityDelegateBase.java:142)
at android.support.v7.app.ActionBarActivity.onCreate(ActionBarActivity.java:123)
at app.user.views.ActivityWelcome.onCreate(ActivityWelcome.java:33)
at android.app.Activity.performCreate(Activity.java:5133)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2175)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
at android.app.ActivityThread.access$600(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5103)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
ActivityWelcome.java
33行是 super.onCreate(savedInstanceState);
如果我从项目中删除该模块 - 再次一切运行正常。我有添加任何新的模块到我的项目相同的问题。问题出在哪里?
If I remove this module from project - everything runs fine again. I have same problem adding any new module to my project. Where is the problem?
编辑:我发现,项目运行在21 API罚款,但如果我在18 API运行它,我得到错误
I find out that project runs fine on API 21, but if I run it on API 18, I am getting error.
推荐答案
我发现这个问题的解决方案。我是用multidexing,这是只有在棒棒糖设备可用,因此,在pre-棒棒糖设备使用它,我需要加入这一行
I found solution for this problem. I was using multidexing and it is available only in Lolipop devices, so, to use it in pre-Lolipop devices I needed to add this line
编译com.android.support:multidex:1.0.0
到的build.gradle
文件
和这一行
的android:NAME =android.support.multidex.MultiDexApplication
到的AndroidManifest.xml
在 <参加办法
标记。
对于我 - 现在一切正常。
For me - now everything works fine.
编辑:而不是添加行的android:名称
清单中,你可以添加 multiDexEnabled = TRUE
到 gradle这个
文件中的 defaultConfig
。
instead of adding line to android:name
in manifest, you can add multiDexEnabled = true
to gradle
file in defaultConfig
.
这篇关于java.lang.NoClassDefFoundError的:Android Studio中添加新的模块时,android.support.v4.app.NavUtilsJB错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!