No original dex files found for dex location

前端 未结 2 1370
鱼传尺愫
鱼传尺愫 2020-12-11 22:03
E/AndroidRuntime: FATAL EXCEPTION: main
                  Process: com.example.nnroh.debtmanager, PID: 23433
                  java.lang.RuntimeException: Unable to          


        
相关标签:
2条回答
  • 2020-12-11 22:25

    try using this code in the manifest.xml inside the application tag.

    <uses-library android:name="org.apache.http.legacy" android:required="false"/>
    
    0 讨论(0)
  • 2020-12-11 22:39

    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

    0 讨论(0)
提交回复
热议问题