我的应用在更新为Android Studio 3 RC1
(Gradle
4,Android Gradle
插件3 RC2)后崩溃。
This is the error I am having:
java.lang.RuntimeException: Unable to start activity ComponentInfo{*****}:
android.view.InflateException: Binary XML file line #0: Binary XML file line #0:
Error inflating class com.viewpagerindicator.CirclePageIndicator
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2817)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2892)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1593)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6541)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
Caused by: android.view.InflateException: Binary XML file line #0: Binary XML file line #0: Error inflating class com.viewpagerindicator.CirclePageIndicator
Caused by: android.view.InflateException: Binary XML file line #0: Error inflating class com.viewpagerindicator.CirclePageIndicator
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance0(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:334)
at android.view.LayoutInflater.createView(LayoutInflater.java:647)
at uk.co.chrisjenx.calligraphy.CalligraphyLayoutInflater.createCustomViewInternal(CalligraphyLayoutInflater.java:211)
at uk.co.chrisjenx.calligraphy.CalligraphyLayoutInflater.access$000(CalligraphyLayoutInflater.java:20)
at uk.co.chrisjenx.calligraphy.CalligraphyLayoutInflater$PrivateWrapperFactory2.onCreateView(CalligraphyLayoutInflater.java:302)
at android.view.LayoutInflater$FactoryMerger.onCreateView(LayoutInflater.java:186)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:780)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:730)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:863)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:866)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:866)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
at uk.co.chrisjenx.calligraphy.CalligraphyLayoutInflater.inflate(CalligraphyLayoutInflater.java:60)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)
at com.raimbekov.android.sajde.zikr.ZikrActivity.onCreate(ZikrActivity.java:195)
at android.app.Activity.performCreate(Activity.java:6975)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1213)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2770)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2892)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1593)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6541)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
Caused by: java.lang.UnsupportedOperationException: Can't convert value at index 5 to color: type=0x5
10-20 10:48:09.562 6156-6156 E/AndroidRuntime: at android.content.res.TypedArray.getColor(TypedArray.java:473)
at com.viewpagerindicator.CirclePageIndicator.<init>(CirclePageIndicator.java:96)
at com.viewpagerindicator.CirclePageIndicator.<init>(CirclePageIndicator.java:72)
... 34 more
我在更新前没有遇到此问题(在Android Studio
2上)。它也在github上描述,但没有答案。
答案 0 :(得分:27)
更改
compile 'com.viewpagerindicator:library:2.4.1@aar'
要
compile 'com.github.JakeWharton:ViewPagerIndicator:2.4.1'
它会起作用。该库存在问题。
答案 1 :(得分:6)
jitpack.io
使用cpi:
使用android gradle插件3.0无法为我工作。
相反,我必须以编程方式设置我之前在xml布局中使用app:
(或<com.viewpagerindicator.CirclePageIndicator
cpi:fillColor="@color/azure"
cpi:pageColor="@color/white"
cpi:radius="4dp"
cpi:snap="true"
cpi:strokeWidth="0dp" />
)属性设置的所有视图属性。
实施例
cpi:
我删除了所有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);
属性并以编程方式设置它们:
compileSdkVersion
答案 2 :(得分:6)
我的项目使用android gradle plugin 3.0和compileSdk 27.我无法使用此线程中建议的解决方案(ViewPager#removeOnPageChangeListener
)使其与此设置一起使用。
它抱怨支持库的第24版中添加了allprojects {
repositories {
maven { url "https://jitpack.io" }
}
}
不存在的方法。我认为这与图书馆直接烘焙了android-support-v4.jar这一事实有关。
我不想查看我的所有xml文件并以编程方式设置属性,所以我最终创建了一个使用gradle构建库的fork,并将compileSdk / minSdk / support-v4更新为更现代的版本。
您可以在https://github.com/splatte/ViewPagerIndicator
找到该项目要在项目中使用它,请从jitpack中获取它,如下所示:
dependencies {
implementation 'com.github.splatte:ViewPagerIndicator:3.0.0'
}
然后:
$EmployeeLeaveModel->EmployeeID = value;
(必须有另一个项目在ViewPagerIndicator拥有的4.300分叉的海洋中执行此操作,但我不知道如何找到它。)
答案 3 :(得分:4)
我发现jitpack.io
是最简单的方法:
allprojects {
repositories {
maven { url "https://jitpack.io" }
}
}
然后:
dependencies {
implementation ('com.github.JakeWharton:ViewPagerIndicator:2.4.1'){
exclude module: 'support-v4'
}
}
请注意,在我排除其中一个版本之前,有两个版本的support-v4库已经破坏了它。