我从 github 导入了一个工作项目,但我发现自己无法运行/重建项目,因为我的 styles.xml 和 build.grable 有问题。
以下是我访问过的有关此问题的链接:
- Theme.AppCompat.Light.DarkActionBar - No resource found
- Android Errors : No resource found - Theme.AppCompat.Light.DarkActionBar, and Android Virtual Device
- No resource found that matches the given name 'Theme.AppCompat.Light'
- Fixing Error in styles.xml to generate R.java : No resource found name 'Theme.AppCompat.Light'
- No resource found - Theme.AppCompat.Light.DarkActionBar
- Can't Find Theme.AppCompat.Light for New Android ActionBar Support
还有很多......大多数解决方案都是旧的(5 年以上),我试过的那些都不起作用:
- 在您的 build.gradle 依赖项中添加 compile 'com.android.support:appcompat-v7:25.3.1'
- 导入appcompat,导入按钮似乎在当前版本中消失了
- 重新编译/重新同步/使缓存无效/关闭项目/从github重新导入
- 在模块设置中添加库依赖(要求我上传文件?)
由于我是 Android Studio 的新手,请在您的回答中明确说明要做什么(打开 X 文件,执行 Y)。
主要文件如下:
样式.xml:
<resources>
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
</style>
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
</resources>
构建.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.app.game.quizee"
minSdkVersion 21
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.1'
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:support-vector-drawable:25.3.1'
compile 'com.android.support:support-v4:25.3.1'
testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
感谢您的宝贵时间!
最佳答案
Gradle 版本:“2.3.1”导致了我的情况,通过返回版本“2.2.3”修复了它。
换句话说,改变这一行:
类路径 'com.android.tools.build:gradle:2.3.1'
到:
类路径 'com.android.tools.build:gradle:2.2.3'
关于java - 未找到资源 - Styles.xml 和 Theme.AppCompat.Light,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43566568/