AppLovin / AppLovin-MAX-Flutter

MIT License
51 stars 29 forks source link

AppLovinMAX.initialize Crash #250

Open lukeirvin opened 1 month ago

lukeirvin commented 1 month ago

MAX Plugin Version

3.11.1

Flutter Version

3.24.3

Device/Platform Info

iOS

Current Behavior

Run app & it immediately crashes. I see this in my console:

[AppLovinSdk] [AppLovinMAX] Initializing AppLovin MAX Flutter v3.11.1...
Lost connection to device.

Expected Behavior

AppLovinSDK should initialize & app should run

How to Reproduce

Just start app from VSCode

Reproducible in the demo app?

Not Tested

Additional Info

class MyApp extends StatefulWidget {
  const MyApp({
    super.key,
  });
  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {

Future<void> initMAXLovin() async {
    MaxConfiguration? appLovinMAXConf =
        await AppLovinMAX.initialize('my_sdk_key');

    if (appLovinMAXConf != null) {
      AppLovinMAX.setHasUserConsent(true);
      AppLovinMAX.setIsAgeRestrictedUser(false);
      AppLovinMAX.setDoNotSell(false);
    }
 }

 @override
  void initState() {
    super.initState();

    // Init MAX App Lovin
    initMAXLovin();
 }
}
alhiwatan commented 1 month ago

@lukeirvin, could you upload how you initialize it for us to investigate?

lukeirvin commented 1 month ago

@alhiwatan Thank you for the response!

I have added how I initialize in the main comment above.

I follow the example app for setup.

Previously, iOS was working with 3.10.1 but I was seeing this issue occur on Android. Since then, I have updated my Android Studio, updated my Flutter version, and updated the package to 3.11.1. Now Android is working fine, but iOS crashes right at app launch.

I've tried to revert back to 3.10.1 but I seem to be stuck on 3.11.1

lukeirvin commented 1 month ago

@alhiwatan

I have tested with 4.0.0 & I still get a crash, that occurs faster than the crash from 3.11.1.

Does 4.0.0 rely on the new version of Xcode that came out this week?

alhiwatan commented 1 month ago

The method setIsAgeRestrictedUser() has been deprecated in our latest Android and iOS SDKs v13.0.0, which is compatible with version 4.0.0 (docs}. Could you remove the following line and try again?

      AppLovinMAX.setIsAgeRestrictedUser(false);
lukeirvin commented 1 month ago

@alhiwatan

When updating to 4.0.0 I received the error to remove that & did. Still no luck.

As I mentioned, the app crashes immediately with 4.0.0 - I don't even see my splash screen.

If I try to downgrade to any other version, I get stuck on 3.11.1 - which seems to work ok on Android but not iOS.

Here is my Flutter Doctor output as well:

[flutter] flutter doctor -v
[✓] Flutter (Channel stable, 3.24.3, on macOS 14.6.1 23G93 darwin-arm64, locale en-US)
    • Flutter version 3.24.3 on channel stable at /Users/Development/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 2663184aa7 (7 days ago), 2024-09-11 16:27:48 -0500
    • Engine revision 36335019a8
    • Dart version 3.5.3
    • DevTools version 2.37.3

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at /Users/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 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.93.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.96.0

[✓] Connected device (6 available)
    • iPhone 15 Pro (mobile)          • D7C4C177-885B-4073-A73F-A145B6951838 • ios            • com.apple.CoreSimulator.SimRuntime.iOS-17-5 (simulator)
    • macOS (desktop)                 • macos                                • darwin-arm64   • macOS 14.6.1 23G93 darwin-arm64
    • Mac Designed for iPad (desktop) • mac-designed-for-ipad                • darwin         • macOS 14.6.1 23G93 darwin-arm64
    • Chrome (web)                    • chrome                               • web-javascript • Google Chrome 128.0.6613.138

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

• No issues found!
thomasmso commented 1 month ago

@lukeirvin - could you send over the adb or Xcode logs? We can't tell why it's crashing from the info provided.

lukeirvin commented 1 month ago

@thomasmso

*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid initialization process: please remove the AppLovinSdkKey entry from your Info.plist and set your SDK key with the ALSdkInitializationConfiguration object.'
*** First throw call stack:
(
    0   CoreFoundation                      0x00000001804ae0f8 __exceptionPreprocess + 172
    1   libobjc.A.dylib                     0x0000000180087db4 objc_exception_throw + 56
    2   CoreFoundation                      0x00000001804ae008 -[NSException initWithCoder:] + 0
    3   AppLovinSDK                         0x00000001048af8e8 -[ALSdk initializeWithConfiguration:completionHandler:] + 356
    4   Runner                              0x0000000100dc2d14 -[AppLovinMAX initializeWithPluginVersion:sdkKey:andNotify:] + 384
    5   Runner                              0x0000000100dc980c -[AppLovinMAX handleMethodCall:result:] + 240
    6   Flutter                             0x0000000108db4df4 __45-[FlutterMethodChannel setMethodCallHandler:]_block_invoke + 164
    7   Flutter                             0x00000001087ef66c ___ZN7flutter25PlatformMessageHandlerIos21HandlePlatformMessageENSt3_fl10unique_ptrINS_15PlatformMessageENS1_14default_deleteIS3_EEEE_block_invoke + 108
    8   libdispatch.dylib                   0x0000000103777ec4 _dispatch_call_block_and_release + 24
    9   libdispatch.dylib                   0x000000010377973c _dispatch_client_callout + 16
    10  libdispatch.dylib                   0x00000001037893f8 _dispatch_main_queue_drain + 1228
    11  libdispatch.dylib                   0x0000000103788f1c _dispatch_main_queue_callback_4CF + 40
    12  CoreFoundation                      0x000000018040e960 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 12
    13  CoreFoundation                      0x0000000180409078 __CFRunLoopRun + 1936
    14  CoreFoundation                      0x00000001804084d4 CFRunLoopRunSpecific + 572
    15  GraphicsServices                    0x000000018ef2aae4 GSEventRunModal + 160
    16  UIKitCore                           0x00000001853d0a28 -[UIApplication _run] + 868
    17  UIKitCore                           0x00000001853d46b0 UIApplicationMain + 124
    18  UIKitCore                           0x00000001848736a8 __swift_destroy_boxed_opaque_existential_1Tm + 10048
    19  Runner                              0x0000000100569c14 $sSo21UIApplicationDelegateP5UIKitE4mainyyFZ + 120
    20  Runner                              0x0000000100569b8c $s6Runner11AppDelegateC5$mainyyFZ + 44
    21  Runner                              0x0000000100569c90 main + 28
    22  dyld                                0x0000000102635544 start_sim + 20
    23  ???                                 0x000000010272e154 0x0 + 4336050516
    24  ???                                 0x9873000000000000 0x0 + 10985123916086771712
)
libc++abi: terminating due to uncaught exception of type NSException
thomasmso commented 1 month ago

@lukeirvin - that's perfect, and the error messages gives you the reason why. Please remove our SDK key from the app's Info.plist file.

lukeirvin commented 1 month ago

@thomasmso do we need a different reference in the info.plist file? or not at all?

lukeirvin commented 1 month ago

@thomasmso

I'm seeing this for 4.0.0:

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Please update to the latest adapter versions. Incompatible adapter(s) found: (
    AdMob,
    "Google Ad Manager"
).'
*** First throw call stack:
(
    0   CoreFoundation                      0x00000001804ae0f8 __exceptionPreprocess + 172
    1   libobjc.A.dylib                     0x0000000180087db4 objc_exception_throw + 56
    2   CoreFoundation                      0x00000001804ae008 -[NSException initWithCoder:] + 0
    3   AppLovinSDK                         0x0000000106e946b0 -[ALSdk initializeSdkServices] + 2496
    4   AppLovinSDK                         0x0000000106e939e4 -[ALSdk initializeWithConfiguration:completionHandler:] + 864
    5   Runner                              0x000000010347ef2c -[AppLovinMAX initializeWithPluginVersion:sdkKey:andNotify:] + 384
    6   Runner                              0x000000010348599c -[AppLovinMAX handleMethodCall:result:] + 240
    7   Flutter                             0x000000010b398df4 __45-[FlutterMethodChannel setMethodCallHandler:]_block_invoke + 164
    8   Flutter                             0x000000010add366c ___ZN7flutter25PlatformMessageHandlerIos21HandlePlatformMessageENSt3_fl10unique_ptrINS_15PlatformMessageENS1_14default_deleteIS3_EEEE_block_invoke + 108
    9   libdispatch.dylib                   0x0000000106373ec4 _dispatch_call_block_and_release + 24
    10  libdispatch.dylib                   0x000000010637573c _dispatch_client_callout + 16
    11  libdispatch.dylib                   0x00000001063853f8 _dispatch_main_queue_drain + 1228
    12  libdispatch.dylib                   0x0000000106384f1c _dispatch_main_queue_callback_4CF + 40
    13  CoreFoundation                      0x000000018040e960 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 12
    14  CoreFoundation                      0x0000000180409078 __CFRunLoopRun + 1936
    15  CoreFoundation                      0x00000001804084d4 CFRunLoopRunSpecific + 572
    16  GraphicsServices                    0x000000018ef2aae4 GSEventRunModal + 160
    17  UIKitCore                           0x00000001853d0a28 -[UIApplication _run] + 868
    18  UIKitCore                           0x00000001853d46b0 UIApplicationMain + 124
    19  UIKitCore                           0x00000001848736a8 __swift_destroy_boxed_opaque_existential_1Tm + 10048
    20  Runner                              0x0000000102c25f78 $sSo21UIApplicationDelegateP5UIKitE4mainyyFZ + 120
    21  Runner                              0x0000000102c25ef0 $s6Runner11AppDelegateC5$mainyyFZ + 44
    22  Runner                              0x0000000102c25ff4 main + 28
    23  dyld                                0x0000000105345544 start_sim + 20
    24  ???                                 0x0000000104e5a154 0x0 + 4377125204
    25  ???                                 0x2c71000000000000 0x0 + 3202340810037133312
)
libc++abi: terminating due to uncaught exception of type NSException
thomasmso commented 1 month ago

That's due to you being on outdated adapters that is not compatible with our latest SDK, you can to the latest by following our docs here: https://developers.applovin.com/en/max/react-native/preparing-mediated-networks

eli1stark commented 4 weeks ago

@lukeirvin

Can you please share more details about your project dependencies and configurations to help us troubleshoot this problem in this issue? I think it might be related to the google_mobile_ads: 5.1.0.

lukeirvin commented 4 weeks ago

@eli1stark As of right now I'm working off of 3.11.1, but I am experiencing the same crash in 4.0.0 for Google Ads (running 5.1.0 as well)