Android-资源未链接

时间:2019-02-09 07:10:35

标签: 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>

请帮助。谢谢。

1 个答案:

答案 0 :(得分:1)

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

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