Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AppLovinFlutterMediationExtras Class not found error [Android] #1170

Closed
theLee3 opened this issue Sep 9, 2024 · 10 comments
Closed

AppLovinFlutterMediationExtras Class not found error [Android] #1170

theLee3 opened this issue Sep 9, 2024 · 10 comments
Assignees
Labels
mediation Issue related to mediation API's

Comments

@theLee3
Copy link

theLee3 commented Sep 9, 2024

Plugin Version

gma: 5.1.0
gma_mediation_applovin: 1.2.0
flutter: 3.24.2

The problem

AppLovin mediation throws class not found error on Android, followed by a null pointer exception when working with mediations extras.

Steps to Reproduce

  1. Create an AppLovinMediationExtras object.
  2. Pass the AppLovinMediationExtras object to AdRequest via mediationExtras.
  3. Attempt to load an ad (interstitial used in my case).

Expected results: Able to pass extras to ad request for AppLovin mediation network.

Actual results: Error occurs preventing the ad request from being made.

Logs
E/FlutterMediationExtras(14034): Class not found:
io.flutter.plugins.googlemobileads.mediation.gma_mediation_applovin.AppLovinFlutterMediationExtras
[        ] E/MethodChannel#plugins.flutter.io/google_mobile_ads(14034): Failed to handle method call
[        ] E/MethodChannel#plugins.flutter.io/google_mobile_ads(14034): java.lang.NullPointerException: Attempt to invoke virtual method
'android.util.Pair io.flutter.plugins.googlemobileads.FlutterMediationExtras.getMediationExtras()' on a null object reference
[        ] E/MethodChannel#plugins.flutter.io/google_mobile_ads(14034):         at
io.flutter.plugins.googlemobileads.FlutterAdRequest.addNetworkExtras(FlutterAdRequest.java:224)
[        ] E/MethodChannel#plugins.flutter.io/google_mobile_ads(14034):         at
io.flutter.plugins.googlemobileads.FlutterAdRequest.updateAdRequestBuilder(FlutterAdRequest.java:267)
[        ] E/MethodChannel#plugins.flutter.io/google_mobile_ads(14034):         at
io.flutter.plugins.googlemobileads.FlutterAdRequest.asAdRequest(FlutterAdRequest.java:279)
[        ] E/MethodChannel#plugins.flutter.io/google_mobile_ads(14034):         at
io.flutter.plugins.googlemobileads.FlutterInterstitialAd.load(FlutterInterstitialAd.java:51)
[        ] E/MethodChannel#plugins.flutter.io/google_mobile_ads(14034):         at
io.flutter.plugins.googlemobileads.GoogleMobileAdsPlugin.onMethodCall(GoogleMobileAdsPlugin.java:447)
[        ] E/MethodChannel#plugins.flutter.io/google_mobile_ads(14034):         at
io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:267)
[        ] E/MethodChannel#plugins.flutter.io/google_mobile_ads(14034):         at
io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:292)
[        ] E/MethodChannel#plugins.flutter.io/google_mobile_ads(14034):         at
io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0(DartMessenger.java:319)
[        ] E/MethodChannel#plugins.flutter.io/google_mobile_ads(14034):         at
io.flutter.embedding.engine.dart.DartMessenger.$r8$lambda$2j2MERcK825A5j1fv5sZ7xB2Iuo(DartMessenger.java:0)
[        ] E/MethodChannel#plugins.flutter.io/google_mobile_ads(14034):         at
io.flutter.embedding.engine.dart.DartMessenger$$ExternalSyntheticLambda0.run(R8$$SyntheticClass:0)
[        ] E/MethodChannel#plugins.flutter.io/google_mobile_ads(14034):         at android.os.Handler.handleCallback(Handler.java:959)
[        ] E/MethodChannel#plugins.flutter.io/google_mobile_ads(14034):         at android.os.Handler.dispatchMessage(Handler.java:100)
[        ] E/MethodChannel#plugins.flutter.io/google_mobile_ads(14034):         at android.os.Looper.loopOnce(Looper.java:232)
[        ] E/MethodChannel#plugins.flutter.io/google_mobile_ads(14034):         at android.os.Looper.loop(Looper.java:317)
[        ] E/MethodChannel#plugins.flutter.io/google_mobile_ads(14034):         at android.app.ActivityThread.main(ActivityThread.java:8592)
[        ] E/MethodChannel#plugins.flutter.io/google_mobile_ads(14034):         at java.lang.reflect.Method.invoke(Native Method)
[        ] E/MethodChannel#plugins.flutter.io/google_mobile_ads(14034):         at
com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:580)
[        ] E/MethodChannel#plugins.flutter.io/google_mobile_ads(14034):         at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:878)
[        ] E/flutter (14034): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: PlatformException(error, Attempt to
invoke virtual method 'android.util.Pair io.flutter.plugins.googlemobileads.FlutterMediationExtras.getMediationExtras()' on a null object
reference, null, java.lang.NullPointerException: Attempt to invoke virtual method 'android.util.Pair
io.flutter.plugins.googlemobileads.FlutterMediationExtras.getMediationExtras()' on a null object reference
[        ] E/flutter (14034):   at io.flutter.plugins.googlemobileads.FlutterAdRequest.addNetworkExtras(FlutterAdRequest.java:224)
[        ] E/flutter (14034):   at io.flutter.plugins.googlemobileads.FlutterAdRequest.updateAdRequestBuilder(FlutterAdRequest.java:267)
[        ] E/flutter (14034):   at io.flutter.plugins.googlemobileads.FlutterAdRequest.asAdRequest(FlutterAdRequest.java:279)
[        ] E/flutter (14034):   at io.flutter.plugins.googlemobileads.FlutterInterstitialAd.load(FlutterInterstitialAd.java:51)
[        ] E/flutter (14034):   at io.flutter.plugins.googlemobileads.GoogleMobileAdsPlugin.onMethodCall(GoogleMobileAdsPlugin.java:447)
[        ] E/flutter (14034):   at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:267)
[        ] E/flutter (14034):   at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:292)
[        ] E/flutter (14034):   at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0(DartMessenger.java:319)
[        ] E/flutter (14034):   at io.flutter.embedding.engine.dart.DartMessenger.$r8$lambda$2j2MERcK825A5j1fv5sZ7xB2Iuo(DartMessenger.java:0)
[        ] E/flutter (14034):   at io.flutter.embedding.engine.dart.DartMessenger$$ExternalSyntheticLambda0.run(R8$$SyntheticClass:0)
[        ] E/flutter (14034):   at android.os.Handler.handleCallback(Handler.java:959)
[        ] E/flutter (14034):   at android.os.Handler.dispatchMessage(Handler.java:100)
[        ] E/flutter (14034):   at android.os.Looper.loopOnce(Looper.java:232)
[        ] E/flutter (14034):   at android.os.Looper.loop(Looper.java:317)
[        ] E/flutter (14034):   at android.app.ActivityThread.main(ActivityThread.java:8592)
[        ] E/flutter (14034):   at java.lang.reflect.Method.invoke(Native Method)
[        ] E/flutter (14034):   at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:580)
[        ] E/flutter (14034):   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:878)
[        ] E/flutter (14034): )
[        ] E/flutter (14034): #0      StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:648:7)
[        ] E/flutter (14034): #1      MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:334:18)
[        ] E/flutter (14034): <asynchronous suspension>
[        ] E/flutter (14034): #2      InterstitialAd.load (package:google_mobile_ads/src/ad_containers.dart:1104:5)
[        ] E/flutter (14034): <asynchronous suspension>
flutter analyze
No issues found! (ran in 4.3s)
flutter doctor -v
[✓] Flutter (Channel stable, 3.24.2, on macOS 14.6.1 23G93 darwin-x64, locale en-US)
    • Flutter version 3.24.2 on channel stable at /Users/lee/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 4cf269e36d (6 days ago), 2024-09-03 14:30:00 -0700
    • Engine revision a6bd3f1de1
    • Dart version 3.5.2
    • DevTools version 2.37.2

[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0)
    • Android SDK at /Users/lee/Library/Android/sdk
    • Platform android-35, build-tools 35.0.0
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.11+0-17.0.11b1207.24-11852314)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 15.4)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 15F31d
    • CocoaPods version 1.15.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2024.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.11+0-17.0.11b1207.24-11852314)

[✓] VS Code (version 1.92.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.94.0

[✓] Connected device (4 available)            
    • Pixel 7 Pro (mobile) • 2C121FDH3S0KMR                           • android-arm64  • Android 14 (API 34)
    • Lee’s iPad (mobile)  • d21ffaaa3798c5057ed805168c19dc400b739fc5 • ios            • iOS 17.6.1 21G93
    • macOS (desktop)      • macos                                    • darwin-x64     • macOS 14.6.1 23G93 darwin-x64
    • Chrome (web)         • chrome                                   • web-javascript • Google Chrome 128.0.6613.120

[✓] Network resources
    • All expected network resources are available.

• No issues found!
@malandr2
Copy link
Collaborator

Hi @theLee3 what version of AppLovin are you using?

@malandr2 malandr2 added feedback required Further information is requested mediation Issue related to mediation API's labels Sep 10, 2024
@theLee3
Copy link
Author

theLee3 commented Sep 10, 2024

@malandr2 1.2.0

@github-actions github-actions bot removed the feedback required Further information is requested label Sep 10, 2024
@malandr2
Copy link
Collaborator

malandr2 commented Sep 11, 2024

@theLee3 are you using gma_mediation_unity or gma_mediation_applovin?

@malandr2 malandr2 added the feedback required Further information is requested label Sep 11, 2024
@theLee3
Copy link
Author

theLee3 commented Sep 11, 2024

@malandr2 My apologies for the incorrect info in the edit. I am using gma_mediation_applovin.

@github-actions github-actions bot removed the feedback required Further information is requested label Sep 11, 2024
@theLee3
Copy link
Author

theLee3 commented Sep 11, 2024

FTR, I just tested with gma_mediation_inmobi as it also extends FlutterMediationExtras and am having the same issue.

Logs
E/FlutterMediationExtras(27071): Class not found: io.flutter.plugins.googlemobileads.mediation.gma_mediation_inmobi.InMobiFlutterMediationExtras
E/MethodChannel#plugins.flutter.io/google_mobile_ads(27071): Failed to handle method call
E/MethodChannel#plugins.flutter.io/google_mobile_ads(27071): java.lang.NullPointerException: Attempt to invoke virtual method 'android.util.Pair io.flutter.plugins.googlemobileads.FlutterMediationExtras.getMediationExtras()' on a null object reference
E/MethodChannel#plugins.flutter.io/google_mobile_ads(27071): 	at io.flutter.plugins.googlemobileads.FlutterAdRequest.addNetworkExtras(FlutterAdRequest.java:224)
E/MethodChannel#plugins.flutter.io/google_mobile_ads(27071): 	at io.flutter.plugins.googlemobileads.FlutterAdRequest.updateAdRequestBuilder(FlutterAdRequest.java:267)
E/MethodChannel#plugins.flutter.io/google_mobile_ads(27071): 	at io.flutter.plugins.googlemobileads.FlutterAdRequest.asAdRequest(FlutterAdRequest.java:279)
E/MethodChannel#plugins.flutter.io/google_mobile_ads(27071): 	at io.flutter.plugins.googlemobileads.FlutterInterstitialAd.load(FlutterInterstitialAd.java:51)
E/MethodChannel#plugins.flutter.io/google_mobile_ads(27071): 	at io.flutter.plugins.googlemobileads.GoogleMobileAdsPlugin.onMethodCall(GoogleMobileAdsPlugin.java:447)
E/MethodChannel#plugins.flutter.io/google_mobile_ads(27071): 	at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:267)
E/MethodChannel#plugins.flutter.io/google_mobile_ads(27071): 	at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:292)
E/MethodChannel#plugins.flutter.io/google_mobile_ads(27071): 	at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0(DartMessenger.java:319)
E/MethodChannel#plugins.flutter.io/google_mobile_ads(27071): 	at io.flutter.embedding.engine.dart.DartMessenger.$r8$lambda$2j2MERcK825A5j1fv5sZ7xB2Iuo(DartMessenger.java:0)
E/MethodChannel#plugins.flutter.io/google_mobile_ads(27071): 	at io.flutter.embedding.engine.dart.DartMessenger$$ExternalSyntheticLambda0.run(R8$$SyntheticClass:0)
E/MethodChannel#plugins.flutter.io/google_mobile_ads(27071): 	at android.os.Handler.handleCallback(Handler.java:959)
E/MethodChannel#plugins.flutter.io/google_mobile_ads(27071): 	at android.os.Handler.dispatchMessage(Handler.java:100)
E/MethodChannel#plugins.flutter.io/google_mobile_ads(27071): 	at android.os.Looper.loopOnce(Looper.java:232)
E/MethodChannel#plugins.flutter.io/google_mobile_ads(27071): 	at android.os.Looper.loop(Looper.java:317)
E/MethodChannel#plugins.flutter.io/google_mobile_ads(27071): 	at android.app.ActivityThread.main(ActivityThread.java:8592)
E/MethodChannel#plugins.flutter.io/google_mobile_ads(27071): 	at java.lang.reflect.Method.invoke(Native Method)
E/MethodChannel#plugins.flutter.io/google_mobile_ads(27071): 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:580)
E/MethodChannel#plugins.flutter.io/google_mobile_ads(27071): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:878)

@malandr2
Copy link
Collaborator

Hi @theLee3, I'm not able to reproduce a crash.

I added

    AppLovinMediationExtras applovinExtras =
        const AppLovinMediationExtras(isMuted: true);

    AdRequest request = AdRequest(
      keywords: <String>['foo', 'bar'],
      mediationExtras: [applovinExtras],
    );

to the native_platform_example and it appears to be working as expected.

I'm using google_mobile_ads: ^5.1.0 and gma_mediation_applovin: ^1.2.0 on Flutter version 3.24.3

Can you try this?

@malandr2 malandr2 added the feedback required Further information is requested label Sep 13, 2024
@theLee3
Copy link
Author

theLee3 commented Sep 16, 2024

@malandr2 I am using the same versions of everything.

I tried with both the native_platform_example & interstitial_example (as it's more similar to my implementation) without an issue.

Any idea what would lead to the class not found error I am seeing? The only difference I noted was my project using newer Java/Kotlin versions, newer versions of some plugins/libraries, and the newer declarative Gradle plugin approach as opposed to imperative. However, after rolling all of those things back, the issue persists.

@github-actions github-actions bot removed the feedback required Further information is requested label Sep 16, 2024
@theLee3
Copy link
Author

theLee3 commented Sep 17, 2024

It appears that the issue was due to the JDK version that was being used. Somehow it had changed in the project's gradle settings in Android Studio from JAVA 17 to the system installed version (22). Thanks for your feedback.

@theLee3 theLee3 closed this as completed Sep 17, 2024
@theLee3
Copy link
Author

theLee3 commented Sep 18, 2024

Please re-open this issue. @malandr2 I was incorrect. The problem occurs when run in release mode. I have tested with the native_platform_example and confirmed the problem occurs there as well.

@theLee3
Copy link
Author

theLee3 commented Sep 18, 2024

A ProGuard rule is needed to preserve the AppLovinFlutterMediationExtras class during shrinking. This should be done for all classes that extend FlutterMediationExtras across all mediation plugins.

This can be accomplished with a single proguard-rules.pro file at the google_mobile_ads package level, containing the following line:

-keep class * implements io.flutter.plugins.googlemobileads.FlutterMediationExtras

Then adding the following line in the android.defaultConfig section of the package build.gradle:

consumerProguardFiles 'proguard-rules.pro'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
mediation Issue related to mediation API's
Projects
None yet
Development

No branches or pull requests

3 participants