4

I have been developing this android for some days now, and suddenly the application build has a lot of errors and doesn't run. First few errors are listed below

D:\somepath\someotherpath\app\build\intermediates\exploded-aar\com.android.support\appcompat-v7\21.0.3\res\values-v11\values.xml
Error:(50, 21) No resource found that matches the given name: attr 'android:actionModeShareDrawable'.
Error:(50, 21) No resource found that matches the given name: attr 'android:actionModeShareDrawable'.
Error:(50, 21) No resource found that matches the given name: attr 'android:actionModeShareDrawable'.
Error:(50, 21) No resource found that matches the given name: attr 'android:actionModeShareDrawable'.

A couple of things might have caused these errrors are listed below

I was attempting to speed up the Emulator by using Intel HAXM, and also use Genymotion. I can see changes in the dependencies of the build.gradle

build.gradle old

apply plugin: 'com.android.application'
android {
    compileSdkVersion 20
    buildToolsVersion "20.0.0"

    defaultConfig {
        applicationId "org.nirvanasoftware.donor_app"
        minSdkVersion 8
        targetSdkVersion 20
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            runProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:20.0.0'
    compile 'com.android.support:support-v4:20.0.0'
}

**build.gradle New **

apply plugin: 'com.android.application'
android {
    compileSdkVersion 20
    buildToolsVersion "20.0.0"

    defaultConfig {
        applicationId "org.nirvanasoftware.donor_app"
        minSdkVersion 8
        targetSdkVersion 20
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            runProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:21.0.3'
    compile 'com.android.support:support-v4:21.0.3'
}

Is the change in dependency causing build errors or something else.

Jatin
  • 4,023
  • 10
  • 60
  • 107
  • 1
    I don't see any difference between these two versions. Why do you think targetSdkVersion and compileSdkVersion were 'suddenly' changed? – aga Dec 26 '14 at 11:47
  • Have you double checked with the SDK manager and verified those version numbers against your installed ones? – ChiefTwoPencils Dec 26 '14 at 12:02
  • @aga I think I need some sleep ! I have changed the question because as you pointed out the target and compile version haven't changed. But the dependency has. This is my first android project so I am not sure about many things. Right now, I have these errors (about 100) that I am trying to get rid of. – Jatin Dec 26 '14 at 12:06
  • Please set : minifyEnabled false instead runProguard false in your build.gradle – IntelliJ Amiya Dec 26 '14 at 12:19
  • 1
    @IntelliJAmiya minifyEnabled false gives me following error "Error:(16, 0) Build script error, unsupported Gradle DSL method found: 'minifyEnabled()'! Possible causes could be: - you are using Gradle version where the method is absent (Fix Gradle settings) - you didn't apply Gradle plugin which provides the method (Apply Gradle plugin) - or there is a mistake in a build script (Goto source)" – Jatin Dec 26 '14 at 12:32
  • Okay . Check this link http://stackoverflow.com/questions/27078075/gradle-dsl-method-not-found-runproguard – IntelliJ Amiya Dec 26 '14 at 12:36
  • @aga I changed the dependencies from 'com.android.support:appcompat-v7:21.0.3' to 'com.android.support:appcompat-v7:20.0.0' and the errors are gone. I don't have the SDK platform for API 21 installed so I guess the errors were because of that. But I still didn't understand how the build.gradle was changed in first place. Thanks – Jatin Dec 26 '14 at 12:36

1 Answers1

3

In the dependencies you have used appcompat-v7:21.0.3 and support-v4:21.0.3

But your compileSdkVersion is 20 buildToolsVersion is "20.0.0"

As I know if you use compileSdkVersion 20 then you should use buildToolsVersion "20.0.0" and the version of support library should also be 20 not 21. If you want to use appcompat-v7:21.0.3' and support-v4:21.0.3' you must use compileSdkVersion 21 and buildToolsVersion 21.x.y (here x and y will be the number according to your build tools that you have installed on your computer)

I am not sure that all of your problems are caused for this. But if there is a problem in your gradle synchronization then suddenly you will have a lot of problems. So if you do not have errors other than your gradle build file then your problems should be removed.

My suggestion is if you want to use latest SDKs and Support libraries install the latest build tools and SDKs from the Android SDK Manager then use

compileSdkVersion 21
buildToolsVersion "21.1.2"   // your latest build tools 

and dependencies like this

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:21.0.3'
    compile 'com.android.support:support-v4:21.0.3'
}

Hope it will solve your problems. Happy coding :D

In addition: In the latest gradle version that is gradle-1.0.0 runProguard is a deprecated method. So instead of using it you must use minifyEnabled and update your gradle version to 1.0.0.

Sazedul Islam Sazid
  • 2,258
  • 1
  • 10
  • 10
  • Yes you are correct. I don't have API 21 libraries, and the errors might be because of that. Currently, I am targeting API 20, and so I have changed the dependencies back to appcompat-v7:20.0.0, and I am happy it is working. Although I am still clueless what changed the dependencies in build.gradle in first place to use API 21 ! – Jatin Dec 26 '14 at 12:44
  • I came to know what is causing the dependencies to change to appcompat-v7:21.0.3. When I am adding a new Activity, every time this issue occurs. Any ideas how to fix without targeting API 21 – Jatin Dec 26 '14 at 14:40
  • I don't know exactly. But maybe if you are using Android Studio, may be the IDE wants you to use latest APIs. May be that is causing the problem. I never had this problem. I have no idea how you can overcome this. But if you are using older version of the Android Studio then updating the IDE may help you. – Sazedul Islam Sazid Dec 26 '14 at 16:58