【问题标题】:Compiling Android Project编译安卓项目
【发布时间】:2018-01-18 04:14:53
【问题描述】:

怎么了?我无法编译项目并得到错误:

错误:任务 ':app:transformClassesWithDexForGoogleDebug' 执行失败。

com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: 执行时出错带有参数的主类 com.android.dx.command.Main 的 java 进程 {--dex --force-jumbo --num-threads=4 --multi-dex --main-dex-list C:\Users\andre \Desktop\MYproject\app\build\intermediates\multi-dex\google\debug\maindexlist.txt --output C:\Users\andre\Desktop\MYproject\app\build\intermediates\transforms\dex\google\debug\文件夹\1000\1f\main C:\Users\andre\Desktop\MYproject\app\build\intermediates\transforms\jarMerging\google\debug\jars\1\1f\combined.jar}

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'com.google.firebase.firebase-perf'

android {
    compileSdkVersion 26
    buildToolsVersion '26.0.1'
    defaultConfig {
        applicationId "com.gvarani.myproject"
        minSdkVersion 17
        targetSdkVersion 26
        versionCode 15
        versionName "1.0"
        vectorDrawables.useSupportLibrary = true
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        multiDexEnabled true //important

    }
    useLibrary 'org.apache.http.legacy'
    signingConfigs {
        release
    }
    buildTypes {
        debug {
            minifyEnabled false
            shrinkResources false

        }
        release {
            signingConfig signingConfigs.release
            minifyEnabled true
            shrinkResources true
            useProguard true
            proguardFiles getDefaultProguardFile('proguard-android.txt'),
                    getDefaultProguardFile('proguard-android-optimize.txt'),
                    'proguard/proguard-project.pro'
        }
    }
    sourceSets {
        main.java.srcDirs += 'src/main/kotlin'
    }
    flavorDimensions "release"
    productFlavors {
        google {
            dimension "release"
        }

        other {
            dimension "release"
        }
    }

    dexOptions {
        javaMaxHeapSize "2g"
        jumboMode true
    }
}

ext {
    supportLibVersion = '26.0.0'
    gmsVersion = '11.0.4'
}

dependencies {
    googleCompile "com.google.firebase:firebase-crash:${gmsVersion}"
    googleCompile "com.google.firebase:firebase-messaging:${gmsVersion}"
    googleCompile "com.google.firebase:firebase-auth:${gmsVersion}"
    googleCompile 'com.anjlab.android.iab.v3:library:1.0.42'
    compile "com.android.support:appcompat-v7:${supportLibVersion}"
    compile "com.android.support:cardview-v7:${supportLibVersion}"
    compile "com.android.support:design:${supportLibVersion}"
    compile "com.android.support:customtabs:${supportLibVersion}"
    compile "com.google.firebase:firebase-perf:${gmsVersion}"
    compile "com.google.firebase:firebase-database:${gmsVersion}"
    compile "com.google.firebase:firebase-ads:${gmsVersion}"
    compile 'com.firebaseui:firebase-ui-auth:2.2.0'
    compile 'com.firebaseui:firebase-ui-database:2.2.0'
    compile 'com.google.code.gson:gson:2.8.1'
    compile 'dev.dworks.libs:volleyplus:0.1.4'
    compile 'cat.ereza:customactivityoncrash:2.1.0'
    compile 'com.github.PhilJay:MPAndroidChart:v3.0.2'
    compile 'org.fabiomsr:moneytextview:1.1.0'
    compile 'com.zsoltsafrany:needle:1.0.0'
    compile 'com.github.lykmapipo:local-burst:v0.2.0'
    compile 'com.github.javiersantos:AppUpdater:2.6.1'
    compile 'de.psdev.licensesdialog:licensesdialog:1.8.2'
    compile 'org.jsoup:jsoup:1.10.3'
    compile 'com.wordplat:ikvStockChart:0.1.5'
    compile 'com.android.support:multidex:1.0.0'
    //Kotlin dependencies
    compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
}

apply plugin: 'com.google.gms.google-services

【问题讨论】:

标签: android android-studio build.gradle


【解决方案1】:

请尝试以下代码

android{
defaultConfig {

    // Enabling multidex support.
    multiDexEnabled true
}


dexOptions {
    javaMaxHeapSize "4g"
}
}
dependencies {
//...
 compile 'com.android.support:multidex:1.0.0'
  }

**希望这会有所帮助**

【讨论】:

    【解决方案2】:

    在 build.gradle 中加入下面一行;

    multiDexEnabled true 
    

    像这样:

    defaultConfig 
      {
        applicationId "yourProjectPackage"
        minSdkVersion 15
        versionCode 1
        versionName "1.0"
        targetSdkVersion 23
    
        multiDexEnabled true //important
        }
    

    【讨论】:

    • 将 buildToolVersion 更改为 26.0.0,然后清理并重建项目
    【解决方案3】:

    在您的 manifest.xml 文件中添加以下代码:

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

    【讨论】:

      【解决方案4】:

      在您的应用程序 build.gradle 中添加以下行

       buildTypes {
                  release {
                      minifyEnabled false
                      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
      
                  }
      
              debug {
                  minifyEnabled false
                  proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
      
              }
          }
      

      【讨论】:

        【解决方案5】:

        在项目级 gradle 中添加 maven { url "https://maven.google.com" }

        allprojects {
            repositories {
                jcenter()
                maven {
                    url "https://maven.google.com"
                }
            }
        }
        

        【讨论】:

        • 解决我问题的方法是转移到Android Studio Canary
        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多