Getting below issue when trying to initialize admob sdk in my app in application instance. happening when we add,
android:name=".MyApplication" in AndroidManifest.xml <application tag
Exception at, MobileAds.initialize( this, new OnInitializationCompleteListener() { @Override public void onInitializationComplete( @NonNull InitializationStatus initializationStatus) {} });
Note: No issues found if i initialize the same in activity level.
'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.access$1600(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
CodePudding user response:
It gives an error because you didn't add it. AdmobQuickStart this link You can get information about detailed installation.
<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 -->
CodePudding user response:
@BroscR Manifest file
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.example">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.GET_TASKS" />
<uses-permission android:name="android.permission.KILL_BACKGROUND_PROCESSES" />
<uses-permission android:name="android.permission.REQUEST_DELETE_PACKAGES" />
<uses-permission
android:name="android.permission.READ_LOGS"
tools:ignore="ProtectedPermissions" />
<uses-permission
android:name="android.permission.CHANGE_COMPONENT_ENABLED_STATE"
tools:ignore="ProtectedPermissions" />
<uses-permission
android:name="android.permission.FORCE_STOP_PACKAGES"
tools:ignore="ProtectedPermissions" />
<uses-permission android:name="android.permission.RESTART_PACKAGES" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<permission
android:name="android.permission.FORCE_STOP_PACKAGES"
android:permissionGroup="android.permission-group.SYSTEM_TOOLS"
android:protectionLevel="signature"
android:sharedUserId="android.uid.system" />
<application
android:name=".MyApplication"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<!-- Sample AdMob App ID: ca-app-pub-3940256099942544~3347511713 -->
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="ca-app-pub-3940256099942544~3347511713" />
<activity
android:name="com.example.SplashActivity"
android:exported="true"
android:noHistory="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".MainActivity"
android:exported="true" />
<activity
android:name=".base.BaseActivity"
android:exported="true"
android:theme="@style/Theme.FullScreen.StatusBar" />
<receiver
android:name="com.example.utils.Receiver"
android:enabled="true"
android:exported="true">
<!--<intent-filter>
<action android:name="com.example.UNINSTALL_INTENT" />
</intent-filter>-->
<intent-filter>
<action android:name="android.intent.action.PACKAGE_ADDED" />
<action android:name="android.intent.action.PACKAGE_REMOVED" />
<data android:scheme="package" />
</intent-filter>
</receiver>
</application>
</manifest>