我有一个带有admob的应用程序。 它适用于所有设备,但不能在android 8三星设备上显示广告。
它还可以使用三星的其他版本和其他品牌的所有版本,包括android 8。
我收到以下错误消息。
2018-10-12 21:21:47.508 13284-31190/? E/Ads: Error waiting for future.
java.util.concurrent.ExecutionException: java.util.concurrent.TimeoutException
at com.google.android.gms.ads.internal.util.future.af.get(:com.google.android.gms@14366015@14.3.66 (040300-213742215):18)
at com.google.android.gms.ads.internal.util.future.g.a(:com.google.android.gms@14366015@14.3.66 (040300-213742215):11)
at com.google.android.gms.ads.internal.request.service.c.a(:com.google.android.gms@14366015@14.3.66 (040300-213742215):62)
at com.google.android.gms.ads.internal.request.service.c.a(:com.google.android.gms@14366015@14.3.66 (040300-213742215):169)
at com.google.android.gms.ads.internal.request.service.f.run(:com.google.android.gms@14366015@14.3.66 (040300-213742215):1)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:457)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
at java.lang.Thread.run(Thread.java:764)
Caused by: java.util.concurrent.TimeoutException
at com.google.android.gms.ads.internal.util.future.m.run(Unknown Source:2)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:457)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:301
对于广告,我使用以下版本:
implementation 'com.google.android.gms:play-services-ads:17.0.0'
清单文件
<?xml version="1.1" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.package.app">
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application
android:allowBackup="true"
android:icon="@mipmap/icon"
android:label="@string/app_name"
android:roundIcon="@mipmap/roundicon"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".DepartmentCoursesActivity" />
<activity android:name=".ExamDetailActivity" />
<activity android:name=".AddLessonActivity" />
<activity android:name=".LoginActivity" />
<activity android:name=".CourseExamListActivity" />
<activity android:name=".ImageZoomActivity"></activity>
<!-- Sample AdMob App ID: ca-app-pub-3940256099942544~3347511713 -->
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="[MY_AD_ID]"/>
</application>
</manifest>
还有以下日志,可能与之相关
2018-10-12 21:21:46.618 1764-1764/? E/ServiceUtils: [#MLP#] Unable to get package name: android.content.pm.PackageManager$NameNotFoundException: com.samsung.ipservice (com.samsung.ipservice)
at android.app.ApplicationPackageManager.getPackageInfoAsUser (ApplicationPackageManager.java:301)
at android.app.ApplicationPackageManager.getPackageInfo (ApplicationPackageManager.java:272)
at com.samsung.mlp.platform.utils.ServiceUtils.isPackageAvailable (ServiceUtils.java:55)
at com.samsung.mlp.platform.framework.ItemFetchTask.buildImageSelectionSchema (ItemFetchTask.java:147)
at com.samsung.mlp.platform.framework.ItemFetchTask.buildMediaSelectionSchema (ItemFetchTask.java:129)
at com.samsung.mlp.platform.framework.ItemFetchTask.<init> (ItemFetchTask.java:107)
at com.samsung.mlp.platform.framework.LPServiceController.setupExecutors (LPServiceController.java:200)
at com.samsung.mlp.platform.framework.LPServiceController.<init> (LPServiceController.java:179)
at com.samsung.mlp.platform.framework.LPServiceController.getInstance (LPServiceController.java:168)
at com.samsung.mlp.platform.LPService.onBind (LPService.java:49)
at android.app.ActivityThread.handleBindService (ActivityThread.java:3571)
at android.app.ActivityThread.-wrap2 (null:0)
at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1791)
at android.os.Handler.dispatchMessage (Handler.java:105)
at android.os.Looper.loop (Looper.java:164)
at android.app.ActivityThread.main (ActivityThread.java:6944)
at java.lang.reflect.Method.invoke (Method.java:-2)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run (Zygote.java:327)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1374)
答案 0 :(得分:0)
在清单文件中添加以下代码
<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"
android:theme="@android:style/Theme.Translucent" />
希望这会起作用...!