将字节码转换为 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;
我在尝试构建 APK 后遇到此错误,有什么想法吗?
错误:将字节码转换为 dex 时出错:
原因:com.android.dex.DexException:多个dex文件定义Lcom/RNFetchBlob/RNFetchBlobConst;
错误:com.android.dex.DexException:多个 dex 文件定义 Lcom/RNFetchBlob/RNFetchBlobConst;
错误:任务“:app:transformDexArchiveWithDexMergerForDebug”执行失败。
com.android.build.api.transform.TransformException: com.android.dex.DexException: Multiple dex files define Lcom/RNFetchBlob/RNFetchBlobConst;
加入gradle.property这一行
org.gradle.jvmargs=-Xmx1024m
清理并重建项目后
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 解决了这个问题。
我在尝试构建 APK 后遇到此错误,有什么想法吗?
错误:将字节码转换为 dex 时出错: 原因:com.android.dex.DexException:多个dex文件定义Lcom/RNFetchBlob/RNFetchBlobConst;
错误:com.android.dex.DexException:多个 dex 文件定义 Lcom/RNFetchBlob/RNFetchBlobConst;
错误:任务“:app:transformDexArchiveWithDexMergerForDebug”执行失败。
com.android.build.api.transform.TransformException: com.android.dex.DexException: Multiple dex files define Lcom/RNFetchBlob/RNFetchBlobConst;
加入gradle.property这一行
org.gradle.jvmargs=-Xmx1024m
清理并重建项目后
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 解决了这个问题。