我长期面临这个问题,但我没有找到任何解决方案,所以我希望在这里找到它。
我为解决这个问题所做的工作:
apply plugin: 'com.google.gms.google-services'
它运行没有任何问题。 Error:FAILURE: Build failed with an exception.
出了什么问题:任务“:app:processDebugGoogleServices”执行失败。
File google-services.json is missing. The Google Services Plugin cannot function without it. Searched Location:
C:\Users\Mrwan\Desktop\QassWaNwadar\app\src\nullnull\debug\google-services.json C:\Users\Mrwan\Desktop\QassWaNwadar\app\src\debug\nullnull\google-services.json C:\Users\Mrwan\Desktop\QassWaNwadar\app\src\nullnull\google-services.json C:\Users\Mrwan\Desktop\QassWaNwadar\app\src\debug\google-services.json C:\Users\Mrwan\Desktop\QassWaNwadar\app\src\nullnullDebug\google-services.json C:\Users\Mrwan\Desktop\QassWaNwadar\app\google-services.json尝试:使用 --stacktrace 选项运行以获取堆栈跟踪。使用 --info 或 --debug 选项运行以获得更多日志输出。运行 --scan 以获得完整的见解。 在 https://help.gradle.org 获得更多帮助
6 秒内构建失败
Gradle 模块应用程序apply plugin: 'com.android.application' android { compileSdkVersion 27 buildToolsVersion '27.0.3' defaultConfig { applicationId "com.date.brian.cradletest" minSdkVersion 15 targetSdkVersion 27 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } } dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation 'com.android.support:appcompat-v7:26.1.0' implementation 'com.android.support.constraint:constraint-layout:1.1.0' implementation 'com.android.support:design:26.1.0' implementation 'com.android.support:cardview-v7:26.1.0' implementation 'com.android.support:recyclerview-v7:26.1.0' implementation 'com.getbase:floatingactionbutton:1.9.0' implementation 'de.hdodenhof:circleimageview:2.1.0' implementation 'com.google.android.gms:play-services-ads:15.0.1' testImplementation 'junit:junit:4.12' } apply plugin: 'com.google.gms.google-services'
最佳答案
apply plugin: 'com.google.gms.google-services'
的目的是为您启用的服务所需的基本库添加依赖项。
由于您已经包含了implementation 'com.google.android.gms:play-services-ads:15.0.1'
你实际上并不需要它。删除 apply plugin: 'com.google.gms.google-services'
应该按您的预期工作。
如果您想继续使用 apply plugin: 'com.google.gms.google-services'
然后,正如错误所说:
File google-services.json is missing.
你是
missing google-services.json
该文件通常放在 app/目录中(位于 Android Studio 应用模块的根目录)。你可以关注这个official document正确添加此文件。注:
还要确保您的所有支持库共享相同的版本。
关于android - 失败 : Build failed with an exception gradle,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50413478/