teogor / ceres

🪐 Ceres is a comprehensive Android development framework designed to streamline your app development process. Powered by the latest technologies like Jetpack Compose, Hilt, Coroutines, and Flow, Ceres empowers developers to build modern and efficient Android applications.
https://source.teogor.dev/ceres
Apache License 2.0
65 stars 4 forks source link

Crash when showing `AppOpenAd` #53

Closed zeoowl-dev closed 2 years ago

zeoowl-dev commented 2 years ago

Here is the log

FATAL EXCEPTION: main
  Process: com.zeoowl.lwp.aquarium.dev, PID: 23798
    java.lang.NullPointerException
    at dev.teogor.ceres.core.global.GlobalData.getActivity(GlobalData.kt:35)
    at dev.teogor.ceres.ads.formats.AppOpenAd.show(AppOpenAd.kt:87)
    at dev.teogor.ceres.ads.startup.AdsProvider.showAd(AdsProvider.kt:111)
    at dev.teogor.ceres.ads.startup.AdsProvider.onActivityStarted(AdsProvider.kt:88)
    at android.app.Application.dispatchActivityStarted(Application.java:405)
    at android.app.Activity.dispatchActivityStarted(Activity.java:1406)
    at android.app.Activity.onStart(Activity.java:1922)
    at androidx.fragment.app.FragmentActivity.onStart(FragmentActivity.java:345)
    at androidx.appcompat.app.AppCompatActivity.onStart(AppCompatActivity.java:248)
    at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1455)
    at android.app.Activity.performStart(Activity.java:8315)
    at android.app.ActivityThread.handleStartActivity(ActivityThread.java:4136)
    at android.app.servertransaction.TransactionExecutor.performLifecycleSequence(TransactionExecutor.java:221)
    at android.app.servertransaction.TransactionExecutor.cycleToPath(TransactionExecutor.java:201)
    at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:173)
    at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2443)
    at android.os.Handler.dispatchMessage(Handler.java:106)
    at android.os.Looper.loopOnce(Looper.java:226)
    at android.os.Looper.loop(Looper.java:313)
    at android.app.ActivityThread.main(ActivityThread.java:8751)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1135)
teogor commented 2 years ago

it looks like this occurs due to wrong order of reading the current activity