AppLovin / AppLovin-MAX-Flutter

MIT License
51 stars 29 forks source link

Invalid initialization process with ok initialization #266

Closed al-tush closed 6 days ago

al-tush commented 1 week ago

MAX Plugin Version

4.0.0

Flutter Version

3.24.3

Device/Platform Info

Android 14

Current Behavior

After update to applvin_max 4.0.0 (3.11.1 has the same error) i see in log:

D/AppLovinSdk( 8506): [AppLovinMAX] Initializing AppLovin MAX Flutter v4.0.0...
D/AppLovinSdk( 8506): [AppLovinSdkInitializationConfiguration] Initializing with key: lU52gZ_Qm5PHkHKd1buW--ul25HkgGZtEZTopQ6I8MpLzayVJMo9LqPMv1clKoCDy6iN6dktF8dxlSKWEZya_-
D/AppLovinSdk( 8506): [AppLovinSdkInitializationConfiguration] setPluginVersion(pluginVersion=Flutter-4.0.0)
D/AppLovinSdk( 8506): [AppLovinSdkInitializationConfiguration] setMediationProvider(mediationProvider=max)
D/AppLovinSdk( 8506): [AppLovinSdkInitializationConfiguration] setSegmentCollection(segmentCollection=MaxSegmentColletionImpl{segments=[]})
E/AppLovinSdk( 8506): [AppLovinSdk] Invalid initialization process. Please initialize the SDK as soon as possible with "AppLovinSdk#initialize(AppLovinSdkInitializationConfiguration, AppLovinSdk.SdkInitializationListener)" before accessing any SDK fields or functions
E/MethodChannel#applovin_max( 8506): Failed to handle method call
E/MethodChannel#applovin_max( 8506): java.lang.IllegalStateException: Invalid initialization process. Please initialize the SDK as soon as possible with "AppLovinSdk#initialize(AppLovinSdkInitializationConfiguration, AppLovinSdk.SdkInitializationListener)" before accessing any SDK fields or functions
E/MethodChannel#applovin_max( 8506):    at com.applovin.impl.sdk.j.a(SourceFile:7581)
E/MethodChannel#applovin_max( 8506):    at com.applovin.sdk.AppLovinSdk.initialize(SourceFile:1)
E/MethodChannel#applovin_max( 8506):    at com.applovin.applovin_max.AppLovinMAX.initialize(AppLovinMAX.java:184)
E/MethodChannel#applovin_max( 8506):    at com.applovin.applovin_max.AppLovinMAX.onMethodCall(AppLovinMAX.java:1559)
E/MethodChannel#applovin_max( 8506):    at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:267)
E/MethodChannel#applovin_max( 8506):    at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:292)
E/MethodChannel#applovin_max( 8506):    at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0$io-flutter-embedding-engine-dart-DartMessenger(DartMessenger.java:319)
E/MethodChannel#applovin_max( 8506):    at io.flutter.embedding.engine.dart.DartMessenger$$ExternalSyntheticLambda0.run(Unknown Source:12)
E/MethodChannel#applovin_max( 8506):    at android.os.Handler.handleCallback(Handler.java:958)
E/MethodChannel#applovin_max( 8506):    at android.os.Handler.dispatchMessage(Handler.java:99)
E/MethodChannel#applovin_max( 8506):    at android.os.Looper.loopOnce(Looper.java:205)
E/MethodChannel#applovin_max( 8506):    at android.os.Looper.loop(Looper.java:294)
E/MethodChannel#applovin_max( 8506):    at android.app.ActivityThread.main(ActivityThread.java:8177)
E/MethodChannel#applovin_max( 8506):    at java.lang.reflect.Method.invoke(Native Method)
E/MethodChannel#applovin_max( 8506):    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552)
E/MethodChannel#applovin_max( 8506):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:971)

The ads work ok. Previous versions of applovin_max plugin has no this error.

Expected Behavior

No response

How to Reproduce

Call await AppLovinMAX.initialize(appLovinSDKKey);

Reproducible in the demo app?

Not Tested

Additional Info

No response

thomasmso commented 1 week ago

@al-tush - before we dive in, if you could you send over more of your integration code which interacts with our plugin, that would be great.

al-tush commented 6 days ago

Sure! Here is a default flutter project with android:name="applovin.sdk.key" in manifest and AppLovinMAX.initialize(...); in initState init_failure.zip

It was built with applovin_max 4.0.1. The error is same

al-tush commented 6 days ago
Doctor summary (to see all details, run flutter doctor -v):
[!] Flutter (Channel [user-branch], 3.24.3, on macOS 14.7 23H124 darwin-arm64, locale en-BY)
    ! Flutter version 3.24.3 on channel [user-branch] at /Users/altush/Projects/flutter
      Currently on an unknown channel. Run `flutter channel` to switch to an official channel.
      If that doesn't fix the issue, reinstall Flutter by following instructions at https://flutter.dev/setup.
    ! Upstream repository unknown source is not a standard remote.
      Set environment variable "FLUTTER_GIT_URL" to unknown source to dismiss this error.
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 16.0)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2024.1)
[✓] VS Code (version 1.94.0)
[✓] Connected device (4 available)
    ! Error: Browsing on the local area network for ALT-phone11. Ensure the device is unlocked and attached with a cable or associated
      with the same local area network as this Mac.
      The device must be opted into Developer Mode to connect wirelessly. (code -27)
[✓] Network resources

! Doctor found issues in 1 category.
altush@ALTBOOK-MAC applovin_init % flutter doctor -v
[!] Flutter (Channel [user-branch], 3.24.3, on macOS 14.7 23H124 darwin-arm64, locale en-BY)
    ! Flutter version 3.24.3 on channel [user-branch] at /Users/altush/Projects/flutter
      Currently on an unknown channel. Run `flutter channel` to switch to an official channel.
      If that doesn't fix the issue, reinstall Flutter by following instructions at https://flutter.dev/setup.
    ! Upstream repository unknown source is not a standard remote.
      Set environment variable "FLUTTER_GIT_URL" to unknown source to dismiss this error.
    • Framework revision 2663184aa7 (5 weeks ago), 2024-09-11 16:27:48 -0500
    • Engine revision 36335019a8
    • Dart version 3.5.3
    • DevTools version 2.37.3
    • If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update
      checks and upgrades.

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at /Users/altush/Library/Android/sdk
    • Platform android-34, build-tools 34.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 16.0)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 16A242d
    • 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.94.0)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.98.0

[✓] Connected device (4 available)
    • sdk gphone64 arm64 (mobile)     • emulator-5554         • android-arm64  • Android 14 (API 34) (emulator)
    • macOS (desktop)                 • macos                 • darwin-arm64   • macOS 14.7 23H124 darwin-arm64
    • Mac Designed for iPad (desktop) • mac-designed-for-ipad • darwin         • macOS 14.7 23H124 darwin-arm64
    • Chrome (web)                    • chrome                • web-javascript • Google Chrome 129.0.6668.100
    ! Error: Browsing on the local area network for ALT-phone11. Ensure the device is unlocked and attached with a cable or associated
      with the same local area network as this Mac.
      The device must be opted into Developer Mode to connect wirelessly. (code -27)

[✓] Network resources
    • All expected network resources are available.
thomasmso commented 6 days ago

@al-tush - Can you remove the SDK key from the Android Manifest? Since you are initializing by passing in the SDK key programmatically (docs), adding it to your Android Manifest might cause issues.

al-tush commented 6 days ago

Thank you!