skip to Main Content

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

2

Answers


  1. Chosen as BEST ANSWER

    Note that you should never store mutable shared data inside the Application object since that data might disappear or become invalid at any time. Instead, store any mutable shared data using persistence strategies such as files, SharedPreferences or SQLite.

    https://guides.codepath.com/android/Understanding-the-Android-Application-Class

    Should not create singleton instance inside Application class.


  2. 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 -->
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search