2

I'm trying to rebuild an Android application on VS and Xamarin but I get this error

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

this is the attribute:

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

I use these values for compiling:

enter image description here

the error comes from the file values.xml, but sometimes the same error happens with different attributes in files; values-23.xml or 22..etc

3 Answers 3

11

Change the compilation version to Android 5.0 or above. elevation attribute was introduced in 5.0. So Kit-kat build tools will fail.

4
  • I changed the compilation version as you described: and I get rid of that error, but I get another error: java.lang.OutOfMemoryError. Consider increasing the value of $(JavaMaximumHeapSize). Java ran out of memory while executing 'java.exe
    – mshwf
    May 25, 2016 at 12:17
  • 1
    @MohamedAhmed Go to your Android options-> Advanced Tab -> Advanced Android Build Settings and set Java Heap Size to 1G for example
    – Ingenator
    May 25, 2016 at 19:56
  • @Amit Kumar, I was always wondering... why they even let people set there KitKat 4.4? Is there a scenario that configuration will work?
    – Marshall
    Dec 15, 2016 at 6:01
  • These attributes are compiler dependent and this was introduced in Lollipop(5.0). Its always recommended to compile code with latest build tool version. Due to large marketshare of Kitkat, most of the apps still need to support that.
    – Amit Kumar
    Dec 16, 2016 at 10:47
3

Elevation is only for Android 5.x+ so you must change compilation to use 5.0 or above.

your /Resources/values/style.xml should look more or less like:

<?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>

Also check your style.xml in your /Resources/values folder and make sure you set styles for API level v21+ look like: /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

Set property as AndroidResource in BuildAction for all style.xml and image files. Keep in mind all the files must be in Resources folder within .Droid project.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.