相关疑难解决方法(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万
查看次数

使用v7兼容性支持主题时,IDE"无法解析@ style/Theme.Appcompat"

这不是一个很大的问题,因为我的项目仍然构建并正确运行(使用gradle),但我无法让Android Studio识别API 18 SDK中发布的应用程序兼容性主题(允许Android 2.1的操作栏支持)以上).

我成功加载了支持库,因为java文件中的ActionBar类可以完成代码.问题是Android Studio在AndroidManifest.xml中显示了对Theme.AppCompat.Light赋值的红色文本错误.

有没有办法在Android Studio中的外部库中为清单中声明的​​主题资源启用代码完成?

更新这是<activity>我的AndroidManifest块:

<activity
    android:name="com.example.activities.MainActivity"
    android:label="@string/app_name"
    android:screenOrientation="portrait"
    android:theme="@style/Theme.AppCompat.Light" >
Run Code Online (Sandbox Code Playgroud)

我也尝试在应用程序块中设置主题:

<application
    android:allowBackup="true"
    android:icon="@drawable/main_final_ic"
    android:label="@string/app_name"
    android:logo="@drawable/main_final_enzo"
    android:theme="@style/Theme.AppCompat.Light" >
Run Code Online (Sandbox Code Playgroud)

同样,这些工作和编译都正常,但在我的IDE中显示为带有错误的红色文本.我还刚刚确认在eclipse中运行我的项目时会出现同样的问题.

eclipse android android-support-library android-studio

41
推荐指数
3
解决办法
5万
查看次数

为什么Android Studio在styles.xml中用红色突出显示“主题”?

红色突出显示表示无法解析符号“主题”

在此处输入图片说明

以下是一些配置:

styles.xml

<style name="AppBaseTheme" parent="Theme.AppCompat.Light">
    <!--
        Theme customizations available in newer API levels can go in
        res/values-vXX/styles.xml, while customizations related to
        backward-compatibility can go here.
    -->
    <item name="android:windowNoTitle">true</item>
</style>

<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
    <item name="android:windowNoTitle">true</item>
</style>
Run Code Online (Sandbox Code Playgroud)

AndroidManifest.xml

<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="19" />
Run Code Online (Sandbox Code Playgroud)

...

android:theme="@style/AppTheme">
Run Code Online (Sandbox Code Playgroud)

build.gradle

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:19.0.0'
}
Run Code Online (Sandbox Code Playgroud)

...

android {
    compileSdkVersion 19
    buildToolsVersion '20.0.0'
    defaultConfig {
    applicationId 'com.mobile.slider'
    minSdkVersion 8
    targetSdkVersion 19
Run Code Online (Sandbox Code Playgroud)

MainActivity.java

public class …
Run Code Online (Sandbox Code Playgroud)

android gradle android-theme android-studio android-styles

5
推荐指数
1
解决办法
3662
查看次数

我的风格有什么问题?无法解析符号Theme.AppCompat.Light.NoActionBar

目前,我的styles.xml文件显示不正确的内容.Theme.AppCompat.Light.NoActionBar无法解决.我已经重新启动android studio但它仍然无法正常工作.我尝试了Invalidate Caches/Restart,但它不起作用.它不会使我的应用程序崩溃,但为什么会发生.看下图:

.

这是我的build.gradle文件

import org.apache.tools.ant.taskdefs.condition.Os

apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'

android {
    compileSdkVersion 23
    buildToolsVersion '25.0.0'

    defaultConfig {
        applicationId "xx.com.xxx.xxxx"
        minSdkVersion 17
        targetSdkVersion 23
        versionCode 21
        versionName "1.2.0"
        renderscriptTargetApi 23
        renderscriptSupportModeEnabled true

        // Enabling multidex support.
        multiDexEnabled true
    }

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile('com.afollestad.material-dialogs:core:0.8.5.1@aar') {
        transitive = true
    }
    compile('com.mikepenz:actionitembadge:3.0.2@aar') {
        transitive = true
    }
    compile project(':blurringview')
    compile 'com.android.support:support-v4:23.3.0'
    compile 'com.android.support:appcompat-v7:23.3.0'
    compile 'com.android.support:design:23.3.0'
    compile 'com.android.support:cardview-v7:23.3.0'
    compile 'com.android.support:recyclerview-v7:23.3.0'
    compile 'com.google.android.gms:play-services-gcm:8.3.0'
    compile 'com.android.support:palette-v7:23.3.0' …
Run Code Online (Sandbox Code Playgroud)

android android-appcompat android-studio android-styles

3
推荐指数
1
解决办法
4570
查看次数