error no resource identifier found for attribute 'indeterminateTint' in package 'android'

本文解决了一个关于在XML布局文件中使用ProgressBar组件时出现的错误,该错误提示找不到属性'indeterminateTint'。通过确认项目目标API级别为21及以上,并进行项目清理等步骤解决了问题。

 


I'm trying to create an XML ProgressBar.
When i add the attributes android:indeterminateTint and android:progressBackgroundTint to the ProgressBar i'm getting the error error no resource identifier found for attribute 'indeterminateTint' in package 'android' when i compile the project.
I'm using Eclipse if that maters.

The code:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/background"
    android:gravity="center" >

    <ProgressBar
        android:id="@+id/loader_animation"
        android:layout_width="60dp"
        android:layout_height="60dp"
        android:indeterminate="true"
        android:indeterminateTint="#ffffff"
        android:progressBackgroundTint="#000000" />

</RelativeLayout>

What am i doing wrong?




That attribute was added in API 21. Is your project targeting API 21? –  Christian Göllner  Nov 18 '14 at 3:34
 
@ChristianGöllner Yes it is –  Presen  Nov 18 '14 at 3:37
 
then I would try the usual Eclipse stuff. Build -> Clean -> All projects. Can't remember anything else that could be the problem. –  Christian Göllner  Nov 18 '14 at 3:39
2 
Also, don't forget that you have to target API 21 in AndroidManifest.xml and also in the project properties. –  Christian Göllner  Nov 18 '14 at 3:40
 
What do you mean by project properties? –  Presen  Nov 18 '14 at 3:53


遇到类似问题:

 ogsdklib/res/layout/personal_info.xml:188: error: No resource identifier found for attribute 'buttonTint' in package 'android' 

结合上面的问题及答复,将androidAPI选择5.0就没问题了。


Android 开发中遇到找不到属性 `enableOnBackInvokedCallback` 的资源标识符,通常是由于以下几种原因,可按相应方法解决: ### 1. 版本兼容性问题 `enableOnBackInvokedCallback` 是 Android 13(API 级别 33)引入的特性,如果项目的 `minSdkVersion` 低于 33,或者使用的 Android 支持库版本不兼容,就会出现找不到该属性的情况。 - **解决方案**: - 确保 `minSdkVersion` 不低于 33,可在项目的 `build.gradle` 文件中进行修改: ```groovy android { compileSdkVersion 33 buildToolsVersion "33.0.0" defaultConfig { applicationId "com.example.app" minSdkVersion 33 targetSdkVersion 33 versionCode 1 versionName "1.0" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } // ... } ``` - 同时,要保证使用的 AndroidX 库是最新版本,在 `build.gradle` 文件中更新依赖: ```groovy dependencies { implementation 'androidx.appcompat:appcompat:1.6.1' // 其他依赖... } ``` ### 2. 资源引用问题 有时候资源标识符找不到是因为资源文件没有正确引用或配置。 - **解决方案**: - 检查布局文件或代码中对 `enableOnBackInvokedCallback` 的引用是否正确,确保没有拼写错误。 - 尝试清理并重新构建项目,在 Android Studio 中选择 `Build` -> `Clean Project`,然后再选择 `Build` -> `Rebuild Project`。 ### 3. 缺少必要的导入 如果在代码中使用该属性,可能是缺少必要的导入语句。 - **解决方案**: - 确保在使用 `enableOnBackInvokedCallback` 的类中导入了正确的包,例如: ```java import androidx.activity.OnBackPressedCallback; import androidx.activity.ComponentActivity; ``` ### 4. 缓存问题 Android Studio 的缓存可能会导致资源标识符无法正确识别。 - **解决方案**: - 可以尝试清除 Android Studio 的缓存,选择 `File` -> `Invalidate Caches / Restart`,然后在弹出的对话框中选择 `Invalidate and Restart`。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值