你好,我的问题是,模拟器不显示我的测试广告,这里是我的代码。
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>
摇篮
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.-3367/com.example.chawkii.myapplication W/Ads: There was a problem getting an ad response. ErrorCode: 0
08-01 10:00:53.-3210/com.example.chawkii.myapplication W/Ads: Failed to load ad: 0
08-01 10:01:43.-3210/com.example.chawkii.myapplication E/Ads: JS engine could not be obtained. Cancelling ad request
林学习DEVELOPPEMENT,我不能看到故障,也为他们的权限也很好,但我的测试广告不会在Android设备仿真器加载。请帮忙吗?
遵循这样@chawkii – Jai
https://developers.google.com/android/reference/com/google/android/gms/ads/AdView – Jai