相关疑难解决方法(0)

无法在styles.xml(Android Studio)中解析符号'Theme'

截图

从今天开始,Android Studio无法在styles.xml中找到AppCompat主题,但是例如代码中的AppCompatActivity确实得到了识别.我的Android Studio版本是2.2.2,Build#AI-145.3360264

我已经尝试升级到最新的构建工具,编译sdk(25)版本等,但它没有解决问题.

目前我安装了以下内容(来自sdk经理):

  • android api:19和23
  • sdk平台工具:25.0.1
  • sdk工具:25.2.3
  • 构建工具:23.0.2和25.0.1
  • 支持存储库:40
  • 谷歌存储库:39

和其他一些,这里没有必要列出.

app的build.gradle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion '25.0.1'
    defaultConfig {
        applicationId "xxx.xxxxxxxx.xxxxxxxxx" //not the real applicationId
        minSdkVersion 14
        targetSdkVersion 19
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled true
            shrinkResources true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
        debug {

        }
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile files('libs/RootTools.jar')
    compile 'com.android.support:support-v4:23.+'
    compile 'com.android.support:support-v13:23.+'
    compile 'com.android.support:appcompat-v7:23.+'
    compile 'com.android.support:design:23.+'
    compile 'com.android.support:cardview-v7:23.+'
    compile 'com.android.support.constraint:constraint-layout:1.0.0-beta4' …
Run Code Online (Sandbox Code Playgroud)

android android-appcompat gradle android-studio android-styles

175
推荐指数
10
解决办法
7万
查看次数

Android无法解析符号'?attr/selectableItemBackground'

<android.support.v7.widget.CardView
    android:id="@+id/card_view"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginLeft="@dimen/card_outer_padding"
    android:layout_marginTop="@dimen/card_outer_padding"
    android:layout_marginRight="@dimen/card_outer_padding"
    android:layout_marginBottom='@{model.cardBottomMargin}'
    android:foreground="?attr/selectableItemBackground"
    android:onClick="@{model::onCardClick}"
    app:cardElevation="2dp"
    app:cardCornerRadius="2dp"
    app:cardUseCompatPadding="true">
</android.support.v7.widget.CardView>
Run Code Online (Sandbox Code Playgroud)

我收到此错误消息

无法解析符号?attr/selectableItemBackground 验证Android XML文件中的资源引用.

<TextView
    android:id="@+id/country_name"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginRight="40dp"
    android:text="@{model.name}"
    style="@style/TextAppearance.AppCompat.Headline"
    tools:text="Country"/>
Run Code Online (Sandbox Code Playgroud)

而且,我也遇到了类似的错误

无法解析符号'@ style/TextAppearance.AppCompat.Headline'
验证Android XML文件中的资源引用.

任何指针都会很棒!谢谢!它似乎与此线程有关,但没有提供解决方案:

android android-xml

54
推荐指数
4
解决办法
2万
查看次数

尽管同步项目,但无法在Android Studio中解析符号"主题"

我的项目构建和运行顺利,但是在styles.xml中,"Theme"以红色突出显示,每次我将项目提交给Git时都会注意到这个错误:

Error:(4, 36) Cannot resolve symbol 'Theme'

styles.xml:

<resources>

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
</style>
Run Code Online (Sandbox Code Playgroud)

请注意,我已尝试将我的项目与gradle文件同步,并确保google()在我的buildscript块中存在,build.gradle如下面这些问题的答案中所述:

1] Android Studio 3.0无法解析符号主题

2] 无法在styles.xml(Android Studio)中解析符号'Theme'

这些问题中接受/最高投票的答案并没有解决我的问题,请帮忙

xml android-theme android-studio

2
推荐指数
1
解决办法
468
查看次数