AppLovin / AppLovin-MAX-SDK-Android

Other
210 stars 95 forks source link

Crash: java.lang.NoSuchMethodError: No virtual method addNetworkExtrasBundle(Ljava/lang/Class;Landroid/os/Bundle;) #637

Open tracer8 opened 3 months ago

tracer8 commented 3 months ago

MAX SDK Version

12.3.1

Device/Platform Info

Any device

Current Behavior

Crash with this error when show Collapsible Banner of Google ads, use MAX SDK and Google Mobile Ads together: java.lang.NoSuchMethodError: No virtual method addNetworkExtrasBundle(Ljava/lang/Class;Landroid/os/Bundle;)Lcom/google/android/gms/ads/AbstractAdRequestBuilder; in class Lcom/google/android/gms/ads/AdRequest$Builder; or its super classes (declaration of 'com.google.android.gms.ads.AdRequest$Builder'

Expected Behavior

On version 12.3.0, Collapsible Banner of Google Ads will show success without any issue.

How to Reproduce

Gradle:

implementation 'com.applovin:applovin-sdk:12.3.1'
implementation 'com.applovin.mediation:google-adapter:+'

I am use MAX and Google ads together, Google Mobile Ads to show Collapsible banner. Before version 12.3.1, everything is good, but after upgrade to 12.3.1, the error cause of crash show up "java.lang.NoSuchMethodError: No virtual method addNetworkExtrasBundle"

You can try to show GMA collapsible with this code try on both version to see the error

MobileAds.initialize(context, new OnInitializationCompleteListener() {
            @Override
            public void onInitializationComplete(InitializationStatus initializationStatus) {
            }
        });

private AdView mAdView;
    public void LoadBanner(Activity activity, ViewGroup container) {
        Log.d("ADMOB", "Try to load banner");
        this.mAdView = new AdView(activity);
        this.mAdView.setAdSize(this.getAdSize(activity, container));
        this.mAdView.setAdUnitId("ca-app-pub-3940256099942544/8388050270"); // test id already
        container.removeAllViews();
        container.setVisibility(View.VISIBLE);
        container.addView(this.mAdView);
        Bundle extras = new Bundle();
        extras.putString("collapsible", "bottom");
        AdRequest adRequest = ((AdRequest.Builder)(new AdRequest.Builder()).addNetworkExtrasBundle(AdMobAdapter.class, extras)).build();
        this.mAdView.loadAd(adRequest);
        this.mAdView.setAdListener(new AdListener() {
            public void onAdClicked() {
            }

            public void onAdClosed() {
            }

            public void onAdFailedToLoad(LoadAdError adError) {
                Log.d("ADMOB", "Banner fail to load: " + adError);
            }

            public void onAdImpression() {
                Log.d("ADMOB", "Banner impression");
            }

            public void onAdLoaded() {
                Log.d("ADMOB", "Banner loaded");
            }

            public void onAdOpened() {
            }
        });
    }

    private AdSize getAdSize(Activity activity, View adContainerView) {
        Display display = activity.getWindowManager().getDefaultDisplay();
        DisplayMetrics outMetrics = new DisplayMetrics();
        display.getMetrics(outMetrics);
        float widthPixels = (float)outMetrics.widthPixels;
        float density = outMetrics.density;
        int adWidth = (int)(widthPixels / density);
        return AdSize.getCurrentOrientationAnchoredAdaptiveBannerAdSize(activity, adWidth);
    }

Additional Info

No response

tracer8 commented 3 months ago

@alvarshahanji @thomasmso @santoshbagadi please check it out, thanks!

thomasmso commented 3 months ago

@tracer8 - This is likely a mismatch of AdMob adapter and SDK version. Could you send a screenshot of the Mediation Debugger so we can check that?

tracer8 commented 3 months ago

Screenshot_2024-03-20 11 31 50_001 Here is my adapters

thomasmso commented 3 months ago

And are you able to reproduce this locally when forcing AdMob live or test ads?

tracer8 commented 3 months ago

And are you able to reproduce this locally when forcing AdMob live or test ads?

yes, i can show admob with applovin MAX , but if show collapsible banner, it crashed. I check the code, the method missing is still there. Can't understand why. May be cache of gradle or something?

thomasmso commented 3 months ago

That is strange, and not something we've had reported before. I am pretty sure it has something to do with your local environment, and +1 to your belief that it may have something to do with your local Gradle setup/cache. Unfortunately, there's not much we can do here unless we have access to your project / local environment. If you can reproduce it in a new app (e.g. our demo app), that would help as well.