无法导入com.google.android.gms:play-services-ads:17.1.1 [英] Cannot import com.google.android.gms:play-services-ads:17.1.1
问题描述
应用插件:'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'
}
}
}
依赖项{
实现fileTree(dir:'libs',include:['* .jar'])
实现'com.android.support:appcompat-v7:28.0.0'
实现'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation'junit: junit:4.12'
androidTestImplementation'com.android.support.test:runner:1.0.2'
a ndroidTestImplementation'com.android.support.test.espresso:espresso-core:3.0.2'
实现'com.android.support:cardview-v7:28.0.0'
实现'com.google。 android.gms:play-services-ads:17.1.1'
}
这些是我的代码。我正在使用Admob在我的应用中展示广告。当我添加以下代码时: 'com.google.android.gms:play-services-ads:17.1.1' 并同步,我的应用程序崩溃。
此后,我转到Admob官方网站,发现此版本适用于'com.android.support:appcompat-v7 :26.1.0'版本。但是,当我将 compileSdkVersion 更改为26时,我的应用仍然崩溃...。
我已经测试了没有以下代码的代码: 'com.google.android.gms:play-services-ads:17.1.1'并可以运行。我确定此代码是问题所在,但我不知道如何纠正。
有人可以帮助解决我的问题吗?
谢谢。
转到 Admob-选择应用-应用设置-应用ID
复制 App ID
现在添加此值(更改此 android:value =粘贴从admob应用复制的应用ID值
)
<元数据
android:name = com.google.android.gms.ads.APPLICATION_ID
android:value = ca-app-pub-111100000000〜1111111 />
元数据
到 AndroidManifest.xml
文件
无需在 APPLICATION_ID
中添加任何内容code> android:name = com.google.android.gms.ads.APPLICATION_ID
这将起作用! p>
请参阅下面的图片以获得清晰的了解
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'
}
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.
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....
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.
Go to Admob - Select App - App Setting - App ID
copy the value from App ID
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
into AndroidManifest.xml
file
No need to add anything in APPLICATION_ID
from android:name="com.google.android.gms.ads.APPLICATION_ID"
This will work!
See the picture below for clear understanding
这篇关于无法导入com.google.android.gms:play-services-ads:17.1.1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!