【问题标题】:Android gradle sync issueAndroid gradle 同步问题
【发布时间】:2017-12-05 23:41:28
【问题描述】:

此应用程序运行良好,没有任何问题。突然我看到了这个 gradle 同步问题。我真的被卡住了,需要帮助。现在要做什么?我已经从 SDK 管理器卸载并重新安装了 android 支持存储库。

C:\Users\DELL\AndroidStudioProjects\Prokriti\app\build.gradle
    Error:Error:Failed to resolve: com.android.support:support-annotations:27.0.1
Install Repository and sync project
    Error:Error:Failed to resolve: com.android.support:appcompat-v7:27.0.1
Install Repository and sync project
    Error:Error:Failed to resolve: com.android.support:customtabs:27.0.1
Install Repository and sync project
    Error:Error:Failed to resolve: com.android.support:cardview-v7:27.0.1
Install Repository and sync project
    Error:Error:Failed to resolve: com.android.support:support-v4:27.0.1
Install Repository and sync project
    Error:Error:Failed to resolve: com.android.support:support-core-utils:27.0.1
Install Repository and sync project

build.gradle(应用程序)

apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion "26.0.1"
    defaultConfig {
        applicationId "com.avtro.prokriti.prokriti"
        minSdkVersion 16
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        multiDexEnabled true

    }
    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })


    compile 'com.android.support:appcompat-v7:25.3.1'
    compile 'com.android.support:cardview-v7:25.3.1'
    compile 'com.android.support:design:25.3.1'
    compile 'com.android.support:support-core-utils:25.3.1'
    compile 'com.android.support:support-annotations:25.3.1'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    compile 'com.google.android.gms:play-services-auth:11.0.4'
    compile 'com.google.firebase:firebase-core:11.0.2'
    compile 'com.google.firebase:firebase-messaging:11.0.2'
    compile 'com.google.firebase:firebase-database:11.0.2'
    compile 'com.google.firebase:firebase-auth:11.0.2'
    compile 'com.google.firebase:firebase-ads:11.0.2'
    compile 'com.afollestad.material-dialogs:core:0.9.4.5'
    compile 'com.wang.avi:library:2.1.3'
    compile 'com.google.android.gms:play-services-ads:11.0.4'
    compile 'de.hdodenhof:circleimageview:2.1.0'
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'com.survivingwithandroid:weatherlib:1.6.0'
    compile 'com.amitshekhar.android:android-networking:1.0.0'
    compile 'com.android.support:multidex:1.0.1'
    compile 'com.squareup.okhttp:okhttp:2.0.0'
    compile 'com.facebook.android:facebook-android-sdk:[4,5)'
    compile 'com.google.firebase:firebase-storage:11.0.2'
    androidTestCompile 'junit:junit:4.12'
    compile 'javax.inject:javax.inject:1'
    compile 'com.android.support:support-v4:25.3.1'
    compile 'com.github.bumptech.glide:glide:3.8.0'
}
apply plugin: 'com.google.gms.google-services'

build.gradle(项目)

buildscript {
    repositories {
        jcenter()
    }
dependencies {
        classpath 'com.android.tools.build:gradle:2.3.3'
        classpath 'com.google.gms:google-services:3.0.0'
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

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

我没有更新 android studio 或 gradle。 Android 支持存储库已安装。

【问题讨论】:

  • 尝试将您的所有 firebase 和 gas 依赖项更改为 11.0.4 编辑:刚刚看到您的图像截图,我知道之前一切都很好,所以您可以做一个无效缓存并重新启动 android studio。如果仍然存在,请尝试将您的构建工具版本更改为 27.0.1。
  • 没有解决....需要帮助
  • 我们也面临同样的问题。你能解决这个问题吗?
  • 面临同样的问题。从这开始到现在只有 2 个小时。有希望吗?
  • @Emil Pradeep 试试 usere9060393 给出的答案。这解决了我的问题

标签: android gradle


【解决方案1】:

我通过删除来解决问题

 compile 'com.facebook.android:facebook-android-sdk:[4,5)'

并添加

compile 'com.facebook.android:facebook-android-sdk:4.26.0'

【讨论】:

  • 没有解决问题,Error:(49, 13) Failed to resolve: com.facebook.android:facebook-login:4.26.0
  • 谢谢,通过删除 compile 'com.facebook.android:facebook-login:[4,5)' 并更改为 compile 'com.facebook.android:facebook-android-sdk:4.26.0' 解决了
  • 通过@usere9060393 的回答解决了我的问题。非常感谢你.....但我想知道为什么 FB sdk 会导致这种情况以及为什么会发生这种情况?我的意思是它工作正常.....
  • 有时是compile 'com.facebook.android:facebook-android-sdk:4.+'。将其更改为 compile 'com.facebook.android:facebook-android-sdk:4.26.0'
  • 字面上花了一整天的时间来解决这个问题,非常感谢!!!
【解决方案2】:

您只需要更改一行。

已通过更新 facebook sdk 版本修复


编译'com.facebook.android:facebook-android-sdk:[4,5)'

编译'com.facebook.android:facebook-android-sdk:4.26.0'

【讨论】:

  • 这对我也有用,你怎么知道是 FB?
【解决方案3】:

'com.facebook.android:facebook-android-sdk:[4,5)'

'com.facebook.android:facebook-android-sdk:4.+'

上面替换为下面

'com.facebook.android:facebook-android-sdk:4.26.0'

【讨论】:

    【解决方案4】:

    替换

    compile 'com.facebook.android:facebook-android-sdk:[4,5)'
    

    通过

    compile 'com.facebook.android:facebook-android-sdk:4.26.0'
    

    希望它会起作用

    【讨论】:

      【解决方案5】:

      buildscript.repositoriesallprojects.repositories 中添加google()

      buildscript {
          repositories {
              google()
              jcenter()
          }
      dependencies {
              classpath 'com.android.tools.build:gradle:2.3.3'
              classpath 'com.google.gms:google-services:3.0.0'
          }
      }
      
      allprojects {
          repositories {
              google()
              jcenter()
          }
      }
      
      task clean(type: Delete) {
          delete rootProject.buildDir
      }
      

      这应该可以解决您的问题。

      【讨论】:

      • 请注意,此快捷方式仅在 Gradle 4.1 之后可用!否则你必须使用: // 如果你使用的是低于 4.1 的 Gradle 版本,你必须使用:maven { url 'maven.google.com' }
      【解决方案6】:
      Its work for me
      Its work for me
      Update Android SDK Build -Tools and SDK platforms
      Changed in project build file.
      buildscript {
          repositories {
              jcenter()
              maven {
                  url "https://maven.google.com"
              }
          }
      }
      
      allprojects {
          repositories {
              jcenter()
              maven {
                  url "https://maven.google.com"
              }
          }
      }
      changed in app build file
      compileSdkVersion 26
      buildToolsVersion "26.0.2"
      Disable dependencies inspection.
      compile 'com.android.support:design:25.3.1
      

      【讨论】:

        【解决方案7】:

        使用这个

        repositories {
                maven { url 'https://maven.google.com/' }
            }
        

        【讨论】:

          【解决方案8】:

          对于 react-native 项目:将 maven 存储库添加到您的项目中。 (在添加 maven repo 链接后移除 react-native-fbsdk 错误)。

          buildscript {
              repositories {
                 jcenter()
                 mavenCentral()
                 maven {            // Add this block
                    url "https://maven.google.com"
                 }
              }
          }
          
          allprojects {
              repositories {
                  mavenLocal()
                  jcenter()
                  maven {
                      // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
                      url "$rootDir/../node_modules/react-native/android"
                  }
          
                  // If something is not found from above maven repo.
                  maven { url 'https://maven.google.com' }    // Add this block 
              }
          }
          

          更多信息here

          【讨论】:

            【解决方案9】:

            不要

            compile 'com.facebook.android:facebook-android-sdk:[4,5)'
            

            根据Facebook SDK for Android,你应该使用

             // Facebook Android SDK (everything)
              compile 'com.facebook.android:facebook-android-sdk:4.+'
            

            更新案例阅读Changelog and release notes for the Facebook SDK for Android.

            compile 'com.facebook.android:facebook-android-sdk:4.26.0'
            compile 'com.facebook.android:facebook-android-sdk:4.27.0'
            compile 'com.facebook.android:facebook-android-sdk:4.28.0'
            compile 'com.facebook.android:facebook-android-sdk:4.29.0'
            

            【讨论】:

              猜你喜欢
              • 2017-12-29
              • 1970-01-01
              • 2022-12-02
              • 2019-09-25
              • 1970-01-01
              • 1970-01-01
              • 2016-06-28
              • 2022-12-12
              • 1970-01-01
              相关资源
              最近更新 更多