2016-05-26 50 views
0
Theme.AppCompat.Light.NoActionBar 

顯示爲紅色且未被識別。這是我做了什麼:使用SDK經理如何使用Intellij導入appcompat-v7

下載支持庫

推門進去,項目結構中添加一個新的圖書館,選擇的程序兼容性-v7-23.4.0-javadoc.jar和程序兼容性,v7- appcompat-7的23.4.0文件夾中的23.4.0-sources.jar文件。

選擇OK後,將appcompat-v7-23.4.0-sources添加到我的庫中。

然後我去了Modules - > Dependencies以確保appcompat-v7-23.4.0-sources被選中並點擊OK。

它沒有工作......?該行仍然無法識別,圖書館甚至沒有出現在我的libs文件夾中。我嘗試了另一種方式來複制.jar文件,將它們粘貼到我的libs文件夾中,然後右鍵單擊以從此處添加到庫,但同樣的事情發生。我怎樣才能使這個工作?我的分鐘設置爲7,目標21和清單中最多23個。 styles.xml中的錯誤是「無法解析符號」。

<?xml version="1.0" encoding="utf-8"?> 
<resources> 
    <style name="AppTheme" parent="AppTheme.Base"></style> 
    <!-- Base theme applied no matter what API --> 
    <style name="AppTheme.Base" parent="Theme.AppCompat.Light.NoActionBar"> 
     <item name="colorPrimary">@color/colorPrimary</item> 
     <item name="colorPrimaryDark">@color/colorPrimaryDark</item> 
     <item name="colorAccent">@color/colorAccent</item> 
    </style> 
</resources> 

我試圖重建我的項目,只有這樣,我得到了以下錯誤:

Information:5/26/16, 12:29 PM - Compilation completed with 4 errors and 0 warnings in 4s 99ms 
/Users/accudeveloper/Android-App-2.0/android2.0/res/values/styles.xml 
Error:(5, -1) android-apt-compiler: [android2.0] /Users/accudeveloper/Android-App-2.0/android2.0/res/values/styles.xml:5: error: Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light.NoActionBar'. 
Error:(8, -1) android-apt-compiler: [android2.0] /Users/accudeveloper/Android-App-2.0/android2.0/res/values/styles.xml:8: error: Error: No resource found that matches the given name: attr 'colorAccent'. 
Error:(6, -1) android-apt-compiler: [android2.0] /Users/accudeveloper/Android-App-2.0/android2.0/res/values/styles.xml:6: error: Error: No resource found that matches the given name: attr 'colorPrimary'. 
Error:(7, -1) android-apt-compiler: [android2.0] /Users/accudeveloper/Android-App-2.0/android2.0/res/values/styles.xml:7: error: Error: No resource found that matches the given name: attr 'colorPrimaryDark'. 

這是我找到的.jar文件。這條道路看起來是否正確?基於此網站上的相關問題的答案

Android的SDK /演員/安卓/ m2repository/COM /安卓/支持/程序兼容性-V7

應該有一個程序兼容性/ RES /值目錄以及但我沒有看到。

+0

爲什麼不使用FREE-ANDROID STUDIO,這是在GOOGLE支持下的類固醇上的intelliJ-Idea? –

+0

我遵循的一些教程使用了IntelliJ,所以我就堅持使用它。但所有這些都讓我頭痛。我最終可能會試用Android Studio。 – terratunaz

+0

再次,Android Studio使用相同的內核,相同的快捷方式,相同的界面。並且無需卸載IDEA,您可以安裝少量Android Studios實例。 –

回答

1

嘗試編譯這個依賴於你的build.gradle

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

和同步嘗試後清潔你的項目

+0

我沒有在我的項目中只有build.xml文件。 – terratunaz

+0

然後您需要將庫jar文件複製到libs文件夾,並將其添加到您的項目 – Max

+0

謝謝,但我已經嘗試過,它仍然無法正常工作。 – terratunaz

1

編譯您的搖籃。除了android avd之外的綠色(看起來像地圖標記)或嘗試重建您的項目。

如果仍然存在,請刪除它們。重建您的項目並粘貼下面的gradle。

編譯 'com.android.support.appcompat-V7:23.4.0'

你可以在這裏找到它。

enter image description here

對不起,質量差的圖像。

嘗試刪除App主題的樣式。在你的Theme.AppCompat上方並且 正如我所看到的你的風格名稱=「AppTheme.Base」 - 刪除.Base

結果會是這樣的。 enter image description here

+0

您還可以使用打印屏幕(PrtSc)獲取屏幕快照 – Isaac

+0

我正在使用手機,手機數據。我會嘗試 – RoCk

+0

謝謝你的圖像,但我試圖重建項目,並得到以下錯誤: 錯誤:(5,-1)android-apt-compiler:[android2.0]/Users/accudeveloper/Android- App-2.0/android2.0/res/values/styles.xml:5:錯誤:檢索父項的錯誤:找不到與給定名稱'Theme.AppCompat.Light.NoActionBar'匹配的資源。 當我開始這個項目時,我只選擇了Android,並沒有使用Gradle:Android模塊。 – terratunaz

0

我最終搗毀了整個項目,並創建一個新的,這個時候開始的Android應用程序,並確保搖籃被列入沿着它和所有我需要已經包含的依賴關係立即工作過我的代碼。這種方式更容易。不知道我之前做了什麼(我不認爲我甚至從Android SDK抓取了正確的文件夾,因爲我實際上需要的文件夾顯然已經過時 - Android支持庫),但我現在將使用Gradle for我的項目。感謝所有嘗試提供幫助的人。