我很长时间都遇到这个问题而且我找不到任何解决方案,所以我希望能在这里找到它。
我为解决这个问题做了什么:
apply plugin: 'com.google.gms.google-services'
时,它会毫无问题地运行。错误:FAILURE:构建因异常而失败。
出了什么问题:任务执行失败':app:processDebugGoogleServices'。
文件google-services.json缺失。没有它,Google Services插件无法运行。搜索位置:
C:\用户\ Mrwan \桌面\ QassWaNwadar \程序\ SRC \ nullnull \调试\谷歌,services.json C:\用户\ Mrwan \桌面\ QassWaNwadar \程序\ SRC \调试\ nullnull \谷歌services.json C:\用户\ Mrwan \桌面\ QassWaNwadar \程序\ SRC \ nullnull \谷歌services.json C:\用户\ Mrwan \桌面\ QassWaNwadar \程序\ SRC \调试\谷歌,services.json C:\用户\ Mrwan \桌面\ QassWaNwadar \程序\ SRC \ nullnullDebug \谷歌services.json C:\用户\ Mrwan \桌面\ QassWaNwadar \应用\谷歌-services.json尝试:使用--stacktrace选项运行以获取堆栈跟踪。使用--info或--debug选项运行以获取更多日志输出。使用--scan运行以获得全面的见解。
- 获取更多帮助
在6s内建立失败
Gradle Module app
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'
答案 0 :(得分:1)
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'
,则会出现错误:
文件google-services.json缺失。
您是missing google-services.json
文件,通常放在app /目录中(位于Android Studio应用模块的根目录下)。您可以按照此official document正确添加此文件。
注意:强> 还要确保所有支持库共享相同的版本。