项目中遇到的一些问题汇总,记录

做项目的时候遇到的问题的汇总与解决方案,如有问题或者是不对的地方希望指教谢谢


No.1

.Error:Error converting bytecode to dex: Cause: com.android.dex.DexException: Multiple dex files define L......;

解决:

首先 在app的build.gradle中

defaultConfig {
applicationId "应用包名"
    minSdkVersion16
    targetSdkVersion26
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    // dex突破65535的限制
    multiDexEnabled true
}

其次在Application中插入

@Override
protected void attachBaseContext(Context base) {
    super.attachBaseContext(base);
    MultiDex.install(this);
}

No.2

Error:Execution failed for task ':app:transformResourcesWithMergeJavaResForDebug'.

More than one file was found with OS independent path 'META-INF/rxjava.properties'

解决:

在app的build.gradle文件的android下添加

packagingOptions {
    exclude'META-INF/rxjava.properties'
}

No.3 打包的时候出现的问题

  • What went wrong:

Execution failed for task ':app:transformDexWithDexForRelease'.

com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.dex.DexIndexOverflowException: Cannot merge new index 65981 into a non-jumbo instruction!

原因超过65535限制

解决:

在app的build.gradle文件中的defaultConfig下添加
multiDexEnabled true

defaultConfig {
    applicationId "com.stone.flybird"

    minSdkVersion16

    targetSdkVersion26

    versionCode 1

    versionName "1.0"
     // dex突破65535的限制 
    multiDexEnabled true
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}

你可能感兴趣的:(项目中遇到的一些问题汇总,记录)