Cannot import com.google.android.gms:play-services-ads:17.1.1(无法导入 com.google.android.gms:play-services-ads:17.1.1)
问题描述
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.kaiboon0216gmail.homeownerstarterkit"
minSdkVersion 21
targetSdkVersion 28
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:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.android.support:cardview-v7:28.0.0'
implementation 'com.google.android.gms:play-services-ads:17.1.1'
}
这些是我的代码.我正在使用 Admob 在我的应用中显示广告.当我添加此代码时:"'com.google.android.gms:play-services-ads:17.1.1'" 和同步,我的应用程序崩溃了.
These are my codes.I'm using Admob to display the ads in my app.When I add this code:"'com.google.android.gms:play-services-ads:17.1.1'" and sync , my apps crash.
之后我去Admob官网发现这个版本是针对'com.android.support:appcompat-v7:26.1.0'版本的.但是当我将 compileSdkVersion 更改为 26 时,我的应用程序仍然崩溃....
After that I go to Admob official website and found that this version is for 'com.android.support:appcompat-v7:26.1.0' version. But when I change the compileSdkVersion to 26, my apps still crash....
我已经测试了没有这个代码的代码:'com.google.android.gms:play-services-ads:17.1.1'" 并且它可以运行.我确定这个代码是问题,但我不知道如何纠正它.
I have test the code without this code:"'com.google.android.gms:play-services-ads:17.1.1'" and it can run.Im sure that this code is the problem but i have no idea how to correct it.
谁能帮助解决我的问题?谢谢.
Could anyone help to solve my problem? Thank you.
推荐答案
转到 Admob - 选择应用 - 应用设置 - 应用 ID
从 App ID 复制值
现在添加这个(更改这个 android:value="paste the App ID value you copy from your admob app"
)
Now add this (change this android:value="paste the App ID value you copy from your admob app"
)
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="ca-app-pub-111100000000~1111111"/>
meta-data
到 AndroidManifest.xml
文件
无需在 android:name="com.google.android.gms.ads.APPLICATION_ID"
的 APPLICATION_ID
中添加任何内容
No need to add anything in APPLICATION_ID
from android:name="com.google.android.gms.ads.APPLICATION_ID"
这行得通!
看下图就清楚了
这篇关于无法导入 com.google.android.gms:play-services-ads:17.1.1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:无法导入 com.google.android.gms:play-services-ads:17.1.1


- Eclipse 的最佳 XML 编辑器 2022-01-01
- GC_FOR_ALLOC 是否更“严重"?在调查内存使用情况时? 2022-01-01
- 在 Java 中,如何将 String 转换为 char 或将 char 转换 2022-01-01
- 将 Java Swing 桌面应用程序国际化的最佳实践是什么? 2022-01-01
- java.lang.IllegalStateException:Bean 名称“类别"的 BindingResult 和普通目标对象都不能用作请求属性 2022-01-01
- 如何指定 CORS 的响应标头? 2022-01-01
- 未找到/usr/local/lib 中的库 2022-01-01
- 获取数字的最后一位 2022-01-01
- 转换 ldap 日期 2022-01-01
- 如何使 JFrame 背景和 JPanel 透明且仅显示图像 2022-01-01