gpt4 book ai didi

java - Android Studio 模拟器不显示测试 ADS

转载 作者:行者123 更新时间:2023-12-02 12:26:36 25 4
gpt4 key购买 nike

您好,我的问题是模拟器没有显示我的测试广告,这是我的代码

Activity

    package project.chawki.anew.enwproject;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdView;

public class MainActivity extends AppCompatActivity {
private AdView mAdView;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

mAdView = (AdView) findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder().build();
mAdView.loadAd(adRequest);
}
}

XML

<com.google.android.gms.ads.AdView
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
ads:adSize="BANNER"
ads:adUnitId="ca-app-pub-3940256099942544/6300978111">
</com.google.android.gms.ads.AdView>

Gradle

apply plugin: 'com.android.application'

android {
compileSdkVersion 26
buildToolsVersion "26.0.1"
defaultConfig {
applicationId "project.chawki.anew.enwproject"
minSdkVersion 14
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:26.+'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
compile 'com.google.android.gms:play-services-ads:11.0.4'
}

这是我得到的错误:

08-01 10:00:53.160 3210-3367/com.example.chawkii.myapplication W/Ads: There was a problem getting an ad response. ErrorCode: 0
08-01 10:00:53.160 3210-3210/com.example.chawkii.myapplication W/Ads: Failed to load ad: 0
08-01 10:01:43.200 3210-3210/com.example.chawkii.myapplication E/Ads: JS engine could not be obtained. Cancelling ad request

我正在学习开发,我看不到错误,而且权限也很好,但我的测试广告无法在 Android 设备模拟器中加载。有什么帮助吗?

最佳答案

经过大量研究,我找到了这个错误的解决方案,问题不是代码,实际上是在我的模拟器中,我必须下载最后一个 API 并将 google play 服务更新到最后一个版本,以便我可以看到广告

关于java - Android Studio 模拟器不显示测试 ADS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45437393/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com