[英]Error retrieving parent for item: No resource found that matches the given name '@android:style/Theme.AppCompat.Light.DarkActionBar'
[英]Theme.AppCompat.Light.DarkActionBar - No resource found
如何正確使用Android支持庫,因為我的清單文件中有此錯誤:
android:theme="@style/Theme.AppCompat.Light.DarkActionBar"
error: Error: No resource found that matches the given name
(at 'theme' with value '@style/Theme.AppCompat.Light.DarkActionBar').
AndroidManifest.xml /ttab line 39 Android AAPT Problem
我的朋友之前在其他計算機上為我實現了此功能,現在我必須單獨執行此操作。 請幫我:)
我正在使用ADT
我的styles.xml:
<resources>
<!--
Base application theme, dependent on API level. This theme is replaced
by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
-->
<style name="AppBaseTheme" parent="android:Theme.Light">
<!--
Theme customizations available in newer API levels can go in
res/values-vXX/styles.xml, while customizations related to
backward-compatibility can go here.
-->
</style>
<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
</style>
<style name="Theme.AppCompat.Light">
<!-- theme customizations here. -->
</style>
<style name="Theme.AppCompat.Light.DarkActionBar" parent="Theme.AppCompat.Light">
<!-- theme customizations here. -->
</style>
</resources>
在“android-support-v7-appcompat”項目中:
另一方面,使用“android-support-v7-appcompat”的項目:
如果您使用的是Gradle,則說明最新版本的兼容性庫存在問題。
如果build.gradle
文件中包含以下內容, build.gradle
末尾帶有'+'
:
dependencies {
compile 'com.android.support:appcompat-v7:+'
}
然后它可能會抓住你想要的更高版本的庫。
將依賴項更改為:
dependencies {
compile 'com.android.support:appcompat-v7:18.0+'
}
可以解決你的問題。
你能試試嗎?
android:theme="Theme.AppCompat.Light.DarkActionBar"
代替
android:theme="@style/Theme.AppCompat.Light.DarkActionBar"
在您的應用程序依賴項文件中檢查您是否具有依賴項
compile 'com.android.support:appcompatv[anything here]
要么
implement 'com.android.support:appcompat[anything here]
刪除或注釋掉它們,單擊“燈泡”以獲取自動建議,然后選擇添加庫依賴項。 單擊appcompat的autofillbulb
滾動第一個appcompat版本的選項。 該庫將添加到依賴項列表下方。 重建應用程序或使緩存無效並重新啟動
在一種情況下,這沒有用,並且轉到包含項目的文件夾,刪除.gradle文件並重新啟動Android Studio已經有效。 來自Sneh Pandya在https://reformatcode.com/code/android/error-while-gradle-sync中的回答
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.