Android Studio Android资源链接失败错误.. AAPT:错误:未找到资源android:attr/lStar,

yiytaume  于 2022-11-16  发布在  Android
关注(0)|答案(2)|浏览(553)

起初我能够运行一切没有问题,但突然这个错误开始出现,每次我试图建立指向我这个xml文件特别:C:\用户\联想.gradle\缓存\转换-2\文件-2.1\f243f87f287fb4f4052bd069a9b71980\core-1.7.0\res\values\values.xml:105:5..表示AAPT:error:resource android:attr/lStar not found我甚至尝试创建一个新的空项目,但每次尝试运行时问题仍然发生..那么,在此XML文件中创建的问题是什么?
下面是我的代码文件:
values.xml文件:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <attr format="reference" name="nestedScrollViewStyle"/>
    <color name="androidx_core_ripple_material_light">#1f000000</color>
    <color name="androidx_core_secondary_text_default_material_light">#8a000000</color>
    <color name="notification_action_color_filter">#ffffffff</color>
    <color name="notification_icon_bg_color">#ff9e9e9e</color>
    <dimen name="compat_button_inset_horizontal_material">4dp</dimen>
    <dimen name="compat_button_inset_vertical_material">6dp</dimen>
    <dimen name="compat_button_padding_horizontal_material">8dp</dimen>
    <dimen name="compat_button_padding_vertical_material">4dp</dimen>
    <dimen name="compat_control_corner_material">2dp</dimen>
    <dimen name="compat_notification_large_icon_max_height">320dp</dimen>
    <dimen name="compat_notification_large_icon_max_width">320dp</dimen>
    <dimen name="notification_action_icon_size">32dp</dimen>
    <dimen name="notification_action_text_size">13sp</dimen>
    <dimen name="notification_big_circle_margin">12dp</dimen>
    <dimen name="notification_content_margin_start">8dp</dimen>
    <dimen name="notification_large_icon_height">64dp</dimen>
    <dimen name="notification_large_icon_width">64dp</dimen>
    <dimen name="notification_main_column_padding_top">10dp</dimen>
    <dimen name="notification_media_narrow_margin">@dimen/notification_content_margin_start</dimen>
    <dimen name="notification_right_icon_size">16dp</dimen>
    <dimen name="notification_right_side_padding_top">2dp</dimen>
    <dimen name="notification_small_icon_background_padding">3dp</dimen>
    <dimen name="notification_small_icon_size_as_large">24dp</dimen>
    <dimen name="notification_subtext_size">13sp</dimen>
    <dimen name="notification_top_pad">10dp</dimen>
    <dimen name="notification_top_pad_large_text">5dp</dimen>
    <drawable name="notification_template_icon_bg">#3333B5E5</drawable>
    <drawable name="notification_template_icon_low_bg">#0cffffff</drawable>
    <item name="accessibility_action_clickable_span" type="id"/>
    <item name="accessibility_custom_action_0" type="id"/>
    <item name="accessibility_custom_action_1" type="id"/>
    <item name="accessibility_custom_action_10" type="id"/>
    <item name="accessibility_custom_action_11" type="id"/>
    <item name="accessibility_custom_action_12" type="id"/>
    <item name="accessibility_custom_action_13" type="id"/>
    <item name="accessibility_custom_action_14" type="id"/>
    <item name="accessibility_custom_action_15" type="id"/>
    <item name="accessibility_custom_action_16" type="id"/>
    <item name="accessibility_custom_action_17" type="id"/>
    <item name="accessibility_custom_action_18" type="id"/>
    <item name="accessibility_custom_action_19" type="id"/>
    <item name="accessibility_custom_action_2" type="id"/>
    <item name="accessibility_custom_action_20" type="id"/>
    <item name="accessibility_custom_action_21" type="id"/>
    <item name="accessibility_custom_action_22" type="id"/>
    <item name="accessibility_custom_action_23" type="id"/>
    <item name="accessibility_custom_action_24" type="id"/>
    <item name="accessibility_custom_action_25" type="id"/>
    <item name="accessibility_custom_action_26" type="id"/>
    <item name="accessibility_custom_action_27" type="id"/>
    <item name="accessibility_custom_action_28" type="id"/>
    <item name="accessibility_custom_action_29" type="id"/>
    <item name="accessibility_custom_action_3" type="id"/>
    <item name="accessibility_custom_action_30" type="id"/>
    <item name="accessibility_custom_action_31" type="id"/>
    <item name="accessibility_custom_action_4" type="id"/>
    <item name="accessibility_custom_action_5" type="id"/>
    <item name="accessibility_custom_action_6" type="id"/>
    <item name="accessibility_custom_action_7" type="id"/>
    <item name="accessibility_custom_action_8" type="id"/>
    <item name="accessibility_custom_action_9" type="id"/>
    <item name="line1" type="id"/>
    <item name="line3" type="id"/>
    <item name="tag_accessibility_actions" type="id"/>
    <item name="tag_accessibility_clickable_spans" type="id"/>
    <item name="tag_accessibility_heading" type="id"/>
    <item name="tag_accessibility_pane_title" type="id"/>
    <item name="tag_on_apply_window_listener" type="id"/>
    <item name="tag_on_receive_content_listener" type="id"/>
    <item name="tag_on_receive_content_mime_types" type="id"/>
    <item name="tag_screen_reader_focusable" type="id"/>
    <item name="tag_state_description" type="id"/>
    <item name="tag_transition_group" type="id"/>
    <item name="tag_unhandled_key_event_manager" type="id"/>
    <item name="tag_unhandled_key_listeners" type="id"/>
    <item name="tag_window_insets_animation_callback" type="id"/>
    <item name="text" type="id"/>
    <item name="text2" type="id"/>
    <item name="title" type="id"/>
    <integer name="status_bar_notification_info_maxnum">999</integer>
    <string name="status_bar_notification_info_overflow">999+</string>
    <style name="TextAppearance.Compat.Notification" parent="@android:style/TextAppearance.StatusBar.EventContent"/>
    <style name="TextAppearance.Compat.Notification.Info">
        <item name="android:textSize">12sp</item>
        <item name="android:textColor">?android:attr/textColorSecondary</item>
    </style>
    <style name="TextAppearance.Compat.Notification.Line2" parent="TextAppearance.Compat.Notification.Info"/>
    <style name="TextAppearance.Compat.Notification.Time">
        <item name="android:textSize">12sp</item>
        <item name="android:textColor">?android:attr/textColorSecondary</item>
    </style>
    <style name="TextAppearance.Compat.Notification.Title" parent="@android:style/TextAppearance.StatusBar.EventContent.Title"/>
    <style name="Widget.Compat.NotificationActionContainer" parent=""/>
    <style name="Widget.Compat.NotificationActionText" parent=""/>
    <declare-styleable name="Capability">
        <!-- Resource reference to the string array of query patterns for a custom capability. -->
        <attr format="reference" name="queryPatterns"/>
        <!-- Indicates whether a parameter in a capability template can only contain a matched
             shortcut id and not an arbitrary string. -->
        <attr format="boolean" name="shortcutMatchRequired"/>
    </declare-styleable>
    <declare-styleable name="ColorStateListItem">
        <!-- Base color for this state. -->
        <attr name="android:color"/>
        <!-- Alpha multiplier applied to the base color. -->
        <attr format="float" name="alpha"/>
        <attr name="android:alpha"/>
        <!-- Perceptual luminance applied to the base color. From 0 to 100. -->
        <attr format="float" name="lStar"/>
        <attr name="android:lStar"/>
    </declare-styleable>
    <declare-styleable name="FontFamily">
        <!-- The authority of the Font Provider to be used for the request. -->
        <attr format="string" name="fontProviderAuthority"/>
        <!-- The package for the Font Provider to be used for the request. This is used to verify
        the identity of the provider. -->
        <attr format="string" name="fontProviderPackage"/>
        <!-- The query to be sent over to the provider. Refer to your font provider's documentation
        on the format of this string. -->
        <attr format="string" name="fontProviderQuery"/>
        <!-- The sets of hashes for the certificates the provider should be signed with. This is
        used to verify the identity of the provider, and is only required if the provider is not
        part of the system image. This value may point to one list or a list of lists, where each
        individual list represents one collection of signature hashes. Refer to your font provider's
        documentation for these values. -->
        <attr format="reference" name="fontProviderCerts"/>
        <!-- The strategy to be used when fetching font data from a font provider in XML layouts.
        This attribute is ignored when the resource is loaded from code, as it is equivalent to the
        choice of API between {@link
    androidx.core.content.res.ResourcesCompat#getFont(Context, int)} (blocking) and
        {@link
    androidx.core.content.res.ResourcesCompat#getFont(Context, int, FontCallback, Handler)}
        (async). -->
        <attr name="fontProviderFetchStrategy">
            <!-- The blocking font fetch works as follows.
              First, check the local cache, then if the requested font is not cached, request the
              font from the provider and wait until it is finished.  You can change the length of
              the timeout by modifying fontProviderFetchTimeout.  If the timeout happens, the
              default typeface will be used instead. -->
            <enum name="blocking" value="0"/>
            <!-- The async font fetch works as follows.
              First, check the local cache, then if the requeted font is not cached, trigger a
              request the font and continue with layout inflation. Once the font fetch succeeds, the
              target text view will be refreshed with the downloaded font data. The
              fontProviderFetchTimeout will be ignored if async loading is specified. -->
            <enum name="async" value="1"/>
        </attr>
        <!-- The length of the timeout during fetching. -->
        <attr format="integer" name="fontProviderFetchTimeout">
            <!-- A special value for the timeout. In this case, the blocking font fetching will not
              timeout and wait until a reply is received from the font provider. -->
            <enum name="forever" value="-1"/>
        </attr>
        <!-- Provides the system font family name to check before downloading the font. For
        example if the fontProviderQuery asked for "Sans Serif", it is possible to define
        fontProviderSystemFontFamily as "sans-serif" to tell the system to use "sans-serif" font
        family if it exists on the system. -->
        <attr format="string" name="fontProviderSystemFontFamily"/>
    </declare-styleable>
    <declare-styleable name="FontFamilyFont">
        <!-- The style of the given font file. This will be used when the font is being loaded into
         the font stack and will override any style information in the font's header tables. If
         unspecified, the value in the font's header tables will be used. -->
        <attr name="fontStyle">
            <enum name="normal" value="0"/>
            <enum name="italic" value="1"/>
        </attr>
        <!-- The reference to the font file to be used. This should be a file in the res/font folder
         and should therefore have an R reference value. E.g. @font/myfont -->
        <attr format="reference" name="font"/>
        <!-- The weight of the given font file. This will be used when the font is being loaded into
         the font stack and will override any weight information in the font's header tables. Must
         be a positive number, a multiple of 100, and between 100 and 900, inclusive. The most
         common values are 400 for regular weight and 700 for bold weight. If unspecified, the value
         in the font's header tables will be used. -->
        <attr format="integer" name="fontWeight"/>
        <!-- The variation settings to be applied to the font. The string should be in the following
         format: "'tag1' value1, 'tag2' value2, ...". If the default variation settings should be
         used, or the font used does not support variation settings, this attribute needs not be
         specified. -->
        <attr format="string" name="fontVariationSettings"/>
        <!-- The index of the font in the tcc font file. If the font file referenced is not in the
        tcc format, this attribute needs not be specified. -->
        <attr format="integer" name="ttcIndex"/>
        <!-- References to the framework attrs -->
        <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="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>
    <declare-styleable name="GradientColorItem">
        <!-- The offset (or ratio) of this current color item inside the gradient.
             The value is only meaningful when it is between 0 and 1. -->
        <attr name="android:offset"/>
        <!-- The current color for the offset inside the gradient. -->
        <attr name="android:color"/>
    </declare-styleable>
</resources>

我的构建gradle文件:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 30
    buildToolsVersion "30.0.2"

    defaultConfig {
        applicationId "com.example.testing"
        minSdkVersion 19
        targetSdkVersion 30
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation 'androidx.appcompat:appcompat:1.4.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.2'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test.ext:junit:1.1.3'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'

}
7nbnzgx9

7nbnzgx91#

我按照Bashar Hamade的做法,复制粘贴了一个工作项目的build.gradle文件的内容。它实际上解决了这个问题。仔细看一下,我注意到了以下内容:
从以下位置设置核心和appcompat的实施依赖关系

...  
implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.appcompat:appcompat:1.4.0'
...

...
implementation 'androidx.core:core-ktx:1.6.0'
implementation 'androidx.appcompat:appcompat:1.3.1'
...

由于某些原因,只修改其中一个并不能解决问题。我想core-ktx:1.6.0和appcompat:1.3.1是一起工作的。你不能只修改其中一个而不修改另一个。
顺便说一句,这个问题似乎来自于最近的Android Studio升级。

fykwrbwg

fykwrbwg2#

对我来说,工作更新在build.gradle:

compileSdkVersion = 31
targetSdkVersion = 31

所以把30改成31。

相关问题