2013-08-21 42 views
14

如何使用正確的Android支持庫,因爲我在清單文件中有這樣的錯誤:
Theme.AppCompat.Light.DarkActionBar - 無資源發現

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> 
+1

在eclipse中導入AppCompat庫項目(支持lib v7)。 看到這個 - http://developer.android.com/tools/support-library/index.html – Varun

+0

我做到了這一點,但問題還沒有解決 – Jerry

+0

你是否已經將appcompat項目添加爲應用程序中的庫項目? – Varun

回答

16

在 「Android的支持-V7-程序兼容性」 項目:

  • 刪除「機器人-support-v7-appcompat「。
  • 再次導入並勾選「複製到工作區」
  • 在屬性 - > Android的 - >在項目建設目標,取消的Android 2.2和Android的檢查4.1.2
  • 在Java構建路徑,取消,如果您有任何。罐子庫,並取消的依賴性

在另一方面,使用「Android的支持-V7-程序兼容性」的項目:

  • 在屬性 - > Android的添加庫,但取消「IsLibrary 「。
  • 在Android - >項目構建tarjet檢查Android 4.0。
  • 在「Java構建路徑」 - >在線訂單和出口 - >未選中該.jar庫
  • 最後做了「項目 - >清除」這兩個項目
+0

我試過了在我來到這裏之前,很多其他類似問題的事情,問題是依賴項的導出,不知道庫不必導出那些東西。謝謝,你救了我的一天! :)格拉西亞斯broder,te pasaste! – Aiapaec

+0

這將是很好的指定如何導入文件在第一個地方 - 當我點擊「導入」我沒有選擇導入一個罐子。 –

7

如果使用的是搖籃,那麼你有最新版本的兼容性庫的問題。

如果你在你的build.gradle文件與'+'在末尾以下內容:

dependencies { 
    compile 'com.android.support:appcompat-v7:+' 
} 

則可以抓住庫的版本比你想要的。

改變依賴於:

dependencies { 
    compile 'com.android.support:appcompat-v7:18.0+' 
} 

可以解決您的問題。

5

可否請您嘗試

android:theme="Theme.AppCompat.Light.DarkActionBar" 

,而不是

android:theme="@style/Theme.AppCompat.Light.DarkActionBar" 
+0

它真的有用嗎? –

+1

這是行不通的 –

0

在你的應用程序依賴文件檢查,如果你有依賴

compile 'com.android.support:appcompatv[anything here] 

implement 'com.android.support:appcompat[anything here] 

刪除或註釋掉它們,單擊「燈泡」以獲得自動建議並選擇添加庫依賴項。 clicking on the autofillbulb for appcompat

滾動第一個版本的appcompat的選項。該庫將被添加到依賴項列表下方。重建應用程序或使緩存無效並重新啓動

在一種情況下,該功能無法正常工作並進入包含該項目的文件夾,刪除.gradle文件並重新啓動Android Studio已運行。從Sneh Pandya的回答中獲得https://reformatcode.com/code/android/error-while-gradle-sync

相關問題