2016-11-08 93 views
4

我正在製作具有目標SDK版本24和最低版本19的Android應用程序。它在較高API級別上正常工作,但試圖在API上運行時19平其與以下錯誤崩潰:「ClassNotFoundException:未在路徑DexPathList上找到類」on API 19

java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{se.android/se.android.SplashScreenActivity}: java.lang.ClassNotFoundException: Didn't find class "se.android.SplashScreenActivity" on path: DexPathList[[zip file "/data/app/se.android-2.apk"],nativeLibraryDirectories=[/data/app-lib/se.android-2, /vendor/lib, /system/lib]] 
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2121) 
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245) 
        at android.app.ActivityThread.access$800(ActivityThread.java:135) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196) 
        at android.os.Handler.dispatchMessage(Handler.java:102) 
        at android.os.Looper.loop(Looper.java:136) 
        at android.app.ActivityThread.main(ActivityThread.java:5017) 
        at java.lang.reflect.Method.invokeNative(Native Method) 
        at java.lang.reflect.Method.invoke(Method.java:515) 
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595) 
        at dalvik.system.NativeStart.main(Native Method) 
       Caused by: java.lang.ClassNotFoundException: Didn't find class "se.android.SplashScreenActivity" on path: DexPathList[[zip file "/data/app/se.android-2.apk"],nativeLibraryDirectories=[/data/app-lib/se.android-2, /vendor/lib, /system/lib]] 
        at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56) 
        at java.lang.ClassLoader.loadClass(ClassLoader.java:497) 
        at java.lang.ClassLoader.loadClass(ClassLoader.java:457) 
        at android.app.Instrumentation.newActivity(Instrumentation.java:1061) 
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2112) 
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)  
        at android.app.ActivityThread.access$800(ActivityThread.java:135)  
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)  
        at android.os.Handler.dispatchMessage(Handler.java:102)  
        at android.os.Looper.loop(Looper.java:136)  
        at android.app.ActivityThread.main(ActivityThread.java:5017)  
        at java.lang.reflect.Method.invokeNative(Native Method)  
        at java.lang.reflect.Method.invoke(Method.java:515)  
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)  
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)  
        at dalvik.system.NativeStart.main(Native Method)  

有關活動是建立在清單文件:

<activity 
     android:name=".SplashScreenActivity" 
     android:label="@string/app_name" 
     android:screenOrientation="portrait" 
     android:theme="@style/Theme.AppCompat.NoActionBar"> 

     <intent-filter> 
      <action android:name="android.intent.action.MAIN" /> 
      <category android:name="android.intent.category.LAUNCHER" /> 
     </intent-filter> 

</activity> 

我曾嘗試應用程序啓動上改變其行爲但不工作。在Gradle設置中啓用Multidex。

我已經嘗試清理它並從存儲庫重新加載它,但它不會工作。

+0

是否在擴展AppCompatActivity? –

+0

是的,它擴展了AppCompatActivity –

回答

7

我終於設法解決了這個問題。原來,雖然我曾與

defaultConfig { 
    multiDexEnabled true 
    ... 
} 

啓用MultiDex在gradle這個設置和進口的MultiDex庫

depenencies { 
    ... 
    compile 'com.android.support:multidex:1.0.1' 
    ... 
} 

我忘了把它與

<application 
    ... 
    android:name="android.support.multidex.MultiDexApplication" 
    ... 
> 
    ... 
</application> 
添加在AndroidManifest.xml

添加該部件後,現在在API級別19上工作。

+0

奇怪的是,這允許我的應用程序通過Hockey App分發,而在我運行相同的錯誤之前。謝謝 – ElliotM

1

use fol降低您的gradle文件中的代碼。

defaultConfig { 
 
    multiDexEnabled true 
 
    ... 
 
}

和 depenencies

{ 
 
    ... 
 
    compile 'com.android.support:multidex:1.0.1' 
 
    ... 
 
}

然後SYC項目。

相關問題