react-native-splash-screen icon indicating copy to clipboard operation
react-native-splash-screen copied to clipboard

RuntimeException Can't convert to color:type=0x1

Open pjamrozowicz opened this issue 9 years ago • 6 comments

Hi! I've just updated react-native-splash-screen in my project to the latest version and I'm getting a following RuntimeException:

--------- beginning of crash E/AndroidRuntime( 3926): FATAL EXCEPTION: main E/AndroidRuntime( 3926): Process: com.xxxxxx, PID: 3926 E/AndroidRuntime( 3926): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.xxxxxx/com.xxxxxx.MainActivity}: java.lang.UnsupportedOperationException: Can't convert to color:type=0x1 E/AndroidRuntime( 3926): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2325) E/AndroidRuntime( 3926): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387) E/AndroidRuntime( 3926): at android.app.ActivityThread.access$800(ActivityThread.java:151) E/AndroidRuntime( 3926): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303) E/AndroidRuntime( 3926): at android.os.Handler.dispatchMessage(Handler.java:102) E/AndroidRuntime( 3926): at android.os.Looper.loop(Looper.java:135) E/AndroidRuntime( 3926): at android.app.ActivityThread.main(ActivityThread.java:5254) E/AndroidRuntime( 3926): at java.lang.reflect.Method.invoke(Native Method) E/AndroidRuntime( 3926): at java.lang.reflect.Method.invoke(Method.java:372) E/AndroidRuntime( 3926): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903) E/AndroidRuntime( 3926): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698) E/AndroidRuntime( 3926): Caused by: java.lang.UnsupportedOperationException: Can't convert to color: type=0x1 E/AndroidRuntime( 3926): at android.content.res.TypedArray.getColor(TypedArray.java:404) E/AndroidRuntime( 3926): at com.android.internal.policy.impl.PhoneWindow.generateLayout(PhoneWindow.java:3477) E/AndroidRuntime( 3926): at com.android.internal.policy.impl.PhoneWindow.installDecor(PhoneWindow.java:3677) E/AndroidRuntime( 3926): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:368) E/AndroidRuntime( 3926): at android.app.Dialog.setContentView(Dialog.java:490) E/AndroidRuntime( 3926): at org.devio.rn.splashscreen.SplashScreen$1.run(SplashScreen.java:32) E/AndroidRuntime( 3926): at android.app.Activity.runOnUiThread(Activity.java:5293) E/AndroidRuntime( 3926): at org.devio.rn.splashscreen.SplashScreen.show(SplashScreen.java:26) E/AndroidRuntime( 3926): at org.devio.rn.splashscreen.SplashScreen.show(SplashScreen.java:47) E/AndroidRuntime( 3926): at com.xxxxxx.MainActivity.onCreate(MainActivity.java:13) E/AndroidRuntime( 3926): at android.app.Activity.performCreate(Activity.java:5990) E/AndroidRuntime( 3926): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106) E/AndroidRuntime( 3926): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2278) E/AndroidRuntime( 3926): ... 10 more

I can see SplashScreen references there and latest merges added support for Status Bar color (which I don't need so I haven't change my config files). When I disable SplashScreen the exception is gone. What can I do to make it work?

My config: compileSdkVersion 26 buildToolsVersion "26.0.1" defaultConfig { applicationId "xxxxxxx" minSdkVersion 16 targetSdkVersion 26 versionCode 1 versionName "1.0" ndk { abiFilters "armeabi-v7a", "x86" } renderscriptTargetApi 23 renderscriptSupportModeEnabled true }

pjamrozowicz avatar Oct 17 '17 20:10 pjamrozowicz

In andorid, I created android/app/src/main/res/values/colors.xml, and setting content <?xml version="1.0" encoding="utf-8"?> <resources> <color name="primary_dark">#660B0B0B</color> </resources> It's worked

zh2120 avatar Nov 06 '17 03:11 zh2120

I had the same error and using your fix @zh2120 solved the problem

alxistn avatar Nov 06 '17 16:11 alxistn

Updating from 3.0.1 to 3.0.5 caused this error in our application, albeit with a different index (I think 0x35). Downgrading to 3.0.1 fixed it. Presumably this is not quite the same as originally reported, as I think 3.0.1 would have been the latest version then.

haggholm avatar Nov 06 '17 18:11 haggholm

OMG thank you very much @zh2120 !! You saved my day!!! Spent half of my day for downgrading gradle and fix every plugin but only this can make it work!

riryjs avatar Nov 09 '17 06:11 riryjs

zh2120 saved my day too! been wasting 2h on compiling again and again the project, trying to use different build tools version, a complete mindfuck. Happened after upgrading build tools. Shouldn't this issue be reopened and fixed in the library?

jcharlet avatar Nov 10 '17 16:11 jcharlet

@jcharlet I found that this problem only appears in some Android (7.0 or above) system. This problem has been closed, indicating that the author has obtained the problem and is trying to fix it. If you can not wait, you can fork or PR. Cheers!

zh2120 avatar Nov 11 '17 00:11 zh2120