找不到 multidex.jar (com.android.support:multidex:1.0.2)

12

无法找到multidex.jar (com.android.support:multidex:1.0.2)。 在以下位置搜索: https://jcenter.bintray.com/com/android/support/multidex/1.0.2/multidex

我刚安装了最新版本的Android Studio 3.1.3, 当我尝试同步我的项目时,它显示无法解析:multidex

我也尝试了 https://jcenter.bintray.com/com/android/support/multidex/1.0.2/multidex 这个链接,但显示404错误。请帮忙。

项目级别:

// Top-level build file where you can add configuration options common to all sub-projects/modules.
apply from: 'buildsystem/dependencies.gradle'

buildscript {
    repositories {
        jcenter()
        mavenCentral()
        maven { url 'https://maven.fabric.io/public' }
        maven {
            url 'https://maven.google.com'
        }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.1'
        classpath 'com.frogermcs.androiddevmetrics:androiddevmetrics-plugin:0.5'
        classpath 'com.google.gms:google-services:3.1.2'
        classpath 'io.fabric.tools:gradle:1.25.1'
    }
}

allprojects {
    ext {
        androidApplicationId = 'com.medikoe.connect'
        androidVersionCode = 23
        androidVersionName = "1.7.2"
        testInstrumentationRunner = "android.support.test.runner.AndroidJUnitRunner"
        testApplicationId = 'com.medikoe.test'
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}
repositories {
    google()
}

应用层:
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
apply plugin: 'com.frogermcs.androiddevmetrics'

configurations {
    devDebugCompile
    devSignedDebugCompile
    devPreReleaseCompile
    devReleaseCompile
    prodDebugCompile
    prodSignedDebugCompile
    prodPreReleaseCompile
    prodReleaseCompile
}


android {
    def globalConfiguration = rootProject.extensions.getByName("ext")

    compileSdkVersion globalConfiguration.getAt("androidCompileSdkVersion")
    buildToolsVersion globalConfiguration.getAt("androidBuildToolsVersion")

    defaultConfig {
        minSdkVersion globalConfiguration.getAt("androidMinSdkVersion")
        targetSdkVersion globalConfiguration.getAt("androidTargetSdkVersion")
        versionCode globalConfiguration.getAt("androidVersionCode")
        applicationId globalConfiguration.getAt("androidApplicationId")
        testInstrumentationRunner globalConfiguration.getAt("testInstrumentationRunner")
        testApplicationId globalConfiguration.getAt("testApplicationId")

        multiDexEnabled true

        vectorDrawables.useSupportLibrary = true
    }

    dexOptions {

        jumboMode true
        javaMaxHeapSize "6g"

    }

    compileOptions {
        targetCompatibility 1.8
        sourceCompatibility 1.8
    }

    packagingOptions {
        exclude 'LICENSE.txt'
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/ASL2.0'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE'
    }

    lintOptions {
        quiet true
        abortOnError false
        ignoreWarnings true
        disable 'InvalidPackage'            //Some libraries have issues with this.
        disable 'OldTargetApi'
        //Lint gives this warning but SDK 20 would be Android L Beta.
        disable 'IconDensities'             //For testing purpose. This is safe to remove.
        disable 'IconMissingDensityFolder'  //For testing purpose. This is safe to remove.
    }


    signingConfigs {
        debug {
            storeFile file('../buildsystem/debug.keystore')
            storePassword 'android'
            keyAlias '********'
            keyPassword '******'
        }

        signedDebug {
            storeFile file('../buildsystem/keystore_medikoe.jks')
            storePassword '*********'
            keyAlias '*********'
            keyPassword '**********'
        }
        preRelease {
            storeFile file('../buildsystem/keystore_medikoe.jks')
            storePassword '**********'
            keyAlias '******'
            keyPassword '********'
        }

        release {
            storeFile file('../buildsystem/keystore_medikoe.jks')
            storePassword '************'
            keyAlias '**********'
            keyPassword '************'
        }
    }

    dataBinding {
        enabled = false
    }

    flavorDimensions "default"

    productFlavors {
        dev {
            // Enable pre-dexing to produce an APK that can be tested on
            // Android 5.0+ without the time-consuming DEX build processes.
            minSdkVersion 19
        }
        prod {
            // The actual minSdkVersion for the production version.
            minSdkVersion globalConfiguration.getAt("androidMinSdkVersion")
        }
    }

    buildTypes {

        debug {
            signingConfig signingConfigs.debug
            applicationIdSuffix ".debug"
            resValue "string", "app_name", "Connect-D"
            buildConfigField "boolean", "PRE_RELEASE", "false"
        }
        signedDebug {
            minifyEnabled true
            zipAlignEnabled true
            shrinkResources true
            debuggable true
            signingConfig signingConfigs.signedDebug
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            applicationIdSuffix ".signeddebug"
            resValue "string", "app_name", "Connect-SD"
            buildConfigField "boolean", "PRE_RELEASE", "false"
        }
        preRelease {
            minifyEnabled true
            zipAlignEnabled true
            shrinkResources true
            debuggable false
            signingConfig signingConfigs.release
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            applicationIdSuffix ".prerelease"
            resValue "string", "app_name", "Connect-PR"
            buildConfigField "boolean", "PRE_RELEASE", "true"
        }
        release {
            minifyEnabled true
            zipAlignEnabled true
            shrinkResources true
            debuggable false
            signingConfig signingConfigs.release
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            resValue "string", "app_name", "Medikoe Connect"
            buildConfigField "boolean", "PRE_RELEASE", "false"
        }
    }

}

dependencies {
    def presentationDependencies = rootProject.ext.presentationDependencies
    def presentationTestDependencies = rootProject.ext.presentationTestDependencies
    def developmentDependencies = rootProject.ext.developmentDependencies

    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    implementation 'com.android.support:support-v4:27+'
    compile project(':Domain')

    devDebugCompile project(path: ':Data')
    devSignedDebugCompile project(path: ':Data')
    devPreReleaseCompile project(path: ':Data')
    devReleaseCompile project(path: ':Data')
    prodDebugCompile project(path: ':Data')
    prodSignedDebugCompile project(path: ':Data')
    prodPreReleaseCompile project(path: ':Data')
    prodReleaseCompile project(path: ':Data')

    devDebugCompile project(path: ':Infrastructure')
    devSignedDebugCompile project(path: ':Infrastructure')
    devPreReleaseCompile project(path: ':Infrastructure')
    devReleaseCompile project(path: ':Infrastructure')
    prodDebugCompile project(path: ':Infrastructure')
    prodSignedDebugCompile project(path: ':Infrastructure')
    prodPreReleaseCompile project(path: ':Infrastructure')
    prodReleaseCompile project(path: ':Infrastructure')

    //compile files('libs/date4j.jar')
    //compile files('libs/commons-collections4-4.1.jar')

    annotationProcessor presentationDependencies.daggerCompiler
    compile presentationDependencies.dagger
    compile presentationDependencies.rxJava
    compile presentationDependencies.rxAndroid
    provided presentationDependencies.javaxAnnotation
    //compile presentationDependencies.autoFactory
    compile presentationDependencies.butterKnife
    annotationProcessor presentationDependencies.butterKnifeCompiler

    compile presentationDependencies.designLibrary
    compile presentationDependencies.recyclerView
    compile presentationDependencies.cardView
    compile presentationDependencies.percent
    compile presentationDependencies.glide
    compile presentationDependencies.glideOkhttp3
    compile presentationDependencies.nineOldAndroids
    //compile presentationDependencies.ahBottomNav
    //compile presentationDependencies.lapismSearch
    //compile presentationDependencies.FragmentNavigator
    compile presentationDependencies.flexibleDivider
    compile presentationDependencies.materialDialogsCore
    compile presentationDependencies.materialFavoriteButton
    compile presentationDependencies.fancyButtons
    compile presentationDependencies.simpleRatingBar
    compile presentationDependencies.circularImageView
    compile presentationDependencies.waveLoadingView
    compile presentationDependencies.googleAutoFactory
    annotationProcessor presentationDependencies.googleAutoFactory
    compile presentationDependencies.playServicesPlaces
    compile presentationDependencies.playServicesLocation
    //compile presentationDependencies.tagGroup
    //compile presentationDependencies.expandableTextView
    //compile presentationDependencies.expandableLayout
    //compile presentationDependencies.touchImageView
    //compile presentationDependencies.sublimePicker
    compile presentationDependencies.rxpermissions
    compile presentationDependencies.rxActivityResult
    compile presentationDependencies.rxBinding
    compile presentationDependencies.rxPaparazzo
    compile presentationDependencies.rxBinding
    compile presentationDependencies.parcelerApi
    annotationProcessor presentationDependencies.parceler
    compile presentationDependencies.guava
    compile presentationDependencies.weekView
    compile presentationDependencies.jodaTime
    compile presentationDependencies.rxPaparazzo
    //compile presentationDependencies.collection
    compile presentationDependencies.RecyclerViewPager
    //compile presentationDependencies.googleAnalytics
    compile presentationDependencies.SpotsProgressDialog
    compile presentationDependencies.CustomActivityOnCrash

    compile presentationDependencies.multiDex
    compile presentationDependencies.SaripaarVersion
    //compile presentationDependencies.RazorPay
    compile presentationDependencies.Timecon
    compile presentationDependencies.ClansFab
    compile presentationDependencies.MPAndroidChart
    compile presentationDependencies.FragNav
    compile presentationDependencies.CircularFillableLoaders
    compile presentationDependencies.AvatarImageView
    compile presentationDependencies.AVLoadingIndicatorView
    compile presentationDependencies.Epoxy
    annotationProcessor presentationDependencies.EpoxyProcessor
    compile presentationDependencies.RelativeTimeTextView
    //compile presentationDependencies.AudioPlayerView
    compile presentationDependencies.EasyVideoPlayer
    compile presentationDependencies.ThreeTenAndroid
    //compile presentationDependencies.Steppers
    //compile presentationDependencies.RxAccountManager
    compile presentationDependencies.MaterialProgressBar
    compile presentationDependencies.FloatingView
//    compile presentationDependencies.HashtagView{
//        //Guava appears to be included explicitly in the list-services.jar
//        //Skip the redundant dependency
//        exclude group: 'com.google.guava'
//    }
    compile('com.github.greenfrvr:hashtag-view:1.3.1@aar') {
        transitive = false
    }

    androidTestCompile presentationTestDependencies.mockito
    androidTestCompile presentationTestDependencies.dexmaker
    androidTestCompile presentationTestDependencies.dexmakerMockito
    androidTestCompile presentationTestDependencies.espresso
    androidTestCompile presentationTestDependencies.testingSupportLib
    androidTestCompile presentationTestDependencies.androidAnnotations
    androidTestCompile presentationTestDependencies.autoFactory
//    androidTestCompile presentationTestDependencies.guava

    //Development
    compile developmentDependencies.leakCanary
    compile developmentDependencies.DebugDatabase
    compile 'com.facebook.stetho:stetho:1.4.1'
    compile 'com.facebook.stetho:stetho-okhttp3:1.4.1'
    compile('com.razorpay:checkout:1.4.4')
    compile 'com.aurelhubert:ahbottomnavigation:2.1.0'
    compile 'com.github.florent37:materialtextfield:1.0.7'
    compile 'com.github.rahatarmanahmed:circularprogressview:2.5.0'
    compile('com.github.ganfra:material-spinner:2.0.0')
    compile 'com.wdullaer:materialdatetimepicker:3.5.0'
    compile 'com.myhexaville:smart-image-picker:1.0'
    compile 'com.github.blikoon:QRCodeScanner:0.1.2'
    compile 'de.hdodenhof:circleimageview:2.2.0'
    compile 'com.github.IntruderShanky:Frisson:2.1.1'
    compile 'com.jsibbold:zoomage:1.1.0'
    compile 'com.github.emrekose26:PinchZoom:-SNAPSHOT'
    compile 'com.ablanco.zoomy:zoomy:1.0.0'
    compile 'xyz.danoz:recyclerviewfastscroller:0.1.3'
    compile 'com.irozon.sneaker:sneaker:1.0.2'
    compile 'com.kyanogen.signatureview:signature-view:1.2'
    compile 'com.getkeepsafe.taptargetview:taptargetview:1.11.0'
    compile 'com.rengwuxian.materialedittext:library:2.1.4'
    implementation 'com.github.takusemba:multisnaprecyclerview:1.3.3'
    compile 'com.github.chahine:pageindicator:0.2.6'
    compile 'com.github.florent37:tutoshowcase:1.0.1'
    implementation 'io.supercharge:shimmerlayout:2.1.0'

    compile 'com.github.yeriomin:play-store-api:0.19'
    compile 'com.squareup.okhttp3:okhttp:3.8.1'

    implementation 'com.github.antonKozyriatskyi:CircularProgressIndicator:1.0.5'}

configurations.all {
    exclude group: 'com.android.support', module: 'support-v13'
}
apply plugin: 'com.google.gms.google-services'

请问您能否给我展示一下您的build.gradle文件,包括应用级别和项目级别的?这可能与您使用的Android Studio Gradle工具版本或依赖项有关。 - Yosi Pramajaya
@YosiPramajaya 请检查。 - Arpit
我在获取26.1.0依赖项时遇到了错误。显然它们已经从jcenter中删除了。它们在Google Maven存储库中也不存在。 - James Wald
4个回答

24

对我而言有效的方法是将 google() 放在 jcenter() 之前,无论是在 buildscript 中还是在 allprojectsrepositories 元素中。

针对你的情况:

repositories {
    maven {
            url 'https://maven.google.com'
        }
    jcenter()
    // Add your other repositories here
}

我也尝试了以下两种方法,它们对我都有效:

repositories {
    google()
    jcenter()
    // Add your other repositories here
}

我猜Google系统依赖项,如multidex,必须首先加载,以允许构建过程继续进行。也许构建过程期望在整个项目上使用multidex,一旦它变得足够大,仅使用jcenter依赖关系,但由于尚未从Google加载multidex而崩溃。 - buzoherbert

2

1
maven { url 'https://maven.google.com' } 可以在 Gradle 4.1+ 中被 google() 替换。 - starkej2

0

由于您正在使用Android Studio 3.1.3进行开发,请尝试将您的build.gradle依赖项和插件更新到最新版本。

并将存储库google()移动到buildscript中。

您可以尝试这样做:

顶层build.gradle

apply from: 'buildsystem/dependencies.gradle'

buildscript {
   repositories {
      jcenter()
      mavenCentral()
      maven { url 'https://maven.fabric.io/public' }
      google()
      //maven {
      //    url 'https://maven.google.com'
      //}
    }
    dependencies {
       //Update it to the latest version: 3.1.3
       classpath 'com.android.tools.build:gradle:3.1.3' 
       classpath 'com.frogermcs.androiddevmetrics:androiddevmetrics-plugin:0.5'
       classpath 'com.google.gms:google-services:3.1.2'
       classpath 'io.fabric.tools:gradle:1.25.1'
    }
}

allprojects {
   ext {
     androidApplicationId = 'com.medikoe.connect'
     androidVersionCode = 23
     androidVersionName = "1.7.2"
     testInstrumentationRunner = "android.support.test.runner.AndroidJUnitRunner"
     testApplicationId = 'com.medikoe.test'
   }

   repositories {
     google()
     jcenter()
   }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}
// Remove these lines
// repositories {
//    google()
// }

一些其他的提示:
对于您的应用程序build.gradle,尝试将compile更改为implementation,因为它很快就会被弃用。

此答案涉及到第三方分析库 'com.frogermcs.androiddevmetrics:androiddevmetrics-plugin:0.5'。 - buzoherbert
1
因为我只是从问题中复制并编辑了代码片段。 - Yosi Pramajaya
我的错!抱歉,我没有检查那个。 - buzoherbert
@Arpit你能给我展示一下你的compile presentationDependencies.multiDex吗? - Yosi Pramajaya
multiDex: "com.android.support:multidex:${multiDexVersion}",其版本为1.0.3。 - Arpit
问题已解决,我只需要在项目级别的Gradle文件中将jcenter()放在google()下面即可。 - Arpit

0

针对现在遇到此问题的任何人,在项目级别的build.gradle文件中,在buildscrript存储库和allprojects存储库之前加入google()。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接