繁体   English   中英

无法在Android中同步gradle for Firebase

[英]Failed to sync the gradle for firebase in android

我试图在我无法同步gradle的项目中使用firebase sdk。我将jdk从1.7更新到了1.8,以及将google仓库,android sdk和工具更新到了最新版本,但即使我正在获取错误,因为无法加载类“ com.google.gson.JsonObject”。

项目摇篮:

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

模块摇篮:

apply plugin: 'com.android.application'

android {compileSdkVersion 23 buildToolsVersion“ 23.0.1”

defaultConfig {
    applicationId "nidhinkumar.firebaseexample"
    minSdkVersion 15
    targetSdkVersion 23
    versionCode 1
    versionName "1.0"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }

}
packagingOptions{
    exclude 'META-INF/LICENSE'
    exclude 'META-INF/LICENSE-FIREBASE.txt'
    exclude 'META-INF/NOTICE'

}
 }dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.firebase:firebase-client-android:2.4.0'
compile 'com.google.firebase:firebase-storage:9.2.1'
compile 'pub.devrel:easypermissions:0.1.9'
compile 'com.google.firebase:firebase-core:9.2.1'
compile 'com.google.firebase:firebase-auth:9.2.1'
 }
apply plugin: 'com.google.gms.google-services'

错误:

Error:Unable to load class 'com.google.gson.JsonObject'.
Possible causes for this unexpected error include:<ul><li>Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.)
  <a href="syncProject">Re-download dependencies and sync project (requires network)</a></li><li>The state of a Gradle build process (daemon) may be corrupt.  Stopping all Gradle daemons may solve this problem.
  <a href="stopGradleDaemons">Stop Gradle build processes (requires restart)</a></li></ul>In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes.

您发布的错误消息中提到了解决方案:

此意外错误的可能原因包括:

  • Gradle的依赖项缓存可能已损坏(这有时会在网络连接超时后发生。)重新下载依赖项并同步项目(需要网络)
  • Gradle构建过程(守护程序)的状态可能已损坏。 停止所有Gradle守护程序可以解决此问题。 停止Gradle构建过程(需要重新启动)
如果Gradle进程损坏,您也可以尝试关闭IDE,然后终止所有Java进程。

重新启动IDE后,还要执行File -> Invalidate Cache / Restart因为它说您的缓存已损坏。

从评论中的对话更新

应满足先决条件。 如您所述,您使用的AS 1.0.1低于Firebase的要求-AS 1.5及更高版本。 升级您的Android Studio,您应该会不错。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM