jonbhanson / flutter_native_splash

Automatically generates native code for adding splash screens in Android and iOS. Customize with specific platform, background color and splash image.
https://pub.dev/packages/flutter_native_splash
MIT License
1.35k stars 214 forks source link

Crash on API < 21 setStatusBarColor method not found #12

Closed hsombini closed 5 years ago

hsombini commented 5 years ago

How to reproduce

  1. Run flutter native splash
  2. Start the app on an emulator with API < 21

The method android.view.Window.setStatusBarColor was introduced on API 21

[   +8 ms] E/AndroidRuntime( 1476): FATAL EXCEPTION: main
[        ] E/AndroidRuntime( 1476): java.lang.NoSuchMethodError: android.view.Window.setStatusBarColor
[        ] E/AndroidRuntime( 1476):     at com.example.tabela_fipe.MainActivity.onCreate(MainActivity.java:15)
[        ] E/AndroidRuntime( 1476):     at android.app.Activity.performCreate(Activity.java:5008)
[        ] E/AndroidRuntime( 1476):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
[        ] E/AndroidRuntime( 1476):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
[        ] E/AndroidRuntime( 1476):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
[        ] E/AndroidRuntime( 1476):     at android.app.ActivityThread.access$600(ActivityThread.java:130)
[        ] E/AndroidRuntime( 1476):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
[        ] E/AndroidRuntime( 1476):     at android.os.Handler.dispatchMessage(Handler.java:99)
[        ] E/AndroidRuntime( 1476):     at android.os.Looper.loop(Looper.java:137)
[        ] E/AndroidRuntime( 1476):     at android.app.ActivityThread.main(ActivityThread.java:4745)
[        ] E/AndroidRuntime( 1476):     at java.lang.reflect.Method.invokeNative(Native Method)
[        ] E/AndroidRuntime( 1476):     at java.lang.reflect.Method.invoke(Method.java:511)
[        ] E/AndroidRuntime( 1476):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
[        ] E/AndroidRuntime( 1476):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
[        ] E/AndroidRuntime( 1476):     at dalvik.system.NativeStart.main(Native Method)
henriquearthur commented 5 years ago

Thanks for reporting!

Fixed in v0.1.7+1 (0dbd1c2ebda2328fc4f4da58092f2ace767bc17f). Now the package checks if minSdkVersion is >= 21 before adding code to change status bar color.

Aljulanda9 commented 5 years ago

Hi, I just tested with v^0.1.7+2 on a Samsung Galaxy S3, API level 18 (using firebase testlab). I still get the same issue.

     FATAL EXCEPTION: main
java.lang.NoSuchMethodError: android.view.Window.setStatusBarColor
    at com.aljulanda.sama.MainActivity.onCreate(MainActivity.kt:15)
    at android.app.Activity.performCreate(Activity.java:5372)
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1104)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2257)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2349)
    at android.app.ActivityThread.access$700(ActivityThread.java:159)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1316)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:176)
    at android.app.ActivityThread.main(ActivityThread.java:5419)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:525)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1046)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:862)
    at dalvik.system.NativeStart.main(Native Method)
henriquearthur commented 5 years ago

@Aljulanda9 can you check this again on v0.1.8+1? API check is now done using Build class.