java - Android - 资源未链接

标签 java android resources android-resources

我的项目运行良好,突然开始显示资源链接失败错误。无法构建项目。 获取资源链接失败错误。它让我看到 values.xml 文件。 但无法找出错误。

 Android resource linking failed
    Output:  warn: removing resource com.creditone.admin.OnBoarding:string/logOut without required default value.
    warn: removing resource com.creditone.admin.OnBoarding:string/wrongNumberWarning without required default value.
    E:\On Boarding App\OnBoardingApp\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values-v28\values-v28.xml:7: error: resource android:attr/dialogCornerRadius not found.
    E:\On Boarding App\OnBoardingApp\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values-v28\values-v28.xml:11: error: resource android:attr/dialogCornerRadius not found.
    E:\On Boarding App\OnBoardingApp\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:602: error: resource android:attr/fontVariationSettings not found.
    E:\On Boarding App\OnBoardingApp\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:602: error: resource android:attr/ttcIndex not found.
    error: failed linking references.

    Command: C:\Users\Intel\.gradle\caches\transforms-1\files-1.1\aapt2-3.2.1-4818971-windows.jar\6f8a19afba4ded03991ba2724772ffb5\aapt2-3.2.1-4818971-windows\aapt2.exe link -I\
            C:\Users\Intel\AppData\Local\Android\Sdk\platforms\android-27\android.jar\
            --manifest\
            E:\On Boarding App\OnBoardingApp\app\build\intermediates\merged_manifests\debug\processDebugManifest\merged\AndroidManifest.xml\
            -o\
            E:\On Boarding App\OnBoardingApp\app\build\intermediates\processed_res\debug\processDebugResources\out\resources-debug.ap_\
            -R\
            @E:\On Boarding App\OnBoardingApp\app\build\intermediates\incremental\processDebugResources\resources-list-for-resources-debug.ap_.txt\
            --auto-add-overlay\
            --java\
            E:\On Boarding App\OnBoardingApp\app\build\generated\not_namespaced_r_class_sources\debug\processDebugResources\r\
            --custom-package\
            com.creditone.admin.OnBoarding\
            -0\
            apk\
            --no-version-vectors\
            --output-text-symbols\
            E:\On Boarding App\OnBoardingApp\app\build\intermediates\symbols\debug\R.txt\
            --no-version-vectors
    Daemon:  AAPT2 aapt2-3.2.1-4818971-windows Daemon #0

在这两行下面显示错误

App\OnBoardingApp\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:602: error: resource android:attr/fontVariationSettings not found.
    E:\On Boarding App\OnBoardingApp\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:602: error: resource android:attr/ttcIndex not found.

单击上面的链接,它会打开 values.xml 文件并显示以下行

 <declare-styleable name="FontFamilyFont"><attr name="fontStyle">
            <enum name="normal" value="0"/>
            <enum name="italic" value="1"/>
        </attr><attr format="reference" name="font"/><attr format="integer" name="fontWeight"/><attr format="string" name="fontVariationSettings"/><attr format="integer" name="ttcIndex"/><attr name="android:fontStyle"/><attr name="android:font"/><attr name="android:fontWeight"/><attr name="android:fontVariationSettings"/><attr name="android:ttcIndex"/></declare-styleable>
    <declare-styleable name="ForegroundLinearLayout"><attr name="android:foreground"/><attr name="android:foregroundGravity"/><attr format="boolean" name="foregroundInsidePadding"/></declare-styleable>
    <declare-styleable name="GradientColor">
        <!-- Start color of the gradient. -->
        <attr name="android:startColor"/>
        <!-- Optional center color. -->
        <attr name="android:centerColor"/>
        <!-- End color of the gradient. -->
        <attr name="android:endColor"/>
        <!-- Type of gradient. The default type is linear. -->
        <attr name="android:type"/>

        <!-- Only applied to RadialGradient-->
        <!-- Radius of the gradient, used only with radial gradient. -->
        <attr name="android:gradientRadius"/>

        <!-- Only applied to SweepGradient / RadialGradient-->
        <!-- X coordinate of the center of the gradient within the path. -->
        <attr name="android:centerX"/>
        <!-- Y coordinate of the center of the gradient within the path. -->
        <attr name="android:centerY"/>

        <!-- LinearGradient specific -->
        <!-- X coordinate of the start point origin of the gradient.
             Defined in same coordinates as the path itself -->
        <attr name="android:startX"/>
        <!-- Y coordinate of the start point of the gradient within the shape.
             Defined in same coordinates as the path itself -->
        <attr name="android:startY"/>
        <!-- X coordinate of the end point origin of the gradient.
             Defined in same coordinates as the path itself -->
        <attr name="android:endX"/>
        <!-- Y coordinate of the end point of the gradient within the shape.
             Defined in same coordinates as the path itself -->
        <attr name="android:endY"/>

        <!-- Defines the tile mode of the gradient. SweepGradient doesn't support tiling. -->
        <attr name="android:tileMode"/>
    </declare-styleable>

请帮忙。谢谢。

最佳答案

tl;dr:将您的编译 SDK 版本更新为 28。

更长的答案:您或您所依赖的库正在尝试使用 API 28 中的资源(即 ttcIndex、fontVariationSettings)。它很可能是支持库的某个版本,并且您有明确的版本 28 依赖项或“+”依赖项,然后使用最新的可用版本库。如果你的SDK低于28,这些资源在编译SDK中是不存在的,AAPT2无法链接资源(无法解析引用)。升级到最新的 SDK (28) 应该可以解决这个问题。

关于java - Android - 资源未链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54604066/

相关文章:

java - Google-App-Engine 中的预定电子邮件 - Java

android - 如何使用Android Profiler在Android中查找不需要的引用

屏幕锁定时调用的 Android Activity onDestroy()

android - 从字符串资源中引用 XML 整数资源

C++ 在运行时修改资源

Bamboo 中的 Java 堆大小错误

java - 无法与远程服务器上的 RMI 注册表建立连接

java - 使用 Java Topology Suite 或 GeoTools 解析 GeoJSON 文件

android - 导入按钮是否从解析仪表板数据浏览器中删除了?

image - Grails Controller 中的资源路径