AppLovin / AppLovin-MAX-Flutter

MIT License
55 stars 29 forks source link

AppLovinMAX.setIsAgeRestrictedUser java.lang.NoSuchMethodError #259

Closed k0shk0sh closed 1 month ago

k0shk0sh commented 2 months ago

MAX Plugin Version

3.11.0

Flutter Version

3.11.0

Device/Platform Info

no particular device

Crashes/ANRs per Day

all users under our ab test

Percentage of Users Affected

25%

First Occurrence of Crash/ANR

Today as we started the A/B Test

Exception and Stack Trace

      Fatal Exception: java.lang.NoSuchMethodError: No static method setIsAgeRestrictedUser(ZLandroid/content/Context;)V in class Lcom/applovin/sdk/AppLovinPrivacySettings; or its super classes (declaration of 'com.applovin.sdk.AppLovinPrivacySettings' appears in /data/app/~~TY-lhxrI_nHpyGrMnkphGA==/de.fastic.app-2X1tVcjahHnmCKslAm3jkg==/base.apk!classes3.dex)
   at com.applovin.applovin_max.AppLovinMAX.setIsAgeRestrictedUser(AppLovinMAX.java:243)
   at com.applovin.applovin_max.AppLovinMAX.onMethodCall(AppLovinMAX.java:1615)
   at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:267)
   at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:292)
   at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0$io-flutter-embedding-engine-dart-DartMessenger(DartMessenger.java:319)
   at io.flutter.embedding.engine.dart.DartMessenger$$ExternalSyntheticLambda0.run(:12)
   at android.os.Handler.handleCallback(Handler.java:959)
   at android.os.Handler.dispatchMessage(Handler.java:100)
   at android.os.Looper.loopOnce(Looper.java:232)
   at android.os.Looper.loop(Looper.java:317)
   at android.app.ActivityThread.main(ActivityThread.java:8592)
   at java.lang.reflect.Method.invoke(Method.java)
   at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:580)
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:878)

How to Reproduce

Opening app

Reproducible in the demo app?

Not Tested

Additional Info

We do not have proguard enabled in our android app

thomasmso commented 2 months ago

@k0shk0sh - it looks like you have mismatch plugin version and native (AppLovin) SDK versions.

Could you update the Flutter plugin to the latest v4.0.0? We've removed the IsAgeRestrictedUser API in the latest SDK, you can read more about it here: https://developers.applovin.com/en/max/flutter/overview/privacy/

You can see our releases and the native SDKs that the plugin is certified agains here: https://github.com/AppLovin/AppLovin-MAX-Flutter/releases

k0shk0sh commented 2 months ago

@thomasmso thanks for the reply and we will definitely do the upgrade, however, how could this happen tho? we are not including the android dependency in our build.gradle.

k0shk0sh commented 2 months ago

could this be the cause:

implementation 'com.applovin.mediation:google-ad-manager-adapter:+'
    implementation 'com.applovin.mediation:google-adapter:+'
    implementation 'com.applovin.mediation:facebook-adapter:+'
    implementation 'com.applovin.mediation:inmobi-adapter:+'
    implementation 'com.applovin.mediation:ironsource-adapter:+'
    implementation 'com.applovin.mediation:unityads-adapter:+'

does any of these dependencies pull also the android SDK?

thomasmso commented 2 months ago

Yea - that is the issue, the adapters are automatically updating to the latest versions which transitively pull the latest SDK. We're looking into solutions on preventing this from happening.

k0shk0sh commented 2 months ago

yeah, I thought so too. thanks alot for the quick response.

k0shk0sh commented 2 months ago

Hi @thomasmso, while working on updating applovin now, I found out that in your documentation you recommend to use gradle dependencies without a specific version which could definitely result again in the future with such catastrophe like the one we are currently having because Playstore review process is taking longer than expected.

Could you please adjust your documentation to specify the version for each of the adapter? https://developers.applovin.com/en/max/react-native/preparing-mediated-networks/?androidnetworks=453%2C843

This is very important so in the future Applovin customers don't face such issues.

thomasmso commented 2 months ago

Thanks for the thoughts here @k0shk0sh. Issue with locking to a specific adapter version is developers never update their adapters.

The more robust solution here would be to somehow warn developers that they have an incompatibility with the Flutter plugin and underlying Android/iOS SDK.

k0shk0sh commented 2 months ago

@thomasmso it all comes to down to writing a proper changelog I assume. if in your flutter changelog you mention that adapters version x.x.x are required, then its the devs responsibility to update their adapters, its no longer on applovin being the one breaking other apps with millions of users, but rather its your customer engineers that obviously (hopefully) read the changelog and follow a proper upgrade flow.

Warn imho is not enough because it can just slip through all logs and whatnot. Also, I don't see how this could possible tho, our problem was that android dependencies upgraded the applovin sdk, which your flutter plugin doesn't support, your flutter plugin was calling a function that is not longer existing. I don't see a way where you can do validation here as you have no way of figuring what flutter plugin the app is using. I may be incorrect. but I didn't see this before.

thomasmso commented 2 months ago

Yeah, I agree we could've documented it better with the min adapter versions 4.0.0 supports (and max adapter versions 3.11.1 supports).

The solution I had in mind was to perform the check upon init. For example, Flutter 4.0.0 would check underlying SDK version.

k0shk0sh commented 2 months ago

I see, yeah, this could work, although it can be not caught 🙈 in our case, when we work on the app, ads are always disabled during development, only time we enable them during development, is to test upgrading/migration. so even with the warn/crash, it can be already tooooo late.

thomasmso commented 2 months ago

Most publishers I've worked with the last 10 years do at least initialize the ad SDK in dev or QA. So hopefully we'll be able to cover most folks. These kinds of breaking changes happen at most once every couple years.