React-native-splash-screen: Can't convert to color: type=0x1

Created on 8 Nov 2017  路  8Comments  路  Source: crazycodeboy/react-native-splash-screen

It seams that something is wrong in android.

react native: 0.47.2
android: 6.0.1

java.lang.UnsupportedOperationException: Can't convert to color: type=0x1

2聽android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2423)
3聽......
4聽Caused by:
5聽java.lang.UnsupportedOperationException:Can't convert to color: type=0x1
6聽android.content.res.TypedArray.getColor(TypedArray.java:453)
7聽com.android.internal.policy.PhoneWindow.generateLayout(PhoneWindow.java:3779)
8聽com.android.internal.policy.PhoneWindow.installDecor(PhoneWindow.java:3983)
9聽com.android.internal.policy.PhoneWindow.setContentView(PhoneWindow.java:383)
10聽android.app.Dialog.setContentView(Dialog.java:515)
11聽org.devio.rn.splashscreen.SplashScreen$1.run(SplashScreen.java:32)
12聽android.app.Activity.runOnUiThread(Activity.java:5573)
13聽org.devio.rn.splashscreen.SplashScreen.show(SplashScreen.java:26)
14聽org.devio.rn.splashscreen.SplashScreen.show(SplashScreen.java:47)
15聽com.gf.mobile.clickeggs2.MainActivity.onCreate(MainActivity.java:27)

Most helpful comment

I had the same problem. In this file, there is a reference to a primary_dark color.

So, try to add the primary_dark in res/values/colors.xml (create the file if not exists) :

<?xml version="1.0" encoding="utf-8"?>
<resources>
  <color name="primary_dark">#000000</color>
</resources>

All 8 comments

I have the same problem on android 7.0 with RN 0.48.4

I had the same problem. In this file, there is a reference to a primary_dark color.

So, try to add the primary_dark in res/values/colors.xml (create the file if not exists) :

<?xml version="1.0" encoding="utf-8"?>
<resources>
  <color name="primary_dark">#000000</color>
</resources>

@kbarralon I solved the problem in the same way.

Thanks, @kbarralon. Adding the reference to "primary_dark" solved the problem. I think this should be an optional step.

I had tried it, when downgrade to 3.0.1, It works fine. but 3.0.6 failed without colors.xml

@kbarralon Thanks!

but still error @kbarralon

Error:Execution failed for task ':react-native-splash-screen:packageReleaseResources'.

[color/primary_dark] --/node_modules/react-native-splash-screen/android/src/main/res/values/colors.xml [color/primary_dark] /--/node_modules/react-native-splash-screen/android/src/main/res/values/refs.xml: Error: Duplicate resources

clean not work

finally i solve by rename ,maybe can help someone

I've put up a PR to fix this (see #125) which will allow custom theming, but doesn't force it.

It'll fix the BC break introduced in version 3.0.6.

Was this page helpful?
0 / 5 - 0 ratings