Android Studio无法解析符号“Theme”

9

我是使用的android studio 0.8.4版本。 当我扩展@style/Theme.AppCompat.Light时,android studio会用红色字体颜色的Theme提示can't resolove symbol 'Theme'。但是当我运行这个项目时,它可以正常运行,我不知道如何解决这个问题。以下是我的代码。

styles.xml

<resources>
    <!-- the theme applied to the application or activity -->
    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    </style>
</resources>

build.gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 20
    buildToolsVersion "20.0.0"

    defaultConfig {
        applicationId "kr.co.hiworks.office"
        minSdkVersion 9
        targetSdkVersion 19
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            runProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    lintOptions {
        disable 'InvalidPackage'
    }

    packagingOptions {
        exclude 'META-INF/services/javax.annotation.processing.Processor'
    }

}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:support-v4:19.+'
    compile 'com.android.support:appcompat-v7:19.+'
    compile 'com.jakewharton:butterknife:5.1.1'
    compile 'com.nineoldandroids:library:2.4.0'
    compile 'com.mcxiaoke.volley:library:1.0.6'
    compile 'com.github.satyan:sugar:1.3'
}

AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="kr.co.hiworks.office" >

    <application
        android:name=".BaseApplication"
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <meta-data android:name="DATABASE" android:value="hiworks_office.db" />
        <meta-data android:name="VERSION" android:value="1" />
        <meta-data android:name="QUERY_LOG" android:value="true" />
        <meta-data android:name="DOMAIN_PACKAGE_NAME" android:value="kr.hiworks.office.models" />
        <activity
            android:name=".activities.MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
</manifest>

我认为你在项目中漏掉了这个库appcompactv7的依赖。 - Haresh Chhelana
@Scott Barta,那个问题中的所有答案都不起作用。而且症状也不同。我正在使用ANDROID STUDIO 0.8.4,但是在ANDROID STUDIO 0.2.x中解决了该问题。 - Cinakyn
3个回答

4

0

这是一个由于低版本Gradle引起的错误,您可以从reference下载Gradle并将其替换为旧版本。

第二个解决方案是升级您的Android Studio到新版本。

第三个解决方案是使缓存无效/重启。

希望能对您有所帮助。


0

1
每个答案都不起作用,症状也不同。我正在使用 ANDROID STUDIO 0.8.4,但这个问题在 ANDROID STUDIO 0.2.x 中已经解决了。 - Cinakyn
这是一个在0.8.4版本中再次提出的问题。请查看链接https://code.google.com/p/android/issues/detail?id=64649。 - Dharmendra Pratap Singh
2
好的,但这仍然是一个问题。 - Dharmendra Pratap Singh
2
2016年5月,仍然存在使用Android Studio 2.1.1的问题。 - carl

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接