【发布时间】:2017-08-01 12:07:54
【问题描述】:
您好,我的问题是模拟器没有显示我的测试广告,这是我的代码。
活动
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 设备模拟器中。有什么帮助吗?
【问题讨论】:
标签: java android android-studio admob banner