【问题标题】:Gradle project sync failed after Android-Studio (3.1) updateAndroid-Studio (3.1) 更新后 Gradle 项目同步失败
【发布时间】:2018-09-05 11:22:54
【问题描述】:

在 2018 年 3 月 27 日进行更新后,我的 gradle 同步失败。我收到错误消息

Could not find org.jetbrains.kotlin:kotlin-stdlib:1.1.3-2.

我在下面发布我的 gradle 文件。我已经尝试清理和重建项目,但仍然无法正常工作。

项目级分级

    // Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        google()
        jcenter()
        maven {
            url 'https://maven.google.com/'
        }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.0'
        classpath 'com.google.gms:google-services:3.0.0'
        classpath 'com.loopj.android:android-async-http:1.4.9'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

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

应用级分级

apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
apply plugin: 'com.google.gms.google-services'

buildscript {
    repositories {
        maven { url 'https://maven.fabric.io/public' }
        google()
    }

    dependencies {
        classpath 'io.fabric.tools:gradle:1.+'
    }
}

buildscript {
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.1'
    }
}

android {
    compileSdkVersion 25
    buildToolsVersion '26.0.2'
    lintOptions {
        disable 'InvalidPackage'
    }
    defaultConfig {
        applicationId 'app.myapp.com'
        minSdkVersion 15
        targetSdkVersion 25
        versionCode 33
        versionName "1.1.30"
        useLibrary 'org.apache.http.legacy'
        // Enabling multidex support.
        multiDexEnabled true
        vectorDrawables.useSupportLibrary = true
    }
    dexOptions {
        preDexLibraries = false
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    productFlavors {
    }
    lintOptions {
        checkReleaseBuilds false
    }

    packagingOptions {
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE'
    }
}
repositories {
    mavenCentral()
    jcenter()

    maven { url 'https://maven.fabric.io/public'

    }

    maven {
        url 'https://maven.google.com/'
        name 'Google'
    }
    google()
}

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


    compile project(':android-async-http-1.4.9')


    //    compile 'com.daimajia.androidanimations:library:1.0.3@aar'
    compile project(':PayTabs_SDK_NOSCAN')
    compile('com.twitter.sdk.android:twitter:1.14.1@aar') {
        transitive = true;
    }
    compile('org.apache.httpcomponents:httpmime:4.3') {
        exclude module: "httpclient"
    }
    compile files('libs/signpost-core-1.2.1.2.jar')
    // Discovery and Outlook services
    compile('com.microsoft.services:discovery-services:1.0.0@aar') {
        transitive = true
    }
    compile('com.microsoft.services:outlook-services:1.0.0@aar') {
        transitive = true
    }
    compile 'org.sufficientlysecure:html-textview:3.3'
    compile 'com.android.support:appcompat-v7:25.3.1'
    compile 'com.android.support:design:25.3.1'
    compile 'com.android.support:support-v4:25.3.1'
    compile 'cz.msebera.android:httpclient:4.3.6'
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'com.nineoldandroids:library:2.4.0'
    compile 'com.daimajia.slider:library:1.1.5@aar'
    compile 'me.dm7.barcodescanner:zxing:1.8.4'
    compile 'com.google.android.gms:play-services:9.0.0'
    compile 'com.android.support:multidex:1.0.1'
    compile 'com.google.gms:google-services:3.0.0'
    compile 'com.google.android.gms:play-services-ads:9.0.0'
    compile 'com.google.android.gms:play-services-auth:9.0.0'
    compile 'com.google.android.gms:play-services-gcm:9.0.0'
    compile 'org.codepond:wizardroid:1.3.1'
    compile 'com.facebook.android:facebook-android-sdk:4.0.0'
    compile 'com.google.code.gson:gson:2.3.1'
    compile 'com.google.zxing:core:3.2.0'
    compile 'io.card:android-sdk:5.3.0'
    compile 'com.google.firebase:firebase-messaging:9.0.1'
    compile 'com.mcxiaoke.volley:library-aar:1.0.0'
    compile 'me.dm7.barcodescanner:zbar:1.8.2'
    compile 'com.journeyapps:zxing-android-embedded:3.0.2@aar'
    compile 'de.hdodenhof:circleimageview:2.0.0'
    compile 'com.cloudrail:cloudrail-si-android:2.11.0'
    compile 'org.apache.httpcomponents:httpclient-android:4.3.5.1'
    compile 'com.davemorrissey.labs:subsampling-scale-image-view:3.6.0'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    compile 'com.android.support:recyclerview-v7:25.3.1'
    compile 'com.ss.bannerslider:bannerslider:1.8.0'
    compile 'com.marshalchen.ultimaterecyclerview:library:0.7.3'
//    compile "org.jetbrains.kotlin:kotlin-stdlib-jdk7"


    testCompile 'junit:junit:4.12'
}
configurations.all {
    resolutionStrategy.eachDependency { DependencyResolveDetails details ->
        def requested = details.requested
        if (requested.group == 'com.android.support') {
            if (!requested.name.startsWith("multidex")) {
                details.useVersion '25.3.1'
            }
        }
    }
}

我尝试了所有我知道的,但目前没有任何效果。 Android Studio 和 Gradle 已更新到最新版本。该应用程序用于在更新之前运行。我按照 developer.android.com 中有关 gradle 迁移的说明进行操作,但没有提到任何可以帮助我解决问题的内容。

我在这里发布错误

Could not find org.jetbrains.kotlin:kotlin-stdlib:1.1.3-2.
Searched in the following locations:
    https://maven.fabric.io/public/org/jetbrains/kotlin/kotlin-stdlib/1.1.3-2/kotlin-stdlib-1.1.3-2.pom
    https://maven.fabric.io/public/org/jetbrains/kotlin/kotlin-stdlib/1.1.3-2/kotlin-stdlib-1.1.3-2.jar
    https://dl.google.com/dl/android/maven2/org/jetbrains/kotlin/kotlin-stdlib/1.1.3-2/kotlin-stdlib-1.1.3-2.pom
    https://dl.google.com/dl/android/maven2/org/jetbrains/kotlin/kotlin-stdlib/1.1.3-2/kotlin-stdlib-1.1.3-2.jar
Required by:
    project :app > com.android.tools.build:gradle:3.0.1 > com.android.tools.build:gradle-core:3.0.1
    project :app > com.android.tools.build:gradle:3.0.1 > com.android.tools.build:gradle-core:3.0.1 > com.android.tools.build:builder:3.0.1
    project :app > com.android.tools.build:gradle:3.0.1 > com.android.tools.build:gradle-core:3.0.1 > com.android.tools.lint:lint:26.0.1
    project :app > com.android.tools.build:gradle:3.0.1 > com.android.tools.build:gradle-core:3.0.1 > com.android.tools.build:builder:3.0.1 > com.android.tools:sdk-common:26.0.1
    project :app > com.android.tools.build:gradle:3.0.1 > com.android.tools.build:gradle-core:3.0.1 > com.android.tools.build:builder:3.0.1 > com.android.tools:sdklib:26.0.1 > com.android.tools:repository:26.0.1
    project :app > com.android.tools.build:gradle:3.0.1 > com.android.tools.build:gradle-core:3.0.1 > com.android.tools.lint:lint:26.0.1 > com.android.tools.lint:lint-checks:26.0.1 > com.android.tools.lint:lint-api:26.0.1

【问题讨论】:

标签: android maven android-gradle-plugin build.gradle android-studio-3.1


【解决方案1】:

您可以尝试更新您的 Kotlin 版本,也可以将 https://maven.google.com 添加到 allProjects 的存储库标签中。

您的项目级 build.gradle 之后应该如下所示:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
   ext.kotlin_version = '1.2.30'
   repositories {
      jcenter()
      google()
   }
   dependencies {
      classpath 'com.android.tools.build:gradle:3.1.0'
      classpath 'com.google.gms:google-services:3.1.0'
      classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
      classpath 'com.loopj.android:android-async-http:1.4.9'
   }
}

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

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

除此之外,尝试清理项目并手动删除您的 .gradle 文件夹

【讨论】:

  • 这对我不起作用。我应该删除哪些所有 .gradle 文件夹?
  • 在您的项目目录中有一个.gradle 文件夹,如果这不起作用,您可以尝试删除用户主目录中的 .gradle 文件夹(至少在 Windows 上)
【解决方案2】:

尝试使缓存无效(做了几次)或重新安装studio,或检查gradle-wrapper.properties distributionUrl应该是这样的:

distributionUrl=https://services.gradle.org/distributions/gradle-4.4-all.zip

【讨论】:

    【解决方案3】:

    我也遇到了同样的问题。似乎 android studio 也在寻求更新 kotlin 插件。

    转到工具 > Kotlin > 配置 Kotlin 插件更新并更新插件。 然后重启studio,它会在重启时同步gradle。

    【讨论】:

      【解决方案4】:

      1- 转到http://services.gradle.org

      2- 转到分布

      3- 点击最新的下载(我下载的是“gradle-4.6-rc-2-all.zip”)

      4- 解压或解压

      5- 在 Android Studio 中,转到文件 > 设置 > 构建、执行、部署 > Gradle > 使用本地 gradle 分发 > 然后从您的计算机中选择文件(您只需下载并解压缩)

      6- 点击确定

      7- 在 "build.gradle(Module:app)" 中确保 compileSdkVersion 和 targetSdkVersion 相同

      8- 点击立即同步

      资源:https://www.youtube.com/watch?v=q_qWUQNbFLY

      【讨论】:

        【解决方案5】:

        我找到了答案。我更改了 gradle 插件的版本。我在下面添加我的 Gradle 文件

        项目级别

        // Top-level build file where you can add configuration options common to all sub-projects/modules.
        
        buildscript {
            repositories {
                jcenter()
                maven {
                    url 'https://maven.google.com/'
                    name 'Google'
                }
            }
            dependencies {
                classpath 'com.android.tools.build:gradle:3.1.0'
                classpath 'com.google.gms:google-services:3.1.1'
                classpath 'com.loopj.android:android-async-http:1.4.9'
        
                // NOTE: Do not place your application dependencies here; they belong
                // in the individual module build.gradle files
            }
        }
        
        allprojects {
            repositories {
                jcenter()
            }
        }
        
        task clean(type: Delete) {
            delete rootProject.buildDir
        }
        

        应用级 build.gradle 文件

        apply plugin: 'com.android.application'
        apply plugin: 'io.fabric'
        apply plugin: 'com.google.gms.google-services'
        
        buildscript {
            repositories {
                maven { url 'https://maven.fabric.io/public' }
            }
        
            dependencies {
                classpath 'io.fabric.tools:gradle:1.+'
            }
        }
        
        buildscript {
            repositories {
                jcenter()
                google()
            }
            dependencies {
                classpath 'com.android.tools.build:gradle:3.0.1'
            }
        }
        
        android {
            compileSdkVersion 25
            buildToolsVersion '26.0.2'
            lintOptions {
                disable 'InvalidPackage'
            }
            defaultConfig {
                applicationId 'app.ecopon.com'
                minSdkVersion 15
                targetSdkVersion 25
                versionCode 33
                versionName "1.1.30"
                useLibrary 'org.apache.http.legacy'
                // Enabling multidex support.
                multiDexEnabled true
                vectorDrawables.useSupportLibrary = true
            }
            dexOptions {
                preDexLibraries = false
            }
            buildTypes {
                release {
                    minifyEnabled false
                    proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
                }
            }
            productFlavors {
            }
            lintOptions {
                checkReleaseBuilds false
            }
        
            packagingOptions {
                exclude 'META-INF/DEPENDENCIES'
                exclude 'META-INF/NOTICE'
                exclude 'META-INF/LICENSE'
            }
        }
        repositories {
            mavenCentral()
            jcenter()
        
            maven { url 'https://maven.fabric.io/public'
        
            }
        
            maven {
                url 'https://maven.google.com/'
                name 'Google'
            }
        }
        
        dependencies {
            compile fileTree(dir: 'libs', include: ['*.jar'])
        
        
            compile project(':android-async-http-1.4.9')
        
            //    compile 'com.daimajia.androidanimations:library:1.0.3@aar'
            compile project(':PayTabs_SDK_NOSCAN')
            compile('com.twitter.sdk.android:twitter:1.14.1@aar') {
                transitive = true;
            }
            compile('org.apache.httpcomponents:httpmime:4.3') {
                exclude module: "httpclient"
            }
            compile files('libs/signpost-core-1.2.1.2.jar')
            // Discovery and Outlook services
            compile('com.microsoft.services:discovery-services:1.0.0@aar') {
                transitive = true
            }
            compile('com.microsoft.services:outlook-services:1.0.0@aar') {
                transitive = true
            }
        
            compile 'org.sufficientlysecure:html-textview:3.3'
            compile 'com.android.support:appcompat-v7:25.3.1'
            compile 'com.android.support:design:25.3.1'
            compile 'com.android.support:support-v4:25.3.1'
            compile 'cz.msebera.android:httpclient:4.3.6'
            compile 'com.squareup.picasso:picasso:2.5.2'
            compile 'com.nineoldandroids:library:2.4.0'
            compile 'com.daimajia.slider:library:1.1.5@aar'
            compile 'me.dm7.barcodescanner:zxing:1.8.4'
            compile 'com.google.android.gms:play-services:9.0.0'
            compile 'com.android.support:multidex:1.0.1'
            compile 'com.google.gms:google-services:3.0.0'
            compile 'com.google.android.gms:play-services-ads:9.0.0'
            compile 'com.google.android.gms:play-services-auth:9.0.0'
            compile 'com.google.android.gms:play-services-gcm:9.0.0'
            compile 'org.codepond:wizardroid:1.3.1'
            compile 'com.facebook.android:facebook-android-sdk:4.0.0'
            compile 'com.google.code.gson:gson:2.3.1'
            compile 'com.google.zxing:core:3.2.0'
            compile 'io.card:android-sdk:5.3.0'
            compile 'com.google.firebase:firebase-messaging:9.0.0'
            compile 'com.mcxiaoke.volley:library-aar:1.0.0'
            compile 'me.dm7.barcodescanner:zbar:1.8.2'
            compile 'com.journeyapps:zxing-android-embedded:3.0.2@aar'
            compile 'de.hdodenhof:circleimageview:2.0.0'
            compile 'com.cloudrail:cloudrail-si-android:2.11.0'
            compile 'org.apache.httpcomponents:httpclient-android:4.3.5.1'
            compile 'com.davemorrissey.labs:subsampling-scale-image-view:3.6.0'
            compile 'com.android.support.constraint:constraint-layout:1.0.2'
            compile 'com.android.support:recyclerview-v7:25.3.1'
            compile 'com.ss.bannerslider:bannerslider:1.8.0'
            compile 'com.marshalchen.ultimaterecyclerview:library:0.7.3'
        
            compile 'com.github.barteksc:android-pdf-viewer:2.8.2'
        
        
            testCompile 'junit:junit:4.12'
        }
        configurations.all {
            resolutionStrategy.eachDependency { DependencyResolveDetails details ->
                def requested = details.requested
                if (requested.group == 'com.android.support') {
                    if (!requested.name.startsWith("multidex")) {
                        details.useVersion '25.3.1'
                    }
                }
            }
        }
        

        现在,一切正常

        【讨论】:

          【解决方案6】:

          找到了解决方案。您需要将 google() 添加到 buildscript 和 allprojects 存储库部分,如下所示:

          buildscript {
              repositories {
                  google()
                  jcenter()
              }
              dependencies {
                  classpath 'com.android.tools.build:gradle:3.1.1'
          
                  // NOTE: Do not place your application dependencies here; they belong
                  // in the individual module build.gradle files
              }
          }
          
          allprojects {
              repositories {
                  google()
                  jcenter()
              }
          }
          

          【讨论】:

          • 我在很多地方都阅读过这个解决方案,但这不起作用。
          【解决方案7】:

          将 build.gradle 的 Buildscript 部分更改为此,Actully Remove google() & jcenter()。这对我有用。

          buildscript {
          
          repositories {
              maven { url 'https://jitpack.io' }
              mavenCentral()
              maven { url "https://maven.google.com" }
          }
          
          
          dependencies {
              classpath 'com.android.tools.build:gradle:3.1.0'
          }
          }
          

          【讨论】:

          • 你应该是我们的下一任总统! 眨眼
          • 这是我的荣幸 :) @Adepoju-CondeAdesegunChris。
          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2019-07-18
          • 2014-07-03
          • 2014-04-04
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多