2

我正在尝试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

这是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">
4

1 回答 1

0

清单文件可能有问题吗?在“AndroidManifest.xml”中,名称属性值必须设置为“.BaseApplication”

<application
    android:icon="@drawable/icon"
    android:label="@string/app_name"
    android:name=".BaseApplication">
于 2014-11-28T08:16:03.073 回答