[英]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.