【发布时间】:2017-09-19 20:45:05
【问题描述】:
我从 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'
感谢您的宝贵时间!
【问题讨论】:
-
你能分享那个 Github 项目的链接吗?
-
这里是链接:github.com/ggegiya1/QuiZee我所有的团队都没有问题地下载了它
-
对我来说它工作正常。删除项目并从 Github 签出新副本并重新导入。那应该可以。
-
如果我下载项目,解压并打开它,它就可以工作。但是如果我打开 android studio 并直接从 github 导入,就会出现这个错误。知道为什么直接导入会产生这个问题吗?这很令人沮丧,因为如果我不将它与 github 链接,我就无法直接从 Android Studio 提交/拉取。
-
我使用
git pull命令从该链接复制项目。如果 Android Studio 没有检测到 VCS root,重启 Android Studio 就可以了。之后,您可以从 Android Studio 中提取或提交。祝你好运
标签: java android xml android-studio