-
Notifications
You must be signed in to change notification settings - Fork 4k
Crash when using color values from styles. #424
Comments
I have the same issue. It happened when I upgraded Gradle plugin to 3.0.0-beta4 |
Same here after updating project to new Android Plugin. |
Same here after updating to Android Studio 3 RC1, Gradle 4, Android Gradle plugin 3 rc2 |
@janbolat same here too |
Does anyone know a good alternative to this library? As it is no longer maintained I don't think we will get a fix for this anytime soon... |
Same too. |
This Stackoverflow Answer worked well for me: https://stackoverflow.com/a/46950028/1350902 |
In my case, I had to set all app: attributes programmatically |
@jannisveerkamp question please, because I'm getting an error
|
This is probably JitPack syntax
but in my case it caused error somewhere else, so I solved this by setting the style programatically |
thank you @kotucz adding |
Instead I had to set programmatically all the view attributes that I previously set in the xml layout with Example <com.viewpagerindicator.CirclePageIndicator
cpi:fillColor="@color/azure"
cpi:pageColor="@color/white"
cpi:radius="4dp"
cpi:snap="true"
cpi:strokeWidth="0dp" /> I removed all the circlePageIndicator.setFillColor(ContextCompat.getColor(getContext(), R.color.azure));
circlePageIndicator.setPageColor(ContextCompat.getColor(getContext(), R.color.white));
circlePageIndicator.setRadius((int) (4 * Resources.getSystem().getDisplayMetrics().density));
circlePageIndicator.setSnap(true);
circlePageIndicator.setStrokeWidth(0); |
I get an exception on Android 7.1.1 : java.lang.UnsupportedOperationException: Can't convert value at index 5 to color: type=0x5
at android.content.res.TypedArray.getColor(TypedArray.java:463)
at com.viewpagerindicator.CirclePageIndicator.<init>(CirclePageIndicator.java:96)
at com.viewpagerindicator.CirclePageIndicator.<init>(CirclePageIndicator.java:72)
at java.lang.reflect.Constructor.newInstance0(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:430)
at android.view.LayoutInflater.createView(LayoutInflater.java:645)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:787)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:858)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
at android.view.LayoutInflater.inflate(LayoutInflater.java:518)
at android.view.LayoutInflater.inflate(LayoutInflater.java:426)
at android.view.LayoutInflater.inflate(LayoutInflater.java:377)
at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)
at com.sankuai.mhotel.GuideActivity.onCreate(GuideActivity.java:48)
at android.app.Activity.performCreate(Activity.java:6679)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2618)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776) targetSdkVersion is 26 |
@zhouchaoyuan , |
@janbolat , I have tried this before,it doesn't work for me. |
I'm trying to set colors like that:
It worked before, but now it throws:
android.view.InflateException: Binary XML file line #16: Binary XML file line #17: Error inflating class com.viewpagerindicator.CirclePageIndicator
caused by: java.lang.UnsupportedOperationException: Can't convert to dimension: type=0x1d
I've tried to set
@color/color_primary
values and '#ff00ff' color hex values: the same issue.As a workaround: I set all needed colors in runtime by calling
setFillColor()
,setPageColor()
andsetStrokeColor()
respectively.The text was updated successfully, but these errors were encountered: