编译Android项目

时间:2017-08-10 04:58:47

标签: android android-studio build.gradle

有什么问题?我无法编译项目并收到错误:

错误:任务':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 \ folders \ 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




4 个答案:

答案 0 :(得分:1)

请尝试以下代码

android{
defaultConfig {

    // Enabling multidex support.
    multiDexEnabled true
}


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

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

答案 1 :(得分:0)

在build.gradle中添加以下行;

multiDexEnabled true 
像这样:

defaultConfig 
  {
    applicationId "yourProjectPackage"
    minSdkVersion 15
    versionCode 1
    versionName "1.0"
    targetSdkVersion 23

    multiDexEnabled true //important
    }

答案 2 :(得分:0)

将以下行添加到您的应用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'

        }
    }

答案 3 :(得分:0)

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

SELECT 
    ID_company, 
    date_grouped, 
    sum(credit_table1) + sum(credit_table2) total_credits, 
    sum(debit_tabel3) + sum(debit_table4) total_debit, 
    sum(debit_tabel3) + sum(debit_table4)
        - (sum(credit_table1) + sum(credit_table2)) balance
FROM (
    SELECT 
        ID_Company, 
        date_table1 date_grouped, 
        credit_table1,
        0 credit_table2, 
        0 debit_table3, 
        0 debit_table4 
    FROM table1
    UNION
    SELECT 
        ID_Company, 
        date_table2 date_grouped, 
        0 credit_table1, 
        credit_table2,
        0 debit_table3, 
        0 debit_table4 
    FROM table2
    UNION
    SELECT 
        ID_Company, 
        date_table3 date_grouped, 
        0 credit_table1, 
        0 credit_table2, 
        debit_table3,
        0 debit_table4 
    FROM table3
    UNION
    SELECT 
        ID_Company, 
        date_table4 date_grouped, 
        0 credit_table1, 
        0 credit_table2, 
        0 debit_table3,
        debit_table4
    FROM table4  
)
GROUP BY ID_company, date_grouped