簡體   English   中英

Android - 資源未鏈接

[英]Android - Resource not getting linked

我的項目運行良好,突然開始顯示資源鏈接失敗錯誤。 無法構建項目。 獲取資源鏈接失敗錯誤。 它讓我進入 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) 應該可以解決這個問題。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM