Xin chào stackoverflower thân yêu,Android XML: RuntimeException: Không thể giải quyết thuộc tính tại chỉ số 6
Trong dự án của tôi, tôi đang sử dụng thư viện "thiết kế android" mới. Vấn đề là, rằng có một ngoại lệ thời gian chạy mà nói (Im cố gắng để tạo ra một FloatingButton):
java.lang.RuntimeException: Failed to resolve attribute at index 6
at android.content.res.TypedArray.getColorStateList(TypedArray.java:426)
at android.support.design.widget.FloatingActionButton.<init>(FloatingActionButton.java:91)
at android.support.design.widget.FloatingActionButton.<init>(FloatingActionButton.java:79)
at android.support.design.widget.FloatingActionButton.<init>(FloatingActionButton.java:75)
tôi đã có thể tìm ra, mà các thuộc tính không thể được giải quyết:
<style name="Widget.Design.FloatingActionButton" parent="android:Widget">
<item name="android:background">@drawable/fab_background</item>
<item name="backgroundTint">?attr/colorAccent</item> **!! this one is missing !!**
<item name="fabSize">normal</item>
<item name="elevation">@dimen/fab_elevation</item>
<item name="pressedTranslationZ">@dimen/fab_translation_z_pressed</item>
<item name="rippleColor">?attr/colorControlHighlight</item>
<item name="borderWidth">@dimen/fab_border_width</item>
</style>
Điều này nằm trong res/values / styles/styles.xml trong android-design-library
tôi đã đọc trong this bài đăng mà API lvl phải bis 21+. Nhưng khi thư viện thiết kế hỗ trợ API 7+, đây không phải là vấn đề thực sự.
Nó cũng đáng đề cập đến mà tôi đã không bao gồm các thư viện thiết kế như một gradle-phụ thuộc như thế này:
compile 'com.android.support:design:22.2.0'
tôi thêm thư viện một cách thủ công để dự án do máy chủ Jenkins không có kết nối Internet . Tôi đã cập nhật thư viện hỗ trợ-v4 thành 21.2.0 cũng bao gồm và cập nhật hỗ trợ appcompat-v7.
Đây là android-thiết kế-thư viện tập tin gradle:
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
minSdkVersion 17
targetSdkVersion 21
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
Nó sẽ là tuyệt vời nếu ai đó có thể giúp tôi.
Rất tiếc, ứng dụng của tôi không có thuộc tính 'colorAccent', vì tôi không sử dụng AppCompat. Giải pháp tôi đăng sẽ hoạt động cho các nhà phát triển có thiết lập tương tự như tôi đã mô tả. –
Dude ... bạn là người giỏi nhất .. 3 ngày đập đầu tôi .. bạn đã giải quyết được vấn đề. – Mitech