更改build.gradle并在顶级存储库中添加Google()后出现Multidex错误

问题描述 投票:0回答:1

将gradle升级到4.1后,我遇到构建错误,找不到gradle 3.0.1所以我谷歌发现我们应该从this question在主存储库中添加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()
 }*/

grad了-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

project .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
}

}

android gradle multidex
1个回答
0
投票

你可以试试:

compile ('com.google.dagger:dagger:2.4') {
    exclude group: 'com.google.guava'
}
© www.soinside.com 2019 - 2024. All rights reserved.