2

Without changing any code between Android Oreo and Android P, when I try to to get the advertisingID in the following fashion:

 Thread backgroundWorker = new Thread(new Runnable(
 {
    @Override
    public void run()
    {
         try
         { 

            AdvertisingIdClient.Info adInfo = AdvertisingIdClient.getAdvertisingIdInfo(appContext);

           if (adInfo != null){
               Log.d(“some tag”,adInfo.getId());
           }

        } 
        catch (IllegalStateException e){} 
        catch (GooglePlayServicesRepairableException e){}
        catch (IOException e){}
        catch (GooglePlayServicesNotAvailableException e){}
        catch (SecurityException e){}
});

I get the following SecurityException on Android P, I do not have any SharedPrefs declared in my manifest or otherwise:

05-22 15:01:14.590 18536-22301/com.someapp.mobilesdktest W/AdvertisingIdClient: Error while reading from SharedPreferences java.lang.SecurityException: MODE_WORLD_READABLE no longer supported at android.app.ContextImpl.checkMode(ContextImpl.java:2453) at android.app.ContextImpl.getSharedPreferences(ContextImpl.java:389) at android.app.ContextImpl.getSharedPreferences(ContextImpl.java:376) at com.google.android.gms.ads.identifier.AdvertisingIdClient.getAdvertisingIdInfo(Unknown Source:12) at com.someapp.SomeFile$58.run(SomeFile.java:3607) at java.lang.Thread.run(Thread.java:764)

When I try to print any SharedPrefs via SharedPreferences prefs.getAll() it is empty... How do I change this to MODE_PRIVATE since this a getAdvertisingIdInfo() is a method in the play-services-basement package and it tries to call getSharedPreferences("google_ads_flags", 1);

neuman8
  • 324
  • 4
  • 15

1 Answers1

1

So I upgraded to com.google.android.gms:play-services-ads:12.0.1 and the exception is gone.

neuman8
  • 324
  • 4
  • 15