簡體   English   中英

更改build.gradle並在頂部存儲庫中添加Google()后出現Multidex錯誤

[英]Multidex error after changing build.gradle and adding Google() in top repository

將gradle升級到4.1后,我遇到未找到gradle 3.0.1的構建錯誤,因此我在google中發現我們必須從這個問題中在主存儲庫中添加Google()。 但是更改了build.gradle之后,我遇到了multidex錯誤,無法構建。 請幫忙。

舊的build.gradle:

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
    jcenter()
}
dependencies {
    classpath 'com.android.tools.build:gradle:3.0.1'
}

allprojects {
    repositories {
        mavenCentral()
    }
}
}

 repositories {
  google()
 }

新的build.gradle:

// Top-level build file where you can add configuration options common to all sub-projects/modules.
 buildscript {
   repositories {
    google()
    jcenter()
  }
  dependencies {
    classpath 'com.android.tools.build:gradle:3.0.1'
  }

  allprojects {
    repositories {
        mavenCentral()
    }
  }
 }

 /*
 repositories {
   google()
 }*/

gradle-wrapper.properties

#Sun Feb 11 23:10:50 IST 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip

項目.gradle文件

apply plugin: 'com.android.library'


dependencies {
compile fileTree(include: '*.jar', dir: 'libs')


compile ('com.google.android.gms:play-services:11.0.0'){
    exclude group: 'com.android.support'
}

//acra
compile ('ch.acra:acra:4.9.2'){
    exclude group: 'com.android.support'
}

//compile 'com.android.support:appcompat-v7:22.2.0'

compile ('com.android.support:design:22.2.0'){
    exclude module: 'support-v4'
}

compile ('com.stripe:stripe-android:4.1.1'){
    exclude group: 'com.android.support'
}

/*Retrofit*/
compile ('com.squareup.retrofit2:retrofit:2.3.0'){
    exclude module: 'okhttp'
}

compile 'com.squareup.okhttp3:logging-interceptor:3.4.1'
compile 'com.squareup.okhttp3:okhttp:3.4.1'

compile 'com.google.code.gson:gson:2.8.2'
compile 'com.squareup.retrofit2:converter-gson:2.3.0'


compile ('com.android.support:recyclerview-v7:22.2.0'){
    exclude module: 'support-annotations'
    exclude module: 'support-v4'
}

/*compile ('com.google.android.gms:play-services-auth:8.3.0'){
    exclude group: 'com.android.support'
}*/


}

android {
compileSdkVersion 22
buildToolsVersion "26.0.2"
sourceSets {
    main {
        manifest.srcFile 'AndroidManifest.xml'
        java.srcDirs = ['src']
        resources.srcDirs = ['src']
        aidl.srcDirs = ['src']
        renderscript.srcDirs = ['src']
        res.srcDirs = ['res']
        assets.srcDirs = ['assets']
    }

    // Move the tests to tests/java, tests/res, etc...
    instrumentTest.setRoot('tests')

    // Move the build types to build-types/<type>
    // For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
    // This moves them out of them default location under src/<type>/... which would
    // conflict with src/ being used by the main source set.
    // Adding new build types or product flavors should be accompanied
    // by a similar customization.
    debug.setRoot('build-types/debug')
    release.setRoot('build-types/release')

}
dexOptions {
    preDexLibraries = false
}

}

你可以試試:

compile ('com.google.dagger:dagger:2.4') {
    exclude group: 'com.google.guava'
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM