<animated-vector> API level 21 is required (current minimum is 15)

It mentions [here] [1] that the new support library now supports animated vectors that were previously only supported in API 21+. I updated my support library to the latest version.

But Android Studio still gives me a warning: an animated vector requires API level 21 (the current minimum is 15).

I have done the following:

I added the following codes for build.gradle:

defaultConfig { generatedDensities = [] } // This is handled for you by the 2.0+ Gradle Plugin aaptOptions { additionalParameters "--no-version-vectors" } 

So now my build.gradle file looks like this:

 apply plugin: 'com.android.application' android { compileSdkVersion 23 buildToolsVersion "23.0.2" defaultConfig { applicationId "com.example.mahdi.askhow" minSdkVersion 15 targetSdkVersion 23 versionCode 1 versionName "1.0" generatedDensities = [] } // This is handled for you by the 2.0+ Gradle Plugin aaptOptions { additionalParameters "--no-version-vectors" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } } repositories { mavenCentral() maven { url "https://jitpack.io" } } dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) testCompile 'junit:junit:4.12' compile 'com.android.support:appcompat-v7:23.2.0' compile 'com.android.support:design:23.2.0' compile 'com.mcxiaoke.volley:library:1.0.19' compile 'com.wang.avi:library:1.0.2' compile 'com.nineoldandroids:library:2.4.0' compile project(':phoenix') compile 'com.github.dmytrodanylyk.circular-progress-button:library:1.1.3' } 

My animation drawing:

 <?xml version="1.0" encoding="utf-8"?> <animated-vector xmlns:android="http://schemas.android.com/apk/res/android" android:drawable="@drawable/vector_upvote"> <target android:name="rotationGroup" android:animation="@anim/rotate_a_to_b" /> <target android:name="left_arrow" android:animation="@animator/animator_checkmark" /> </animated-vector> 

In the first line of the animation drawing, he says: an animated vector requires API level 21 (the current minimum is 15).

So what's wrong?

  [1]: http://android-developers.blogspot.com/2016/02/android-support-library-232.html 
+7
android
source share
1 answer

Ok I checked it out. IT WORKS! I created an animated vector and added it to the layout:

 <ImageView android:id="@+id/animated" android:layout_width="match_parent" android:layout_height="80dp" app:srcCompat="@drawable/animated" /> 

And this is for the code:

 ImageView animatedView = (ImageView) findViewById(R.id.animated); Drawable animation = animatedView.getDrawable(); if (animation instanceof Animatable) { ((Animatable) animation).start(); } 

Android studio will show me that this can be done in the preview, but the application crashed at the start (Android 4.0)

Then I replaced android:src with app:srcCompat , and the preview was broken. But this application started on Android 4.0, and animation works.

Conclusion : library support works. Android Studio (1.5.1) is not ready yet.

+9
source share

All Articles