Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
714 views
in Technique[技术] by (71.8m points)

android - No original dex files found for dex location

E/AndroidRuntime: FATAL EXCEPTION: main
                  Process: com.example.nnroh.debtmanager, PID: 23433
                  java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.nnroh.debtmanager/com.example.nnroh.debtmanager.AddPersonActivity}: android.view.InflateException: Binary XML file line #2: Binary XML file line #2: Error inflating class layout
                      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2778)
                      at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
                      at android.app.ActivityThread.-wrap11(Unknown Source:0)
                      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
                      at android.os.Handler.dispatchMessage(Handler.java:106)
                      at android.os.Looper.loop(Looper.java:164)
                      at android.app.ActivityThread.main(ActivityThread.java:6494)
                      at java.lang.reflect.Method.invoke(Native Method)
                      at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
                      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
                   Caused by: android.view.InflateException: Binary XML file line #2: Binary XML file line #2: Error inflating class layout
                   Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class layout
                   Caused by: java.lang.ClassNotFoundException: Didn't find class "android.view.layout" on path: DexPathList[[zip file "/data/app/com.example.nnroh.debtmanager-eZJs9JyPFQcK5hHTFcCewQ==/base.apk", zip file "/data/app/com.example.nnroh.debtmanager-eZJs9JyPFQcK5hHTFcCewQ==/split_lib_dependencies_apk.apk", zip file "/data/app/com.example.nnroh.debtmanager-eZJs9JyPFQcK5hHTFcCewQ==/split_lib_resources_apk.apk", zip file "/data/app/com.example.nnroh.debtmanager-eZJs9JyPFQcK5hHTFcCewQ==/split_lib_slice_0_apk.apk", zip file "/data/app/com.example.nnroh.debtmanager-eZJs9JyPFQcK5hHTFcCewQ==/split_lib_slice_1_apk.apk", zip file "/data/app/com.example.nnroh.debtmanager-eZJs9JyPFQcK5hHTFcCewQ==/split_lib_slice_2_apk.apk", zip file "/data/app/com.example.nnroh.debtmanager-eZJs9JyPFQcK5hHTFcCewQ==/split_lib_slice_3_apk.apk", zip file "/data/app/com.example.nnroh.debtmanager-eZJs9JyPFQcK5hHTFcCewQ==/split_lib_slice_4_apk.apk", zip file "/data/app/com.example.nnroh.debtmanager-eZJs9JyPFQcK5hHTFcCewQ==/split_lib_slice_5_apk.apk", zip file "/data/app/com.example.nnroh.debtmanager-eZJs9JyPFQcK5hHTFcCewQ==/split_lib_slice_6_apk.apk", zip file "/data/app/com.example.nnroh.debtmanager-eZJs9JyPFQcK5hHTFcCewQ==/split_lib_slice_7_apk.apk", zip file "/data/app/com.example.nnroh.debtmanager-eZJs9JyPFQcK5hHTFcCewQ==/split_lib_slice_8_apk.apk", zip file "/data/app/com.example.nnroh.debtmanager-eZJs9JyPFQcK5hHTFcCewQ==/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/com.example.nnroh.debtmanager-eZJs9JyPFQcK5hHTFcCewQ==/lib/x86, /system/lib, /vendor/lib]]
                      at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:125)
                      at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
                      at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
                      at android.view.LayoutInflater.createView(LayoutInflater.java:606)
                      at android.view.LayoutInflater.onCreateView(LayoutInflater.java:703)
                      at com.android.internal.policy.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:68)
                      at android.view.LayoutInflater.onCreateView(LayoutInflater.java:720)
                      at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:788)
                      at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:730)
                      at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
                      at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
                      at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
                      at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287)
                      at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)
                      at com.example.nnroh.debtmanager.AddPersonActivity.onCreate(AddPersonActivity.java:39)
                      at android.app.Activity.performCreate(Activity.java:7009)
                      at android.app.Activity.performCreate(Activity.java:7000)
E/AndroidRuntime:     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1214)
                      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2731)
                      at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
                      at android.app.ActivityThread.-wrap11(Unknown Source:0)
                      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
                      at android.os.Handler.dispatchMessage(Handler.java:106)
                      at android.os.Looper.loop(Looper.java:164)
                      at android.app.ActivityThread.main(ActivityThread.java:6494)
                      at java.lang.reflect.Method.invoke(Native Method)
                      at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
                      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
                    Suppressed: java.io.IOException: No original dex files found for dex location /data/app/com.example.nnroh.debtmanager-eZJs9JyPFQcK5hHTFcCewQ==/split_lib_resources_apk.apk
                      at dalvik.system.DexFile.openDexFileNative(Native Method)
                      at dalvik.system.DexFile.openDexFile(DexFile.java:353)
                      at dalvik.system.DexFile.<init>(DexFile.java:100)
                      at dalvik.system.DexFile.<init>(DexFile.java:74)
                      at dalvik.system.DexPathList.loadDexFile(DexPathList.java:374)
                      at dalvik.system.DexPathList.makeDexElements(DexPathList.java:337)
                      at dalvik.system.DexPathList.<init>(DexPathList.java:157)
                      at dalvik.system.BaseDexClassLoader.<init>(BaseDexClassLoader.java:65)
                      at dalvik.system.PathClassLoader.<init>(PathClassLoader.java:64)
                      at com.android.internal.os.ClassLoaderFactory.createClassLoader(ClassLoaderFactory.java:73)
                      at com.android.internal.os.ClassLoaderFactory.createClassLoader(ClassLoaderFactory.java:88)
                      at android.app.ApplicationLoaders.getClassLoader(ApplicationLoaders.java:69)
                      at android.app.ApplicationLoaders.getClassLoader(ApplicationLoaders.java:35)
                      at android.app.LoadedApk.createOrUpdateClassLoaderLocked(LoadedApk.java:693)
                      at android.app.LoadedApk.getClassLoader(LoadedApk.java:727)
                      at android.app.LoadedApk.getResources(LoadedApk.java:954)
                      at android.app.ContextImpl.createAppContext(ContextImpl.java:2270)
                      at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5639)
                      at android.app.ActivityThread.-wrap1(Unknown Source:0)
                      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1656)
                            ... 6 more
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Below I'm listing possible solutions, try this steps one by one:

  • 1 Delete app on device and Clean Project


  • 2 Disable minifyEnabled in debug mode

go to build.gradle(Module: app) in debug block and disable minifyEnabled:

buildTypes {

    debug {
        minifyEnabled false

     }
}

  • 3 Setting dataBinding to true in application's gradle file

In my case, I was including another layout <include layout="@layout/attached_layout" /> to my activity's layout and this solved it.

    android {
    ...
    ...
    ...

    dataBinding {
        enabled = true
    }

    }

  • 4 Check the relative path of your activities in manifest

eg:

<activity android:name="com.pathToClass.MyActivity"

  • 5 Check the package names in your custom views

    <com.pathToClass.MyCustomView
        android:id="@+id/myview"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="16dp"
        android:layout_marginRight="16dp" />
    

  • 6 Try disabling pre-dexing in the app build.gradle:

    dexOptions {
     preDexLibraries false
    }
    

  • 7 Disable Instant Run

    Go to File -> Settings -> Build,Execution, Deployment -> Instant Run -> Uncheck the checkbox for instant run

  • 8 Try MultiDexApplication

Add this to build.gradle(Module:app)

android { 

defaultConfig {
      ...
      multiDexEnabled true
}

dependencies {
     ... 
    implementation 'androidx.multidex:multidex:2.0.1'
}


}

if you are using application class you have to extend it with MultiDexApplication instead of Application and add it to AndroidManifest.xml

<application
    android:name="com.myPackageName.MyApplication"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name">

else add MultiDexApplication class path from library as name

<application
    android:name="androidx.multidex.MultiDexApplication"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name">

  • 9 Proguard obfuscation

Looks like the class is loaded by reflection, but your proguard file doesn't prevent that class from being obfuscated


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...