实施Google Play服务时应用崩溃

时间:2018-11-24 16:16:31

标签: android-studio gradle

当我插入google play服务广告的实现以gradle时,我的应用崩溃了..而且我的依赖项看起来像这样:

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:27.1.1'
    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.google.android.gms:play-services-ads:17.1.1'
}

2 个答案:

答案 0 :(得分:0)

我拿到了那些,然后进口了...

implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:27.1.1'
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.google.android.gms:play-services-ads:17.1.1'
implementation'com.android.support:animated-vector-drawable:27.1.1'
implementation'com.android.support:customtabs:27.1.1'
implementation'com.android.support:support-media-compat:27.1.1'
implementation'com.android.support:support-v4:27.1.1'

答案 1 :(得分:0)

实施'com.google.android.gms:play-services-ads:17.1.1'后,还必须将以下内容插入AndroidManifest.xml中。

有关App ID (a-app-pub-3940256099942544~3347511713)的更多信息,请参见https://developers.google.com/admob/android/quick-start

<application
...
<meta-data
     android:name="com.google.android.gms.ads.APPLICATION_ID"
     android:value="ca-app-pub-3940256099942544~3347511713"/>
...
</application>