2016-05-25 67 views
2

我試圖重建的VS和Xamarin 一個Android應用程序,但我得到這個錯誤沒有資源發現在給定名稱匹配:ATTR「機器人:海拔」

No resource found that matches the given name: attr 'android:elevation'.

這是屬性:

<item name="android:elevation">@dimen/design_bottom_sheet_modal_elevation</item> 

我使用這些值來編譯:

enter image description here

錯誤來自文件values.xml,但有時會發生文件中不同屬性的相同錯誤;值-23.xml或22 ..等等

回答

11

將編譯版本更改爲Android 5.0或更高版本。在5.0中引入了海拔屬性 。 So Kit-kat構建工具將失敗。

+0

我改變了編譯版本爲你描述:我擺脫錯誤的,但我得到另一個錯誤:java.lang.OutOfMemoryError。考慮增加$(JavaMaximumHeapSize)的值。 Java運行時內存不足,執行'java.exe –

+1

@MohamedAhmed轉到您的Android選項 - >高級選項卡 - >高級Android構建設置並將Java堆大小設置爲1G,例如 – Ingenator

+0

@Amit Kumar,我一直想知道...爲什麼他們甚至讓人們在那裏設置KitKat 4.4?是否有配置可以工作的場景? – Marshall

2

海拔僅適用於Android 5.x +,因此您必須更改編譯爲使用5.0或更高版本。

您/Resources/values/style.xml應該或多或少是:

<?xml version="1.0" encoding="utf-8" ?> 
<resources> 
    <style name="MyTheme" parent="MyTheme.Base"> 
    </style> 
    <style name="MyTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar"> 
    <!--If you are using revision 22.1 please use just windowNoTitle. Without android:--> 
    <item name="windowNoTitle">true</item> 
    <!--We will be using the toolbar so no need to show ActionBar--> 
    <item name="windowActionBar">false</item> 
    <!-- Set theme colors from http://www.google.com/design/spec/style/color.html#color-color-palette--> 
    <!-- colorPrimary is used for the default action bar background --> 
    <item name="colorPrimary">#00FFAA</item> 
    <!-- colorPrimaryDark is used for the status bar --> 
    <item name="colorPrimaryDark">#004D40</item> 
    <!-- colorAccent is used as the default value for colorControlActivated 
     which is used to tint widgets --> 
    <item name="colorAccent">@color/accent</item> 
    <!-- You can also set colorControlNormal, colorControlActivated 
     colorControlHighlight and colorSwitchThumbNormal. 
    <item name="colorControlNormal">#00897B</item> 
    <item name="colorControlActivated">#1DE9B6</item>--> 
    <item name="windowActionModeOverlay">true</item> 
    </style> 
</resources> 

還要檢查你的style.xml在你的/資源/文件夾值,並確保您爲API級別V21 +風格是這樣的:在BuildAction的/Resources/values-v21/style.xml

<?xml version="1.0" encoding="utf-8" ?> 
<resources> 
    <!-- 
     Base application theme for API 21+. This theme replaces 
     MyTheme from resources/values/styles.xml on API 21+ devices. 
    --> 
    <style name="MyTheme" parent="MyTheme.Base"> 
    <item name="android:windowContentTransitions">true</item> 
    <item name="android:windowAllowEnterTransitionOverlap">true</item> 
    <item name="android:windowAllowReturnTransitionOverlap">true</item> 
    <item name="android:windowSharedElementEnterTransition">@android:transition/move</item> 
    <item name="android:windowSharedElementExitTransition">@android:transition/move</item> 
    </style> 
</resources> 
0

設置屬性爲AndroidResource所有style.xml和圖像文件。請記住,所有文件必須位於.Droid項目中的Resources文件夾中。

0

您需要添加最新的支持庫以在Kitkat中添加CardView和RecyclerView。

高程僅適用於Android 5.x的+

添加下列項目中的gradle這個依賴

compile 'com.android.support:cardview-v7:23.4.0' 
compile 'com.android.support:recyclerview-v7:23.4.0' 
相關問題