从今天开始,Android Studio无法在styles.xml中找到AppCompat主题,但是例如代码中的AppCompatActivity确实得到了识别.我的Android Studio版本是2.2.2,Build#AI-145.3360264
我已经尝试升级到最新的构建工具,编译sdk(25)版本等,但它没有解决问题.
目前我安装了以下内容(来自sdk经理):
和其他一些,这里没有必要列出.
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
我今天将Android Studio升级到3.1,现在Android Studio说它无法解析大多数资源的符号(例如ThemeOverlayin styles.xml或?attr/actionBarSize).到目前为止,这似乎并没有阻止我在模拟器中构建或运行,但这些错误让我感到紧张.
还有其他人遇到过这个问题吗?我怎样才能解决它?我尝试过同步gradle和清理我的项目,但它似乎没有任何帮助.
有任何想法吗?
我正在使用带有Gradle版本4.4和Gradle Plugin 3.1.0的Android Studio 3.1
编辑: 此问题影响更新到Android Studio 3.1.1,3.1.2,3.1.3,3.1.4以及Gradle Plugin到3.1.1,3.1.2,3.1.3和3.1.4.但是,下面的答案仍然有效.
android intellij-idea android-resources android-studio android-studio-3.1
这不是一个很大的问题,因为我的项目仍然构建并正确运行(使用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中运行我的项目时会出现同样的问题.
正如style.xml中所述,有一个奇怪的错误,它显示无法解析符号'Theme',这很奇怪.
我的项目规格: -
使用Android Studio 3.0
和gradle版本3.0.0
和distributionUrl = https://services.gradle.org/distributions/gradle-4.1-all.zip
编辑:-
尝试通过转到文件>无效缓存/重新启动>无效和重新启动来清除缓存,但无效,因为错误仍然存在.