android - 更新到 Android Studio,现在收到 AAPT : error: resource attr/type not found error for Navigation

标签 android gradle aapt aapt2

我刚刚更新到 Android Studio 3.6.1 和最新的 gradle 版本,现在我的项目不会出现错误

.gradle/caches/transforms-2/files-2/<some-hash-number>/navigation-common-1.0.0-alpha01/res/values/values.xml:16:5-21-25: AAPT: error: resource attracts/type not found

我试图清除我的缓存并重建,但它没有帮助。所以我也尝试了无效缓存并重新启动,这也没有改变任何东西。不知道还有什么可以尝试...

编辑:添加 Values.xml。
<?xml version="1.0" encoding="utf-8"?>
<resources>
    <declare-styleable name="NavAction">
        <attr name="android:id"/>
        <attr format="reference" name="destination"/>
        <attr format="boolean" name="launchSingleTop"/>
        <attr format="boolean" name="launchDocument"/>
        <attr format="boolean" name="clearTask"/>
        <attr format="reference" name="popUpTo"/>
        <attr format="boolean" name="popUpToInclusive"/>
        <attr format="reference" name="enterAnim"/>
        <attr format="reference" name="exitAnim"/>
        <attr format="reference" name="popEnterAnim"/>
        <attr format="reference" name="popExitAnim"/>
    </declare-styleable>
    <declare-styleable name="NavArgument">
        <attr name="android:name"/>
        <attr name="android:defaultValue"/>
        <!--free format since in future it could be Parcelable-->
        <attr name="type"/>
    </declare-styleable>
    <declare-styleable name="NavDeepLink">
        <attr format="string" name="uri"/>
        <attr name="android:autoVerify"/>
    </declare-styleable>
    <declare-styleable name="NavGraphNavigator">
        <attr format="reference" name="startDestination"/>
    </declare-styleable>
    <declare-styleable name="Navigator">
        <attr name="android:id"/>
        <attr name="android:label"/>
    </declare-styleable>
</resources>

最佳答案

升级到 Android Studio 3.6 后我遇到了同样的问题。为了解决这个问题,我必须在我的 attrs.xml 中添加自定义 View 属性的格式。文件。例如。

<declare-styleable name="TheCustomView">
    <attr name="custom_view_attribute" />
</declare-styleable>

变成:
<declare-styleable name="TheCustomView">
    <attr name="custom_view_attribute" format="string" />
</declare-styleable>

关于android - 更新到 Android Studio,现在收到 AAPT : error: resource attr/type not found error for Navigation,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60536172/

相关文章:

android - 在android中从上到下删除画廊中的滑动效果

android - IntelliJ Idea Android 项目 : Gradle project sync failed

spring - 使用Gradle生成EAR(JBoss的Spring应用程序)

java - Gradle 应用程序插件在运行应用程序时卡在 96%?

android - Xamarin Studio 2 - 最新的稳定更新 - 执行任务 Aapt : The source sequence is empty 时出错

android - adb shell 命令检查 apk 是调试还是发布签名?

java - 如何使用 WiFi Direct 打印文本文件

android - 如何强制 Eclipse 重新创建 R(=资源)文件?

javascript - 使用 POST 请求在 PHP 中查询 "SELECT * FROM .... WHERE ..."

android - Eclipse 无法构建 Android 项目