Ads not showing Unity Android - Initialisation Problem

379 views
Skip to first unread message

Haris M

unread,
Dec 19, 2022, 7:14:18 AM12/19/22
to Google Mobile Ads SDK Developers
Hey there,
I run into an issue where I build my Unity game to android with Google Admob integrated and it does not show ads. I have used the logcat to find out that there is some sort of issue with the initialisation of the ad network. I have been struggling to find a solution to this issue and would greatly appreciate some assistance.

Here is the error that I receive in logcat:
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.ads.initialization.OnInitializationCompleteListener" on path: DexPathList[[zip file "/data/app/PACKAGENAME-GTuKFd6EQmpWzLn9EuZ6hw==/base.apk", zip file "/data/app/PACKAGENAME-GTuKFd6EQmpWzLn9EuZ6hw==/split_config.arm

Here is my code for the ad integration:
 void Start()
    {
        // Initialize the Google Mobile Ads SDK.
        MobileAds.Initialize(initStatus => { });

        RequestInterstitial();
        RequestRewardedVideo();


    }

 private void RequestRewardedVideo()
    {

        rewardedAd = new RewardedAd(rewardedAdUnitId);

        // Called when an ad request has successfully loaded.
        rewardedAd.OnAdLoaded += HandleRewardedAdLoaded;
        // Called when an ad request failed to load.
        rewardedAd.OnAdFailedToLoad += HandleRewardedAdFailedToLoad;
        // Called when an ad is shown.
        rewardedAd.OnAdOpening += HandleRewardedAdOpening;
        // Called when an ad request failed to show.
        rewardedAd.OnAdFailedToShow += HandleRewardedAdFailedToShow;
        // Called when the user should be rewarded for interacting with the ad.
        rewardedAd.OnUserEarnedReward += HandleUserEarnedReward;
        // Called when the ad is closed.
        rewardedAd.OnAdClosed += HandleRewardedAdClosed;

        // Create an empty ad request.
        AdRequest request = new AdRequest.Builder().Build();
        // Load the rewarded ad with the request.
        rewardedAd.LoadAd(request);
    }

    private void RequestInterstitial()
    {

        // Initialize an InterstitialAd.
        interstitial = new InterstitialAd(interstitialAdUnitId);
        // Create an empty ad request.
        AdRequest request = new AdRequest.Builder().Build();
        // Load the interstitial with the request.
        interstitial.LoadAd(request);
    }

Thanks in advance!

Mobile Ads SDK Forum Advisor

unread,
Dec 19, 2022, 3:14:06 PM12/19/22
to harisdoe...@gmail.com, google-adm...@googlegroups.com
Hi Haris,

Thank you for reaching out to us.

As per checking, this has been reported by other publisher as well. The publisher mentioned that they were able to resolved the issue by following this guidance. With that, we would recommend to check it on your end, and get back to us if you still encounter the issue.

Regards,
Google Logo
Teejay Wennie
Mobile Ads SDK Team
 


ref:_00D1U1174p._5004Q2hLOeS:ref

Haris M

unread,
Dec 19, 2022, 9:09:46 PM12/19/22
to Google Mobile Ads SDK Developers
Hey there,
I assumed this solution was to uncheck all settings under minify as I didn't see anything to do with "proguard" in the publishing settings. So I attempted this however the build fails when I uncheck "Use R8" and "Release" under the "minify" section of the Publishing Player settings. To clarify, I press build and it starts and goes for a while before it throws me a build failure pop-up telling me that the details are in the console. It gives me multiple messages in the console.

The errors are as follows:
Error 1
Starting a Gradle Daemon, 1 incompatible and 1 stopped Daemons could not be reused, use --status for details

> Configure project :launcher
WARNING: The option setting 'android.enableR8=false' is deprecated.
It will be removed in version 5.0 of the Android Gradle plugin.
You will no longer be able to disable R8

Error 2
error processing C:\Users\username\.gradle\caches\transforms-2\files-2.1\40a5c5778e44c6cefe581fe0507a8adc\googlemobileads-unity-runtime.jar
java.lang.UnsupportedOperationException: This feature requires ASM7
    at org.objectweb.asm.ClassVisitor.visitNestHost(ClassVisitor.java:150)
    at org.objectweb.asm.ClassReader.accept(ClassReader.java:541)
    at org.objectweb.asm.ClassReader.accept(ClassReader.java:391)
    at com.android.builder.desugaring.DesugaringClassAnalyzer.analyze(DesugaringClassAnalyzer.java:153)
    at com.android.builder.desugaring.DesugaringClassAnalyzer.analyzeJar(DesugaringClassAnalyzer.java:100)
    at com.android.builder.desugaring.DesugaringClassAnalyzer.analyze(DesugaringClassAnalyzer.java:68)
    at com.android.build.gradle.internal.tasks.DesugarIncrementalHelper.lambda$getInitalGraphData$4(DesugarIncrementalHelper.java:146)
    at java.util.concurrent.ForkJoinTask$AdaptedCallable.exec(ForkJoinTask.java:1424)
    at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
    at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
    at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)
    at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':launcher:dexBuilderRelease'.
> java.lang.UnsupportedOperationException: This feature requires ASM7

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 23s
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8

UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)

Error 3
CommandInvokationFailure: Gradle build failed.
C:\Program Files\Unity\Hub\Editor\2021.3.10f1\Editor\Data\PlaybackEngines\AndroidPlayer\OpenJDK\bin\java.exe -classpath "C:\Program Files\Unity\Hub\Editor\2021.3.10f1\Editor\Data\PlaybackEngines\AndroidPlayer\Tools\gradle\lib\gradle-launcher-6.1.1.jar" org.gradle.launcher.GradleMain "-Dorg.gradle.jvmargs=-Xmx4096m" "bundleRelease"
FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':launcher:dexBuilderRelease'.
> java.lang.UnsupportedOperationException: This feature requires ASM7

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 23s
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8
]
stdout[
Starting a Gradle Daemon, 1 incompatible and 1 stopped Daemons could not be reused, use --status for details

> Configure project :launcher
WARNING: The option setting 'android.enableR8=false' is deprecated.
It will be removed in version 5.0 of the Android Gradle plugin.
You will no longer be able to disable R8

Error 4
Build completed with a result of 'Failed' in 193 seconds (192959 ms)
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)

Note: This build failure only occurs when I uncheck the "use R8" and "Release" in publishing settings. If I have them checked the build completes and gives the outcome as stated in my initial email.

Regards,
Haris

Mobile Ads SDK Forum Advisor

unread,
Dec 20, 2022, 2:42:43 AM12/20/22
to harisdoe...@gmail.com, google-adm...@googlegroups.com

Hi Haris,

 

Thank you for your response.

 

With regard to the error you've encountered, can you try to go to Unity->Preferences->External Tools and disable(uncheck) the JDK,Android SDK,Android NDK, Grandle. Then, close your project, reopen and checked again the following android configuration that you've unchecked? If this still returns an error, kindly provide us your project file so that we can further check it in our end. You can provide it via reply privately to author option or directly provide it to the link below.

 

If the file(s) you are looking to share are less than 25mb in total you can attach them to this case on your next reply. If you are having trouble attaching your file to this case or if your file(s) are larger than 25mb, you can share your files with me by performing the following steps:

 

1. Navigate to

https://docs.google.com/forms/d/e/1FAIpQLSfkAiXMeYP-fw1W3Z-tT9uwmATEKO5X6S-th0gR2ezdKaaqfg/viewform?usp=pp_url&entry.400550049=Mobile+Ads+SDK&entry.460850823=5004Q00002hLOeSQAW&entry.80707362=00161070

2. Fill out all fields, and attach your file(s).

3. Please reply back on this thread when you have uploaded your file(s). Please do not share this link.

 

Regards,

Google Logo
Princess Pamela
Mobile Ads SDK Team
 


ref:_00D1U1174p._5004Q2hLOeS:ref
Reply all
Reply to author
Forward
0 new messages