简体   繁体   English

如何解决Theme.AppCompat.Light错误

[英]How to resolve Theme.AppCompat.Light error

I am facing a issue after run existing android studio project. 运行现有的android studio项目后,我遇到一个问题。 Please check error below and let me know how to resolve that. 请检查以下错误 ,让我知道如何解决。

Error:(54) Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light'. 错误:(54)检索项目的父项时出错:未找到与给定名称'Theme.AppCompat.Light'匹配的资源。

Thanks in advance 提前致谢

Try to use accroding gradle plugin. 尝试使用accroding gradle插件。 I've got the problem with plugin 2.3-beta1 and Studio 2.2.3, when changed to plugin 2.2.3 - everything worked like a charm 改成插件2.2.3时,插件2.3-beta1和Studio 2.2.3出现问题-一切正常

请根据您的android studio现有正在运行的项目,在gradle文件中更改compileSdkVersion和buildToolsVersion。

Our compile SDK version must match the support library's major version. 我们的编译SDK版本必须与支持库的主要版本匹配。

If you are using version 23 of the support library, you need to compile against version 23 of the Android SDK. 如果您使用的是支持库的版本23,则需要针对Android SDK的版本23进行编译。

Alternatively you can continue compiling against version 22 of the Android SDK by switching to the latest support library v22. 或者,您可以通过切换到最新的支持库v22继续针对Android SDK版本22进行编译。

You can either change it manually in your build.gradle, or you can use the GUI by opening up the project properties and going to the "dependencies" tab. 您可以在build.gradle中手动更改它,也可以通过打开项目属性并转到“依赖项”选项卡来使用GUI。

Or Press Ctrl + Shift + Alt + S to get to the project structure page. 或者按Ctrl + Shift + Alt + S进入项目结构页面。 Go to the properties tab and change version to 23.0.0 or whatever latest in the build tool area and rebuild your project. 转到属性选项卡,然后将版本更改为23.0.0或在构建工具区域中更新到最新版本,然后重新构建项目。

If that doesn't work, go to gradle:app and then 如果那不起作用,请转到gradle:app然后

compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.2.1'

Edit version as shown above and sync gradle. 如上所示编辑版本并同步gradle。

You need follow some steps: 您需要执行以下步骤:

This is an issue that can happen in Android Studio if you modify Project Structure Modules. 如果您修改项目结构模块,则这是在Android Studio中可能发生的问题。 In this case you may need to add the dependencies again. 在这种情况下,您可能需要再次添加依赖项。 In a text editor edit the 'build.gradle' file to include the required dependencies: 在文本编辑器中,编辑“ build.gradle”文件以包括所需的依赖项:

dependencies {
    compile 'com.android.support:appcompat-v7:+'
    compile fileTree(dir: 'libs', include: ['*.jar'])
}

If you are new in Android developing, I strongly recomend you move to Android Studio & Gradle right now - you will get the simplest way of managing your android app. 如果您是Android开发的新手,我强烈建议您立即迁移到Android Studio&Gradle-您将获得管理Android应用程序的最简单方法。

Ran into same issue as OP, March 2017 Android Studio 2.3. 遇到与OP同样的问题,2017年3月,Android Studio 2.3。

My build was working fine for months, and this issue came up right after adding a new line to gradle build file. 我的构建工作了好几个月,并且在gradle构建文件中添加了新行之后,这个问题就出现了。 Ultimately making some changes in Gradle and re-sync'ing fixed the issue, but my Gradle ended up being exactly the same as when the issue first came up, strangely. 最终在Gradle中进行了一些更改并重新同步,从而解决了该问题,但是奇怪的是,我的Gradle最终与问题首次出现时完全相同。

My original Gradle build dependencies: 我最初的Gradle构建依赖项:

    compile 'com.android.support:design:25.1.1'
    compile 'com.android.support:multidex:1.0.1'
    compile 'com.android.support:support-v4:25.1.1'
    compile 'com.android.support:appcompat-v7:25.1.1'
    compile 'com.android.support:gridlayout-v7:25.1.1'
    compile 'com.android.support:cardview-v7:25.1.1'
    compile 'com.android.support:recyclerview-v7:25.1.1'    
    compile 'com.google.android.gms:play-services-location:10.0.0'
    compile 'com.google.android.gms:play-services-maps:10.0.0'       
    compile 'com.google.maps.android:android-maps-utils:0.5'    
    compile 'com.android.volley:volley:1.0.0'
    compile 'com.google.code.gson:gson:2.4'

Then, I simply added a new line: 然后,我只是添加了一行:

    compile 'org.scribe:scribe:1.3.5'

This is when the issue appeared, same as OP. 这是问题出现的时间,与OP相同。

I saw red errors in my styles.xml and wondered "wtf?". 我在styles.xml中看到红色错误,并想知道“ wtf?”。

Cleaning and re-building had no affect. 清洁和重建没有影响。

Going back to the Gradle build file, I commented-out that new line. 回到Gradle构建文件,我注释掉了这一行。 ISSUE RESOLVED! 问题解决了! So obviously there was something going on. 因此,显然发生了一些事情。

For fun, I put that line, uncommented, at the top of this compile list. 为了好玩,我将该行毫无注释地放在了此编译列表的顶部。 NO ISSUE! 没有任何问题!

For fun yet again, I put that line back again to the bottom of the list (like how originally added it). 再次为了好玩,我将该行再次放回列表的底部(就像最初添加它的方式一样)。 NO ISSUE.... weird! 没有问题。。。

How Gradle sync'ing responds doesn't seem to be 100% consistent. Gradle同步的响应方式似乎不一致100%。 I did no other changes to my project. 我没有对项目进行其他更改。 All I can say is try toggling and re-ordering things in the compile list. 我只能说是尝试在编译列表中切换和重新排序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Eclipse中检索“ Theme.AppCompat.Light”项的父项时出错 - Error retrieving parent for item: 'Theme.AppCompat.Light' in eclipse Theme.appcompat.light找不到资源 - Theme.appcompat.light no resource found 无法使用android:Theme.AppCompat.Light - Cannot use android:Theme.AppCompat.Light Cordova 找不到 Theme.AppCompat.Light - Cordova fails to find Theme.AppCompat.Light 在Theme.AppCompat.Light中添加图标 - Add icon in Theme.AppCompat.Light Theme.AppCompat.Light actionbar活动与活动 - Theme.AppCompat.Light actionbaractivity vs activity 如何修复Mac版的android eclips“错误检索父项:找不到与给定名称'Theme.AppCompat.Light'相匹配的资源? - How to fix mac version of android eclips 'Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light'? 如何解决xamarin中的'Theme.AppCompat.Light.NoActionBar'错误? - how to resolve the 'Theme.AppCompat.Light.NoActionBar' error in xamarin? Android Theme.AppCompat.Light with Dark Toolbar(用于浅色文本) - Android Theme.AppCompat.Light with Dark Toolbar (for light text) 寻求帮助:“错误:检索项目父项时出错:找不到与给定名称'Theme.AppCompat.Light'相匹配的资源” - Asking for help: “error: Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light' ”
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM