找不到MultiDexApplication

时间:2014-11-27 22:53:06

标签: android android-gradle android-multidex

我试图通过从MultiDexApplication扩展新版BaseApplication来尝试使用新版logcat,但是当我尝试运行应用时,我只能获得/com.my.package I/art? Rejecting re-init on previously-failed class java.lang.Class<com.my.package.BaseApplication> /com.my.package D/AndroidRuntime? Shutting down VM /com.my.package E/AndroidRuntime? FATAL EXCEPTION: main Process: com.my.package, PID: 29930 java.lang.RuntimeException: Unable to instantiate application com.my.package.BaseApplication: java.lang.ClassNotFoundException: Didn't find class "com.my.package.BaseApplication" on path: DexPathList[[zip file "/data/app/com.my.package-2/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]] at android.app.LoadedApk.makeApplication(LoadedApk.java:563) at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4491) at android.app.ActivityThread.access$1500(ActivityThread.java:144) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1339) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:135) at android.app.ActivityThread.main(ActivityThread.java:5221) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694) Caused by: java.lang.ClassNotFoundException: Didn't find class "com.my.package.BaseApplication" on path: DexPathList[[zip file "/data/app/com.my.package-2/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]] at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56) at java.lang.ClassLoader.loadClass(ClassLoader.java:511) at java.lang.ClassLoader.loadClass(ClassLoader.java:469) at android.app.Instrumentation.newApplication(Instrumentation.java:979) at android.app.LoadedApk.makeApplication(LoadedApk.java:558) at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4491) at android.app.ActivityThread.access$1500(ActivityThread.java:144) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1339) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:135) at android.app.ActivityThread.main(ActivityThread.java:5221) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694) Suppressed: java.lang.NoClassDefFoundError: com.my.package.BaseApplication at dalvik.system.DexFile.defineClassNative(Native Method) at dalvik.system.DexFile.defineClass(DexFile.java:226) at dalvik.system.DexFile.loadClassBinaryName(DexFile.java:219) at dalvik.system.DexPathList.findClass(DexPathList.java:321) at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:54) ... 14 more Suppressed: java.lang.ClassNotFoundException: com.my.package.BaseApplication at java.lang.Class.classForName(Native Method) at java.lang.BootClassLoader.findClass(ClassLoader.java:781) at java.lang.BootClassLoader.loadClass(ClassLoader.java:841) at java.lang.ClassLoader.loadClass(ClassLoader.java:504) ... 13 more Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available (在Nexus 5上Android Lollipop,Android Studio RC2):

build.gradle

以下是 android { compileSdkVersion 21 buildToolsVersion "21.1.0" defaultConfig { applicationId "com.my.package" minSdkVersion 21 targetSdkVersion 21 versionCode 3 versionName "0.1-alpha" multiDexEnabled true } ... compile 'com.android.support:multidex:1.0.0'

BaseApplication

我的MultiDexApplication来自public class BaseApplication extends MultiDexApplication {

Manifest

这是我的 <application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:supportsRtl="true" android:theme="@style/AppTheme" android:name=".BaseApplication">

{{1}}

1 个答案:

答案 0 :(得分:0)

清单文件可能有问题吗?在&#34; AndroidManifest.xml&#34; name属性值必须设置为&#34; .BaseApplication&#34;

<application
    android:icon="@drawable/icon"
    android:label="@string/app_name"
    android:name=".BaseApplication">