googleads-mobile-android-examples icon indicating copy to clipboard operation
googleads-mobile-android-examples copied to clipboard

Bug: Unable to use test ads for native ads on newest version of the Admob SDK (20.5.0), including on the sample

Open AndroidDeveloperLB opened this issue 2 years ago • 3 comments

implementation 'com.google.android.gms:play-services-ads:20.5.0'

On a real app, after targeting to API 30 (didn't occur when targeting API 29), I keep getting this on LogCat on a device with Android 11 :

Not retrying to fetch app settings
Update ad debug logging enablement as false
Ad failed to load : 3
Use RequestConfiguration.Builder().setTestDeviceIds(Arrays.asList("...")) to get test ads on this device.

That's even though I already added this kind of code... I even tried to use a more automatic way to add this test-device-id (here).

And as it's on debug, I use the ad units of "ca-app-pub-3940256099942544/2247696110" for image and "ca-app-pub-3940256099942544/1044960115" for video, as written here (and as used on the samples) : https://developers.google.com/admob/android/test-ads?hl=it

So, I tried to see how it works on the sample: https://github.com/googleads/googleads-mobile-android-examples/releases/tag/5.8

Thing is that it hasn't been updated for a very long time, so I tried to update it, but then I got a different error:

2022-01-10 18:08:02.739 22881-22881/com.google.android.gms.example.nativeadvancedexample E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.google.android.gms.example.nativeadvancedexample, PID: 22881
    java.lang.NoSuchMethodError: No static method metafactory(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodHandle;Ljava/lang/invoke/MethodType;)Ljava/lang/invoke/CallSite; in class Ljava/lang/invoke/LambdaMetafactory; or its super classes (declaration of 'java.lang.invoke.LambdaMetafactory' appears in /apex/com.android.art/javalib/core-oj.jar)
        at com.google.android.gms.example.nativeadvancedexample.MainActivity.onCreate(MainActivity.kt:40)
...

How can I use test-ads again, including when targeting API 30 ? And why aren't the samples updated?

Attached files of the sample, before and after the modification:

original.zip

after updating.zip

AndroidDeveloperLB avatar Jan 10 '22 16:01 AndroidDeveloperLB

BTW, using real ad-unit-id without adding test-device-ids, it works fine.

AndroidDeveloperLB avatar Jan 11 '22 07:01 AndroidDeveloperLB

implementation 'com.google.android.gms:play-services-ads:20.5.0'

On a real app, after targeting to API 30 (didn't occur when targeting API 29), I keep getting this on LogCat on a device with Android 11 :

Not retrying to fetch app settings
Update ad debug logging enablement as false
Ad failed to load : 3
Use RequestConfiguration.Builder().setTestDeviceIds(Arrays.asList("...")) to get test ads on this device.

That's even though I already added this kind of code... I even tried to use a more automatic way to add this test-device-id (here).

And as it's on debug, I use the ad units of "ca-app-pub-3940256099942544/2247696110" for image and "ca-app-pub-3940256099942544/1044960115" for video, as written here (and as used on the samples) : https://developers.google.com/admob/android/test-ads?hl=it

So, I tried to see how it works on the sample: https://github.com/googleads/googleads-mobile-android-examples/releases/tag/5.8

Thing is that it hasn't been updated for a very long time, so I tried to update it, but then I got a different error:

2022-01-10 18:08:02.739 22881-22881/com.google.android.gms.example.nativeadvancedexample E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.google.android.gms.example.nativeadvancedexample, PID: 22881
    java.lang.NoSuchMethodError: No static method metafactory(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodHandle;Ljava/lang/invoke/MethodType;)Ljava/lang/invoke/CallSite; in class Ljava/lang/invoke/LambdaMetafactory; or its super classes (declaration of 'java.lang.invoke.LambdaMetafactory' appears in /apex/com.android.art/javalib/core-oj.jar)
        at com.google.android.gms.example.nativeadvancedexample.MainActivity.onCreate(MainActivity.kt:40)
...

How can I use test-ads again, including when targeting API 30 ? And why aren't the samples updated?

Attached files of the sample, before and after the modification:

original.zip

after updating.zip

hau99 avatar Oct 05 '23 04:10 hau99

?

AndroidDeveloperLB avatar Oct 05 '23 06:10 AndroidDeveloperLB