RichPath
RichPath copied to clipboard
Crash on Android 4.1 and 4.4 - Binary XML file line #94: Error inflating class com.richpath.RichPathView
My Gradle
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.simplekana"
minSdkVersion 16
targetSdkVersion 28
versionCode 7
versionName "2.3"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
...
implementation 'com.github.tarek360.RichPath:animator:0.1.1'
When I run the application on API 28 everything works fine When I run the application on API 16 (Android 4.1) or 19 (Android 4.4), the application crashes
Error
Binary XML file line #94: Error inflating class com.richpath.RichPathView
Could you help please A lot of thanks!
oh too old Android version :D please provide you vector drawable file.
I found a solution.
In your app's build.gradle you need to include
android {
defaultConfig {
vectorDrawables.useSupportLibrary = true
}
}
And for vector support for less then API 21, add the following to onCreate
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
It works, but the animation doesn't work as it should. I need the lines to be drawn one by one (I show how to draw the Japanese alphabet). Now the first line is being drawn and the rest lines just appear (no drawing)
Here is the animation code (for API 28 works as expected)
private void svgDrawLines() {
long delay = 500;
long speed = 1000;
String kanaPrefix = alphabetType == AlphabetModel.AlphabetType.hiragana ? "h" : "k";
svgView.setVectorDrawable(getResources().getIdentifier(kanaPrefix + "_" + AbcModel.latinRows.get(rowNumber).get(selectedItem), "drawable",
MyApplication.context.getPackageName()));
RichPath[] svgPath = svgView.findAllRichPaths();
for (RichPath path: svgPath) {
path.setStrokeColor(getResources().getColor(android.R.color.transparent));
// TODO: только первый раз работает изменение толщины линий, а последующие нет
// path.setWidth(5);
RichPathAnimator.animate(path)
.trimPathEnd(0,1)
.startDelay(delay)
.duration(speed)
.strokeColor(getResources().getColor(R.color.colorSilver))
.start();
delay = delay + speed;
}
}
Vector drawable file
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="109dp"
android:height="109dp"
android:viewportWidth="109"
android:viewportHeight="109">
<path
android:strokeColor="#000000"
android:strokeWidth="3"
android:strokeLineJoin="round"
android:strokeLineCap="round"
android:pathData="M31.01,33c0.88,0.88,2.75,1.82,5.25,1.75c8.62-0.25,20-2.12,29.5-4.25c1.51-0.34,4.62-0.88,6.62-0.5" />
<path
android:strokeColor="#000000"
android:strokeWidth="3"
android:strokeLineJoin="round"
android:strokeLineCap="round"
android:pathData="M49.76,17.62c0.88,1,1.82,3.26,1.38,5.25c-3.75,16.75-6.25,38.13-5.13,53.63c0.41,5.7,1.88,10.88,3.38,13.62" />
<path
android:strokeColor="#000000"
android:strokeWidth="3"
android:strokeLineJoin="round"
android:strokeLineCap="round"
android:pathData="M65.63,44.12c0.75,1.12,1.16,4.39,0.5,6.12c-4.62,12.26-11.24,23.76-25.37,35.76c-6.86,5.83-15.88,3.75-16.25-8.38c-0.34-10.87,13.38-23.12,32.38-26.74c12.42-2.37,27,1.38,30.5,12.75c4.05,13.18-3.76,26.37-20.88,30.49" />
</vector>
So How to fix animation? Or another solution for correctly work?
Thanks!