plaidev / karte-android-sdk

KARTE SDK for Android
https://karte.io/
Apache License 2.0
5 stars 3 forks source link

[notifications] Crash calling API when DryRun is set true #3

Closed wasnot closed 4 years ago

wasnot commented 4 years ago

Expected Behavior

I can call the notifications module API when DryRun is set true, without crash.

Current Behavior

Application will crash always, when calling notifications module API with DryRun is set true.

Possible Solution

This issue has been fixed in notifications 2.1.0. https://developers.karte.io/docs/release-notes-android-sdk-v2#releases---20200529

Steps to Reproduce

  1. Set DryRun to true when calling KarteApp.setup.
  2. Call one of the APIs in the notifications module. e.g. Notifications.registerFCMToken
  3. App crashes.

Context (Environment)

dependencies {
  implementation 'io.karte.android:notifications:2.0.0'
}

Detailed Description

Crash log

E/AndroidRuntime: FATAL EXCEPTION: main
    Process: io.karte.example, PID: 7147
    java.lang.RuntimeException: Unable to start activity ComponentInfo{io.karte.example/io.karte.example.MainActivity}: kotlin.UninitializedPropertyAccessException: lateinit property self has not been initialized
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3270)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3409)
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2016)
        at android.os.Handler.dispatchMessage(Handler.java:107)
        at android.os.Looper.loop(Looper.java:214)
        at android.app.ActivityThread.main(ActivityThread.java:7356)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
     Caused by: kotlin.UninitializedPropertyAccessException: lateinit property self has not been initialized
        at io.karte.android.notifications.Notifications$Companion.getSelf$notifications_release(Notifications.kt:69)
        at io.karte.android.notifications.Notifications$Companion.registerFCMToken(Notifications.kt:80)
        at io.karte.example.MainActivity.onCreate(MainActivity.kt:15)
        at android.app.Activity.performCreate(Activity.java:7802)
        at android.app.Activity.performCreate(Activity.java:7791)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1299)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3245)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3409) 
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83) 
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135) 
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2016) 
        at android.os.Handler.dispatchMessage(Handler.java:107) 
        at android.os.Looper.loop(Looper.java:214) 
        at android.app.ActivityThread.main(ActivityThread.java:7356) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930) 

Possible Implementation