George Panayi
George Panayi

Reputation: 1772

How to support Material Design on older android devices

I'm trying to use the Material Design in my project but I didn't find a way to import it. I have spend a lot of time in the internet and in the stackoverflow trying what users have suggested but whatever I have tried is not working.

I'm using Android Studio 0.8.14 on Mac OSX 10.10. with gradle 13.2 and JDK jdk1.8.0_25.jdk. As you can see from the images my android SDK is fully up to date

enter image description here

enter image description here

enter image description here

Here is my gradle

android {
    signingConfigs {
        TESTING {
            keyAlias '****'
            keyPassword '***'
        }
    }
    compileSdkVersion 21
    buildToolsVersion "21.0.2"
    defaultConfig {
        applicationId "********"
        minSdkVersion 14
        targetSdkVersion 21
        versionCode 1
        versionName '1.0'
    }
    buildTypes {
        debug {
            applicationIdSuffix '.dev'
        }
        release {
            runProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            signingConfig signingConfigs.TESTING
        }
    }
    productFlavors {
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_7
        targetCompatibility JavaVersion.VERSION_1_7
    }
}

dependencies {
    compile 'com.android.support:support-v4:21.+'
    compile 'com.android.support:support-v13:21.+'
    compile 'com.android.support:appcompat-v7:21.+'
    compile 'com.android.support:cardview-v7:21.+'
    compile 'com.android.support:recyclerview-v7:21.+'
    compile 'com.google.android.gms:play-services:6.1.+'
    compile fileTree(dir: 'libs', include: ['*.jar', '*.aar'])
}

value/style.xml

<resources>

    <!-- Base application theme. -->
    <style name="AppTheme" parent="AppTheme.Base"/>

    <style name="AppTheme.Base" parent="Theme.AppCompat.Light">
    </style>

</resources>

value-21/style.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="AppTheme" parent="android:Theme.Material.Light">
        <!-- Customize your theme using Material Design here. -->
    </style>
</resources>

When I'm adding the appcompat inside the gradle automatically after the clean of the gradle all the R. inside my classes are not working and shows the error message "Cannot resolve symbol R". Not only this I'm getting the following errors and warnings:

Information:Gradle tasks [clean, :app:generateDebugSources, :app:generateDebugTestSources] :app:clean :app:preBuild :app:preDebugBuild :app:checkDebugManifest :app:preReleaseBuild :app:prepareComAndroidSupportAppcompatV72100Library :app:prepareComAndroidSupportCardviewV72100Library :app:prepareComAndroidSupportRecyclerviewV72100Library :app:prepareComAndroidSupportSupportV132100Library :app:prepareComAndroidSupportSupportV42100Library :app:prepareComGoogleAndroidGmsPlayServices6171Library :app:prepareDebugDependencies :app:compileDebugAidl :app:compileDebugRenderscript :app:generateDebugBuildConfig :app:generateDebugAssets UP-TO-DATE :app:mergeDebugAssets :app:generateDebugResValues UP-TO-DATE :app:generateDebugResources :app:mergeDebugResources /Users/User/AndroidStudioProjects/TEST/app/build/intermediates/exploded-aar/com.android.support/appcompat-v7/21.0.0/res/drawable-mdpi/abc_ab_share_pack_holo_dark.9.png: libpng warning: iCCP: Not recognizing known sRGB profile that has been edited /Users/User/AndroidStudioProjects/TEST/app/src/main/res/drawable-mdpi/ic_drawer.png: libpng warning: iCCP: Not recognizing known sRGB profile that has been edited /Users/User/AndroidStudioProjects/TEST/app/src/main/res/drawable-hdpi/ic_drawer.png: libpng warning: iCCP: Not recognizing known sRGB profile that has been edited /Users/User/AndroidStudioProjects/TEST/app/src/main/res/drawable-xhdpi/ic_drawer.png: libpng warning: iCCP: Not recognizing known sRGB profile that has been edited /Users/User/AndroidStudioProjects/TEST/app/build/intermediates/exploded-aar/com.android.support/appcompat-v7/21.0.0/res/drawable-xhdpi/abc_ab_share_pack_holo_dark.9.png: libpng warning: iCCP: Not recognizing known sRGB profile that has been edited /Users/User/AndroidStudioProjects/TEST/app/build/intermediates/exploded-aar/com.android.support/appcompat-v7/21.0.0/res/drawable-hdpi/abc_spinner_mtrl_am_alpha.9.png: libpng warning: iCCP: Not recognizing known sRGB profile that has been edited /Users/User/AndroidStudioProjects/TEST/app/build/intermediates/exploded-aar/com.android.support/appcompat-v7/21.0.0/res/drawable-hdpi/abc_ab_share_pack_holo_light.9.png: libpng warning: iCCP: Not recognizing known sRGB profile that has been edited /Users/User/AndroidStudioProjects/TEST/app/build/intermediates/exploded-aar/com.android.support/appcompat-v7/21.0.0/res/drawable-hdpi/abc_ab_share_pack_holo_dark.9.png: libpng warning: iCCP: Not recognizing known sRGB profile that has been edited /Users/User/AndroidStudioProjects/TEST/app/build/intermediates/exploded-aar/com.android.support/appcompat-v7/21.0.0/res/drawable-xhdpi/abc_ab_share_pack_holo_light.9.png: libpng warning: iCCP: Not recognizing known sRGB profile that has been edited :app:processDebugManifest Warning:/Users/User/AndroidStudioProjects/TEST/app/src/main/AndroidManifest.xml:11:5 Warning: Element uses-permission#android.permission.ACCESS_COARSE_LOCATION at AndroidManifest.xml:11:5 duplicated with element declared at AndroidManifest.xml:9:5 Warning:/Users/User/AndroidStudioProjects/TEST/app/src/main/AndroidManifest.xml:12:5 Warning: Element uses-permission#android.permission.ACCESS_FINE_LOCATION at AndroidManifest.xml:12:5 duplicated with element declared at AndroidManifest.xml:10:5 /Users/User/AndroidStudioProjects/TEST/app/src/main/AndroidManifest.xml Warning:(11, 5) Element uses-permission#android.permission.ACCESS_COARSE_LOCATION at AndroidManifest.xml:11:5 duplicated with element declared at AndroidManifest.xml:9:5 Warning:(12, 5) Element uses-permission#android.permission.ACCESS_FINE_LOCATION at AndroidManifest.xml:12:5 duplicated with element declared at AndroidManifest.xml:10:5 :app:processDebugResources /Users/User/AndroidStudioProjects/TEST/app/build/intermediates/exploded-aar/com.android.support/appcompat-v7/21.0.0/res/values-v11/values.xml Error:(36, 21) No resource found that matches the given name: attr 'android:actionModeShareDrawable'. Error:(36, 21) No resource found that matches the given name: attr 'android:actionModeShareDrawable'. Error:(36, 21) No resource found that matches the given name: attr 'android:actionModeShareDrawable'. Error:(36, 21) No resource found that matches the given name: attr 'android:actionModeShareDrawable'. /Users/User/AndroidStudioProjects/TEST/app/build/intermediates/exploded-aar/com.android.support/appcompat-v7/21.0.0/res/values-v14/values.xml Error:(9, 21) No resource found that matches the given name: attr 'android:actionModeShareDrawable'. Error:(9, 21) No resource found that matches the given name: attr 'android:actionModeShareDrawable'. Error:(9, 21) No resource found that matches the given name: attr 'android:actionModeShareDrawable'. Error:(9, 21) No resource found that matches the given name: attr 'android:actionModeShareDrawable'. /Users/User/AndroidStudioProjects/TEST/app/build/intermediates/exploded-aar/com.android.support/appcompat-v7/21.0.0/res/values-v21/values.xml Error:(298, 21) No resource found that matches the given name: attr 'android:overlapAnchor'. Error:(298, 21) No resource found that matches the given name: attr 'android:overlapAnchor'. Error:Execution failed for task ':app:processDebugResources'.

com.android.ide.common.internal.LoggedErrorException: Failed to run command: /Users/User/android-sdk/build-tools/21.0.2/aapt package -f --no-crunch -I /Users/User/android-sdk/platforms/android-21/android.jar -M /Users/User/AndroidStudioProjects/TEST/app/build/intermediates/manifests/full/debug/AndroidManifest.xml -S /Users/User/AndroidStudioProjects/TEST/app/build/intermediates/res/debug -A /Users/User/AndroidStudioProjects/TEST/app/build/intermediates/assets/debug -m -J /Users/User/AndroidStudioProjects/TEST/app/build/generated/source/r/debug -F /Users/User/AndroidStudioProjects/TEST/app/build/intermediates/res/resources-debug.ap_ --debug-mode --custom-package andreou.maria.com.TEST -0 apk --output-text-symbols /Users/User/AndroidStudioProjects/TEST/app/build/intermediates/symbols/debug Error Code: 1 Output:
/Users/User/AndroidStudioProjects/TEST/app/build/intermediates/res/debug/values-v11/values.xml:33: error: Error: No resource found that matches the given name: attr 'android:actionModeShareDrawable'.
/Users/User/AndroidStudioProjects/TEST/app/build/intermediates/res/debug/values-v14/values.xml:10: error: Error: No resource found that matches the given name: attr 'android:actionModeShareDrawable'.
/Users/User/AndroidStudioProjects/TEST/app/build/intermediates/res/debug/values-v11/values.xml:39: error: Error: No resource found that matches the given name: attr 'android:actionModeShareDrawable'.
/Users/User/AndroidStudioProjects/TEST/app/build/intermediates/res/debug/values-v14/values.xml:17: error: Error: No resource found that matches the given name: attr 'android:actionModeShareDrawable'.
/Users/User/AndroidStudioProjects/TEST/app/build/intermediates/res/debug/values-v11/values.xml:45: error: Error: No resource found that matches the given name: attr 'android:actionModeShareDrawable'.
/Users/User/AndroidStudioProjects/TEST/app/build/intermediates/res/debug/values-v14/values.xml:24: error: Error: No resource found that matches the given name: attr 'android:actionModeShareDrawable'.
/Users/User/AndroidStudioProjects/TEST/app/build/intermediates/res/debug/values-v11/values.xml:51: error: Error: No resource found that matches the given name: attr 'android:actionModeShareDrawable'.
/Users/User/AndroidStudioProjects/TEST/app/build/intermediates/res/debug/values-v14/values.xml:31: error: Error: No resource found that matches the given name: attr 'android:actionModeShareDrawable'.
/Users/User/AndroidStudioProjects/TEST/app/build/intermediates/res/debug/values-v21/values.xml:287: error: Error: No resource found that matches the given name: attr 'android:overlapAnchor'.
/Users/User/AndroidStudioProjects/TEST/app/build/intermediates/res/debug/values-v21/values.xml:295: error: Error: No resource found that matches the given name: attr 'android:overlapAnchor'. Information:BUILD FAILED Information:Total time: 5.93 secs Information:11 errors Information:4 warnings Information:See complete output in console

Can anyone help me? Am I doing something wrong?

Thank you

Upvotes: 4

Views: 3796

Answers (2)

moyheen
moyheen

Reputation: 702

Here are a couple of tips that could work.

Change your buildToolsVersion to the latest version of the Android SDK Build-tools you have installed. In your case, 21.1 although 21.1.2 is now available.

Reduce your minSdkVersion, depending on the APIs used in your app.

Check for duplicate permission declaration in your Manifest.

Most importantly, change your dependencies to the form 'com.android.support:appcompat-v7:21.0.+' instead of 'com.android.support:appcompat-v7:21.+'

Sync and rebuild the project.

I hope this helps.

Upvotes: 2

Arjun Komath
Arjun Komath

Reputation: 2852

I got the same error, and I fixed it by correcting the Jdk path (The directory where the Java Development Kit is located.)

  • Check build.gradle files for errors or warnings
  • Make sure that the JDK path is not 1.6, it should be 1.7 or above. I'm using :

    /Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/Contents/Home

  • Rebuild Project / Sync Gradle

Upvotes: 1

Related Questions