braze-inc / braze-android-sdk

https://www.braze.com
Other
20 stars 9 forks source link

[Bug]: No static method brazelog #41

Closed gmWheeler001 closed 2 weeks ago

gmWheeler001 commented 3 weeks ago

Braze Android SDK Version

any

Steps To Reproduce

When you have dependancies in your build.gradle like this, it will use version 32.1.0 and this will cause the crash, setting the version back to 32.0.0 resolved the issue.

dependencies {

implementation "com.braze:android-sdk-ui:+"

}

Expected Behavior

Should not crash on start

Actual Incorrect Behavior

App fails to start with the exception FATAL EXCEPTION: main java.lang.NoSuchMethodError: No static method brazelog$default(Lcom/braze/support/BrazeLogger;Ljava/lang/Object;Lcom/braze/support/BrazeLogger$Priority;Ljava/lang/Throwable;Lkotlin/jvm/functions/Function0;ILjava/lang/Object;)V

Verbose Logs

No response

Additional Information

No response

radixdev commented 3 weeks ago
  1. Can you share the full stacktrace of the exception?
  2. What device did you see this exception on?
  3. What is your r8 configuration?
Sese-Schneider commented 3 weeks ago

@radixdev we face the same issue as @gmWheeler001 and can reproduce the issue reliably.

This might be a regression in your latest release of the SDK or a issue in an update downstream dependency. An educated guess is that the R8/proguard configuration broke.

Workaround

Fixing the android SDK version to 32.0.0:

implementation "com.braze:android-sdk-ui:32.0.0"

Your questions:

1. Stacktrace:

It doesn't really matter, we face the issue for multiple functions in the plugin. Example:

FATAL EXCEPTION: main
Process: com.simpleclub.android, PID: 7807
java.lang.NoSuchMethodError: No static method brazelog$default(Lcom/braze/support/BrazeLogger;Ljava/lang/Object;Lcom/braze/support/BrazeLogger$Priority;Ljava/lang/Throwable;Ljv/a;ILjava/lang/Object;)V in class Lcom/braze/support/BrazeLogger; or its super classes (declaration of 'com.braze.support.BrazeLogger' appears in /data/app/~~nc7-ZC6BbyOupP_B1iJFLQ==/com.simpleclub.android-Aq0aMBjZjAR_ZGObj_zaBw==/base.apk!classes2.dex)
 at com.braze.brazeplugin.BrazePlugin.onAttachedToActivity(Unknown Source:46)
 at yr.b.g(Unknown Source:140)
 at io.flutter.plugins.GeneratedPluginRegistrant.registerWith(Unknown Source:68)
 at com.simpleclub.android.Activity.h(Unknown Source:5)
 at xr.g.h(Unknown Source:10)
 at xr.c.q(Unknown Source:58)
 at xr.g.onAttach(Unknown Source:11)
 at u4.o.performAttach(Unknown Source:49)
 at u4.o0.c(Unknown Source:186)
 at u4.o0.m(Unknown Source:134)
 at u4.g0.d0(Unknown Source:347)
 at u4.g0.j1(Unknown Source:81)
 at u4.g0.a0(Unknown Source:21)
 at u4.g0.S(Unknown Source:38)
 at u4.g0.x(Unknown Source:11)
 at u4.w.c(Unknown Source:4)
 at u4.t.onStart(Unknown Source:20)
 at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1701)
 at android.app.Activity.performStart(Activity.java:9023)
 at android.app.ActivityThread.handleStartActivity(ActivityThread.java:4056)
 at android.app.servertransaction.TransactionExecutor.performLifecycleSequence(TransactionExecutor.java:270)
 at android.app.servertransaction.TransactionExecutor.cycleToPath(TransactionExecutor.java:250)
 at android.app.servertransaction.TransactionExecutor.executeLifecycleItem(TransactionExecutor.java:222)
 at android.app.servertransaction.TransactionExecutor.executeTransactionItems(TransactionExecutor.java:107)
 at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:81)
 at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2619)
 at android.os.Handler.dispatchMessage(Handler.java:107)
 at android.os.Looper.loopOnce(Looper.java:232)
 at android.os.Looper.loop(Looper.java:317)
 at android.app.ActivityThread.main(ActivityThread.java:8674)
 at java.lang.reflect.Method.invoke(Native Method)
 at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:580)
 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:886)

2. Devices

All devices across our whole build pipeline

3. R8

Unchanged since previous releases

bryanlogan commented 3 weeks ago

Even if it's unchanged, can you still post it? I'm trying to recreate it in the r8-tester and it's not having any issues. So if you're able to recreate it there, you could send us that config.

If you don't want to post information here, you can also send it to Braze support and reference this Github issue.

Sese-Schneider commented 3 weeks ago

@bryanlogan we're using the Flutter SDK

proguard-rules.pro

...

# Braze (AppBoy)
-keep class bo.app.** { *; }
-keep class com.appboy.** { *; }

...

gradle.properties

android.enableR8=true
bryanlogan commented 3 weeks ago

@gmWheeler001 Are you also using the Flutter SDK? We encourage people to stick with the Android SDK that's shipped with the Braze Flutter SDK to prevent things like this.

radixdev commented 2 weeks ago

Hi @Sese-Schneider, @gmWheeler001 ,

Please see https://github.com/braze-inc/braze-react-native-sdk/issues/264#issuecomment-2313600717 for a resolution. After an investigation, this appears to be a Gradle dependency chain issue and not a R8 issue.