简体   繁体   English

将字节码转换为dex时出错:原因:com.android.dex.DexException:多个dex文件定义了Lcom / RNFetchBlob / RNFetchBlobConst;

[英]Error converting bytecode to dex: Cause: com.android.dex.DexException: Multiple dex files define Lcom/RNFetchBlob/RNFetchBlobConst;

I'm getting this error after i try to build APK, Any ideas? 我尝试构建APK后收到此错误,有什么想法吗?

Error:Error converting bytecode to dex: Cause: com.android.dex.DexException: Multiple dex files define Lcom/RNFetchBlob/RNFetchBlobConst; 错误:将字节码转换为dex时出错:原因:com.android.dex.DexException:多个dex文件定义了Lcom / RNFetchBlob / RNFetchBlobConst;

Error:com.android.dex.DexException: Multiple dex files define Lcom/RNFetchBlob/RNFetchBlobConst; 错误:com.android.dex.DexException:多个dex文件定义了Lcom / RNFetchBlob / RNFetchBlobConst;

Error:Execution failed for task ':app:transformDexArchiveWithDexMergerForDebug'. 错误:任务':app:transformDexArchiveWithDexMergerForDebug'的执行失败。

com.android.build.api.transform.TransformException: com.android.dex.DexException: Multiple dex files define Lcom/RNFetchBlob/RNFetchBlobConst; com.android.build.api.transform.TransformException:com.android.dex.DexException:多个dex文件定义了Lcom / RNFetchBlob / RNFetchBlobConst;

add in gradle.property this line 添加gradle.property这行

org.gradle.jvmargs=-Xmx1024m

after that clean and rebuild project 在清理并重建项目之后

Multidex exception intends that your app and libraries it references exceeds 65536 methods which means it has crossed the limit of Android build architecture.

There are possible reasons for your Multidex exception.
May be you have missed on something while enabling Multidex in you app.

I would suggest you to go through the documentation and also go through the limitations of Multidex.

If your minSdkversion is set to 21 the you just need to add following in your module level grade file:

android {
    defaultConfig {
        minSdkVersion 21 
        targetSdkVersion 26
        multiDexEnabled true
    }

}

 However, if your minSdkVersion set to 20 or low then you need to follow the following:

in your module level grade file add this:
android {
    defaultConfig {
        ...
        minSdkVersion 15 
        targetSdkVersion 26
        multiDexEnabled true
    }
    ...
}

dependencies {
  compile 'com.android.support:multidex:1.0.3'
}

If you are not overriding Application class the add this in your manifest file application tag:

    <application
            android:name="android.support.multidex.MultiDexApplication" >
        ...
    </application>

if you override Application class then just replace Application with MultiDexApplication like this :

public class MyApplication extends MultiDexApplication { ... }


if you don not override Application class and you cannot change your base class then add this:
public class MyApplication extends SomeOtherApplication {
  @Override
  protected void attachBaseContext(Context base) {
     super.attachBaseContext(base);
     MultiDex.install(this);
  }
}

following is the link for MultiDex documentation
https://developer.android.com/studio/build/multidex

我通过从react-native-fetch-blob切换到rn-fetch-blob解决了该问题。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 将字节码转换为dex:原因:com.android.dex.DexException:定义了多个dex文件 - converting bytecode to dex: Cause: com.android.dex.DexException: Multiple dex files define 错误:将字节码转换为dex时出错:原因:com.android.dex.DexException:多个dex文件定义了Lcom / google / android / gms / common / api / zza; - Error:Error converting bytecode to dex: Cause: com.android.dex.DexException: Multiple dex files define Lcom/google/android/gms/common/api/zza; Gradle 构建错误将字节码转换为 dex 时出错:原因:com.android.dex.DexException:多个 dex 文件定义 Landroid/arch/lifecycle/liveData$1 - Gradle build error Error converting bytecode to dex:Cause: com.android.dex.DexException:Multiple dex files define Landroid/arch/lifecycle/liveData$1 com.android.dex.DexException:多个dex文件定义了Lcom / google / android / gms / location / places / PlaceReport; - com.android.dex.DexException: Multiple dex files define Lcom/google/android/gms/location/places/PlaceReport; com.android.dex.DexException:多个dex文件定义了Lcom / facebook / internal / Utility $ GraphMeRequestWithCacheCallback; - com.android.dex.DexException: Multiple dex files define Lcom/facebook/internal/Utility$GraphMeRequestWithCacheCallback; 未知源文件:com.android.dex.DexException:多个dex文件定义了Lcom / google / android / gms / internal / zzpq; - Unknown source file : com.android.dex.DexException: Multiple dex files define Lcom/google/android/gms/internal/zzpq; 错误:com.android.dex.DexException:多个dex文件定义了Ledu / umd / cs / findbugs / annotations / NonNull; - Error:com.android.dex.DexException: Multiple dex files define Ledu/umd/cs/findbugs/annotations/NonNull; com.android.dex.DexException:多个dex文件定义Lorg / hamcrest / Description; - com.android.dex.DexException: Multiple dex files define Lorg/hamcrest/Description; 意外的顶级异常:com.android.dex.DexException:多个dex文件定义 - UNEXPECTED TOP-LEVEL EXCEPTION: com.android.dex.DexException: Multiple dex files define 意外的顶级异常:com.android.dex.DexException:多个dex文件定义 - UNEXPECTED TOP-LEVEL EXCEPTION: com.android.dex.DexException: Multiple dex files define
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM