【发布时间】:2019-11-29 22:00:41
【问题描述】:
我在使用 AdMob 和 Google Play 服务时遇到了一个问题,这让我疯狂了好几天。感觉几乎不可能完成这项工作。这个实现有什么问题?
layout.xml(下面的代码在布局的底部):
xmlns:ads="http://schemas.android.com/apk/res-auto"
...
<LinearLayout
android:id="@+id/layoutAd"
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_marginTop="5dp"
android:layout_weight="3"
android:orientation="vertical" >
<com.google.android.gms.ads.AdView
android:id="@+id/adView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
ads:adSize="BANNER"
ads:adUnitId="@string/ad_unit_id" />
</LinearLayout>
MainActivity.java:
import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdView;
import com.google.android.gms.ads.AdSize;
...
adView = (AdView)this.findViewById(R.id.adView);
AdRequest request = new AdRequest.Builder() .addTestDevice(AdRequest.DEVICE_ID_EMULATOR).
addTestDevice("9234EBAE83E894E6271DEBE7B380782E").build();
adView.loadAd(request);
AndroidManifest.xml:
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
...
<activity android:name="com.google.android.gms.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
LogCat:
Use AdRequest.Builder.addTestDevice("9234EBAE83E894E6271DEBE7B380782E") to get test ads on this device.
GooglePlayServicesUtil: The Google Play services resources were not found. Check your project configuration to ensure that the resources are included.
SQLiteLog: (14) cannot open file at line 30241 of [00bb9c9ce4]
SQLiteLog: (14) os_unix.c:30241: (2) open(/NotificationPermissions.db) -
广告永远不会出现,但如果我在模拟器上运行它,它就会出现。
我哪里错了?
【问题讨论】:
-
这是同样的问题:stackoverflow.com/questions/21382029/… .... 也许,它可以帮助!
标签: android android-emulator admob device