这是我第一次使用Firebase,我已经完成了Firebase for android提供的视频和文档中的每一步,但是当我运行我的项目时,我遇到了这个错误。
Information:Gradle tasks [:app:assembleDebug]
Could not find google-services.json while looking in [src/nullnull/debug, src/debug/nullnull, src/nullnull, src/debug, src/nullnullDebug]
Could not find google-services.json while looking in [src/nullnull/release, src/release/nullnull, src/nullnull, src/release, src/nullnullRelease]
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:checkDebugManifest
:app:preReleaseBuild UP-TO-DATE
:app:prepareComAndroidSupportAnimatedVectorDrawable2421Library UP-TO-DATE
:app:prepareComAndroidSupportAppcompatV72421Library UP-TO-DATE
:app:prepareComAndroidSupportSupportCompat2520Library UP-TO-DATE
:app:prepareComAndroidSupportSupportCoreUi2520Library UP-TO-DATE
:app:prepareComAndroidSupportSupportCoreUtils2520Library UP-TO-DATE
:app:prepareComAndroidSupportSupportFragment2520Library UP-TO-DATE
:app:prepareComAndroidSupportSupportMediaCompat2520Library UP-TO-DATE
:app:prepareComAndroidSupportSupportV42520Library UP-TO-DATE
:app:prepareComAndroidSupportSupportVectorDrawable2421Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesBasement1180Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesBasementLicense1180Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesTasks1180Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesTasksLicense1180Library UP-TO-DATE
:app:prepareComGoogleFirebaseFirebaseAnalytics1180Library UP-TO-DATE
:app:prepareComGoogleFirebaseFirebaseAnalyticsImpl1180Library UP-TO-DATE
:app:prepareComGoogleFirebaseFirebaseAnalyticsImplLicense1180Library UP-TO-DATE
:app:prepareComGoogleFirebaseFirebaseAnalyticsLicense1180Library UP-TO-DATE
:app:prepareComGoogleFirebaseFirebaseCommon1180Library UP-TO-DATE
:app:prepareComGoogleFirebaseFirebaseCommonLicense1180Library UP-TO-DATE
:app:prepareComGoogleFirebaseFirebaseCore1180Library UP-TO-DATE
:app:prepareComGoogleFirebaseFirebaseFirestore1180Library UP-TO-DATE
:app:prepareComGoogleFirebaseFirebaseIid1180Library UP-TO-DATE
:app:prepareComGoogleFirebaseFirebaseIidLicense1180Library UP-TO-DATE
:app:prepareDebugDependencies
:app:compileDebugAidl UP-TO-DATE
:app:compileDebugRenderscript UP-TO-DATE
:app:generateDebugBuildConfig UP-TO-DATE
:app:mergeDebugShaders UP-TO-DATE
:app:compileDebugShaders UP-TO-DATE
:app:generateDebugAssets UP-TO-DATE
:app:mergeDebugAssets UP-TO-DATE
:app:generateDebugResValues UP-TO-DATE
:app:processDebugGoogleServices
Parsing json file: C:\Users\myPc\AndroidStudioProjects\Try\app\google-services.json
:app:generateDebugResources
:app:mergeDebugResources UP-TO-DATE
:app:processDebugManifest UP-TO-DATE
:app:processDebugResources UP-TO-DATE
:app:generateDebugSources UP-TO-DATE
:app:incrementalDebugJavaCompilationSafeguard
:app:compileDebugJavaWithJavac
:app:compileDebugJavaWithJavac - is not incremental (e.g. outputs have changed, no previous execution, etc.).
:app:compileDebugNdk UP-TO-DATE
:app:compileDebugSources
:app:prePackageMarkerForDebug
:app:transformClassesWithDexForDebug
To run dex in process, the Gradle daemon needs a larger heap.
It currently has approximately 910 MB.
For faster builds, increase the maximum heap size for the Gradle daemon to more than 2048 MB.
To do this set org.gradle.jvmargs=-Xmx2048M in the project gradle.properties.
For more information see https://docs.gradle.org/current/userguide/build_environment.html
:app:mergeDebugJniLibFolders UP-TO-DATE
:app:transformNative_libsWithMergeJniLibsForDebug UP-TO-DATE
:app:processDebugJavaRes UP-TO-DATE
:app:transformResourcesWithMergeJavaResForDebug FAILED
Error:Execution failed for task ':app:transformResourcesWithMergeJavaResForDebug'.
com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK META-INF/maven/com.squareup.okhttp/okhttp/pom.xml
File1: C:\Users\myPc\.gradle\caches\modules-2\files- 2.1\com.squareup.okhttp\okhttp\2.7.2\20f6463eb19ac61960c5d91a094c2f4f0727dc2e\okhttp-2.7.2.jar
File2: C:\Users\myPc\AndroidStudioProjects\Try\app\build\intermediates\exploded-aar\com.google.firebase\firebase-firestore\11.8.0\jars\classes.jar
Information:BUILD FAILED
Information:Total time: 1 mins 1.894 secs
Information:1 error
Information:0 warnings
Information:See complete output in console
我添加了所需的路径和依赖项:
这是我的build.gradle(项目:尝试)
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.2'
classpath 'com.google.gms:google-services:3.2.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
maven {
url 'https://maven.google.com'
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
这是我的build.gradle(模块:app)
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "25.0.3"
defaultConfig {
applicationId "com.salmasamy.trytrytry"
minSdkVersion 19
targetSdkVersion 24
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:24.2.1'
compile 'com.google.firebase:firebase-core:11.8.0'
compile 'com.google.firebase:firebase-firestore:11.8.0'
}
apply plugin: 'com.google.gms.google-services'
我还在 project-> app 文件夹中添加了 google-services.json 文件,并确保没有多余的空间,并且我有谷歌播放具有正确版本的服务和谷歌存储库。
当我构建项目时,一切都很好,但是只有在我运行它时才能得到它。
答案 0 :(得分:1)
因为你应该使用gradle 3。+
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath 'com.google.gms:google-services:3.1.1'
}
}
allprojects {
repositories {
maven { url 'https://maven.google.com' }
jcenter()
}
}