android 清单中所需的元数据标记不存在。应用程序在 MobileAds.initialize() 时崩溃;
A required meta data tag in your android manifest does not exist. App crash at MobileAds.initialize();
尝试在我的应用程序实例中初始化 admob sdk 时出现以下问题。当我们添加时发生,
android:name=".MyApplication" in AndroidManifest.xml <应用程序标签
例外情况,MobileAds.initialize( this, new OnInitializationCompleteListener() { @Override public void onInitializationComplete( @NonNull InitializationStatus initializationStatus) {} });
注意:如果我在 activity 级别初始化相同内容,则未发现任何问题。
'W/System.err: com.google.android.gms.common.GooglePlayServicesMissingManifestValueException: A required meta-data tag in your app's AndroidManifest.xml does not exist. You must have the following declaration within the <application> element: <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />'
E/MetadataValueReader: This should never happen.
android.content.pm.PackageManager$NameNotFoundException:
at android.app.ApplicationPackageManager.getApplicationInfoAsUser(ApplicationPackageManager.java:461)
at android.app.ApplicationPackageManager.getApplicationInfo(ApplicationPackageManager.java:450)
at com.google.android.gms.common.wrappers.PackageManagerWrapper.getApplicationInfo(com.google.android.gms:play-services-basement@@17.6.0:1)
at com.google.android.gms.common.internal.zzaf.zzc(com.google.android.gms:play-services-basement@@17.6.0:4)
at com.google.android.gms.common.internal.zzaf.zzb(com.google.android.gms:play-services-basement@@17.6.0:1)
at com.google.android.gms.common.GooglePlayServicesUtilLight.isGooglePlayServicesAvailable(com.google.android.gms:play-services-basement@@17.6.0:7)
at com.google.android.gms.common.GoogleApiAvailabilityLight.isGooglePlayServicesAvailable(com.google.android.gms:play-services-basement@@17.6.0:2)
at com.google.android.gms.internal.ads.zzcfz.zzn(com.google.android.gms:play-services-ads-lite@@20.4.0:2)
at com.google.android.gms.internal.ads.zzbei.zzd(com.google.android.gms:play-services-ads-lite@@20.4.0:2)
at com.google.android.gms.internal.ads.zzbhj.zzw(com.google.android.gms:play-services-ads-lite@@20.4.0:3)
at com.google.android.gms.internal.ads.zzbhj.zzb(com.google.android.gms:play-services-ads-lite@@20.4.0:8)
at com.google.android.gms.ads.MobileAds.initialize(com.google.android.gms:play-services-ads-lite@@20.4.0:3)
at com.example.MyApplication.onCreate(MyApplication.java:31)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1192)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:7249)
at android.app.ActivityThread.access00(ActivityThread.java:294)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2168)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:264)
at android.app.ActivityThread.main(ActivityThread.java:8245)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:632)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1049)
2021-10-18 20:10:04.690 27613-27640/com.example E/AndroidRuntime: FATAL EXCEPTION: pool-3-thread-1
Process: com.example, PID: 27613
java.lang.SecurityException: Permission Denial: getIntentSender() from pid=27613, uid=11251, (need uid=-1) is not allowed to send as package
at android.os.Parcel.createExceptionOrNull(Parcel.java:2389)
at android.os.Parcel.createException(Parcel.java:2373)
at android.os.Parcel.readException(Parcel.java:2356)
at android.os.Parcel.readException(Parcel.java:2298)
at android.app.IActivityManager$Stub$Proxy.getIntentSenderWithFeature(IActivityManager.java:6832)
at android.app.PendingIntent.getBroadcastAsUser(PendingIntent.java:584)
at android.app.PendingIntent.getBroadcast(PendingIntent.java:567)
at androidx.work.impl.utils.ForceStopRunnable.getPendingIntent(ForceStopRunnable.java:174)
at androidx.work.impl.utils.ForceStopRunnable.isForceStopped(ForceStopRunnable.java:108)
at androidx.work.impl.utils.ForceStopRunnable.run(ForceStopRunnable.java:86)
at androidx.work.impl.utils.SerialExecutor$Task.run(SerialExecutor.java:75)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:923)
2021-10-18 20:10:05.895 27661-27661/? E/weather.servic: Unknown bits set in runtime_flags: 0x40000000
2021-10-18 20:10:05.900 27661-27661/? E/weather.servic: Not starting debugger since process cannot load the jdwp agent.
2021-10-18 20:10:05.910 27661-27661/? E/RefClass: java.lang.reflect.InvocationTargetException
它给出了一个错误,因为你没有添加它。
AdmobQuickStart这个link可以得到详细的安装信息
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="ca-app-pub-3940256099942544~3347511713"/>
<!-- Sample AdMob app ID: ca-app-pub-3940256099942544~3347511713 -->
请注意,永远不要将可变共享数据存储在 Application 对象中,因为该数据可能随时消失或变得无效。相反,使用文件、SharedPreferences 或 SQLite 等持久性策略存储任何可变共享数据。
https://guides.codepath.com/android/Understanding-the-Android-Application-Class
不应在应用程序中创建单例实例 class。
尝试在我的应用程序实例中初始化 admob sdk 时出现以下问题。当我们添加时发生,
android:name=".MyApplication" in AndroidManifest.xml <应用程序标签
例外情况,MobileAds.initialize( this, new OnInitializationCompleteListener() { @Override public void onInitializationComplete( @NonNull InitializationStatus initializationStatus) {} });
注意:如果我在 activity 级别初始化相同内容,则未发现任何问题。
'W/System.err: com.google.android.gms.common.GooglePlayServicesMissingManifestValueException: A required meta-data tag in your app's AndroidManifest.xml does not exist. You must have the following declaration within the <application> element: <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />'
E/MetadataValueReader: This should never happen.
android.content.pm.PackageManager$NameNotFoundException:
at android.app.ApplicationPackageManager.getApplicationInfoAsUser(ApplicationPackageManager.java:461)
at android.app.ApplicationPackageManager.getApplicationInfo(ApplicationPackageManager.java:450)
at com.google.android.gms.common.wrappers.PackageManagerWrapper.getApplicationInfo(com.google.android.gms:play-services-basement@@17.6.0:1)
at com.google.android.gms.common.internal.zzaf.zzc(com.google.android.gms:play-services-basement@@17.6.0:4)
at com.google.android.gms.common.internal.zzaf.zzb(com.google.android.gms:play-services-basement@@17.6.0:1)
at com.google.android.gms.common.GooglePlayServicesUtilLight.isGooglePlayServicesAvailable(com.google.android.gms:play-services-basement@@17.6.0:7)
at com.google.android.gms.common.GoogleApiAvailabilityLight.isGooglePlayServicesAvailable(com.google.android.gms:play-services-basement@@17.6.0:2)
at com.google.android.gms.internal.ads.zzcfz.zzn(com.google.android.gms:play-services-ads-lite@@20.4.0:2)
at com.google.android.gms.internal.ads.zzbei.zzd(com.google.android.gms:play-services-ads-lite@@20.4.0:2)
at com.google.android.gms.internal.ads.zzbhj.zzw(com.google.android.gms:play-services-ads-lite@@20.4.0:3)
at com.google.android.gms.internal.ads.zzbhj.zzb(com.google.android.gms:play-services-ads-lite@@20.4.0:8)
at com.google.android.gms.ads.MobileAds.initialize(com.google.android.gms:play-services-ads-lite@@20.4.0:3)
at com.example.MyApplication.onCreate(MyApplication.java:31)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1192)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:7249)
at android.app.ActivityThread.access00(ActivityThread.java:294)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2168)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:264)
at android.app.ActivityThread.main(ActivityThread.java:8245)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:632)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1049)
2021-10-18 20:10:04.690 27613-27640/com.example E/AndroidRuntime: FATAL EXCEPTION: pool-3-thread-1
Process: com.example, PID: 27613
java.lang.SecurityException: Permission Denial: getIntentSender() from pid=27613, uid=11251, (need uid=-1) is not allowed to send as package
at android.os.Parcel.createExceptionOrNull(Parcel.java:2389)
at android.os.Parcel.createException(Parcel.java:2373)
at android.os.Parcel.readException(Parcel.java:2356)
at android.os.Parcel.readException(Parcel.java:2298)
at android.app.IActivityManager$Stub$Proxy.getIntentSenderWithFeature(IActivityManager.java:6832)
at android.app.PendingIntent.getBroadcastAsUser(PendingIntent.java:584)
at android.app.PendingIntent.getBroadcast(PendingIntent.java:567)
at androidx.work.impl.utils.ForceStopRunnable.getPendingIntent(ForceStopRunnable.java:174)
at androidx.work.impl.utils.ForceStopRunnable.isForceStopped(ForceStopRunnable.java:108)
at androidx.work.impl.utils.ForceStopRunnable.run(ForceStopRunnable.java:86)
at androidx.work.impl.utils.SerialExecutor$Task.run(SerialExecutor.java:75)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:923)
2021-10-18 20:10:05.895 27661-27661/? E/weather.servic: Unknown bits set in runtime_flags: 0x40000000
2021-10-18 20:10:05.900 27661-27661/? E/weather.servic: Not starting debugger since process cannot load the jdwp agent.
2021-10-18 20:10:05.910 27661-27661/? E/RefClass: java.lang.reflect.InvocationTargetException
它给出了一个错误,因为你没有添加它。 AdmobQuickStart这个link可以得到详细的安装信息
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="ca-app-pub-3940256099942544~3347511713"/>
<!-- Sample AdMob app ID: ca-app-pub-3940256099942544~3347511713 -->
请注意,永远不要将可变共享数据存储在 Application 对象中,因为该数据可能随时消失或变得无效。相反,使用文件、SharedPreferences 或 SQLite 等持久性策略存储任何可变共享数据。
https://guides.codepath.com/android/Understanding-the-Android-Application-Class
不应在应用程序中创建单例实例 class。