Nó được đề cập [ở đây] [1] rằng thư viện hỗ trợ mới hiện hỗ trợ vectơ hoạt hình, trước đây chỉ được hỗ trợ trong API 21+. Tôi đã nâng cấp thư viện hỗ trợ của mình lên phiên bản mới nhất.<animated-vector> yêu cầu cấp API 21 (min hiện tại là 15)
Nhưng Android Studio vẫn cho tôi cảnh báo: hoạt ảnh-vector yêu cầu cấp API 21 (min hiện tại là 15).
tôi đã làm các nội dung sau:
tôi đã thêm các mã sau đây để build.gradle:
defaultConfig {
generatedDensities = []
}
// This is handled for you by the 2.0+ Gradle Plugin
aaptOptions {
additionalParameters "--no-version-vectors"
}
Bây giờ tập tin build.gradle của tôi trông như thế này:
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'
}
hoạt hình của tôi drawable:
<?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>
Trên dòng đầu tiên của hoạt hình drawable, nó nói: hoạt hình-vector yêu cầu cấp API 21 (min hiện tại là 15).
Vậy có gì sai?
[1]: http://android-developers.blogspot.com/2016/02/android-support-library-232.html
Mã có chạy không? Tôi nhận thấy rằng có một cảnh báo được đưa ra khi sử dụng ứng dụng mới: thuộc tính srcCompat trong xml. Tuy nhiên nó chỉ là một kiểm tra lint không và mã chạy. Họ có thể sẽ sửa chữa nó trong bản phát hành studio tiếp theo. – Jahnold
Alex đã trả lời. Có, vẫn tồn tại cảnh báo khi sử dụng: app: srcCompat, có vẻ như chúng ta phải bỏ qua cảnh báo và đợi bản cập nhật cho studio. – SMahdiS