Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android - Changing compileSdkVersion leads to errors

I am using Android Studio 1.2.2 to develop an Android Application. In my build.gradle file, I have defined the compileSdkVersion to 21 since the beginning of the work. Now I wanted to change that to 19, since this software actually will never be installed on an Android device, that runs a higher version than Android 4.4

When I try to change this value to 19, the project does not compile anymore.

After the change of the version value I have:

  • synced the project
  • cleaned the project
  • rebuild the project (tried)

But the following error occurs:

In the file /projectpath/app/build/intermediates/exploded-aar/com.android.support/appcompat-v7/22.2.0/res/values-v21/values-v21.xml it marks 103 errors, saying "cannot resolve symbol".

values-v21.xml:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <!-- From: file:/usr/local/google/buildbot/repo_clients/https___googleplex-android.googlesource.com_a_platform_manifest.git/lmp-mr1-supportlib-release/frameworks/support/v7/appcompat/res/values-v21/styles_base_text.xml -->
    <eat-comment/>
    <style name="Base.TextAppearance.AppCompat" parent="android:TextAppearance.Material"/>
    <style name="Base.TextAppearance.AppCompat.Body1" parent="android:TextAppearance.Material.Body1"/>
    <style name="Base.TextAppearance.AppCompat.Body2" parent="android:TextAppearance.Material.Body2"/>
    <style name="Base.TextAppearance.AppCompat.Button" parent="android:TextAppearance.Material.Button"/>
....
  • cannot resovle symbol android:TextAppearance.Material
  • cannot resovle symbol android:TextAppearance.Material.Body1
  • cannot resovle symbol android:TextAppearance.Material.Body2
  • cannot resovle symbol android:TextAppearance.Material.Button

and so on...

What is causing this error? What can I do to make it compile again? When I change back the compileSdkVersion to 21, everything works normal again.

My build.gradle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 19
    buildToolsVersion '23.0.0 rc3'
    defaultConfig {
        applicationId 'com.appname.id'
        minSdkVersion 17
        targetSdkVersion 19
        versionCode 1
        versionName "0.0.2 Alpha"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    productFlavors {
    }
}

repositories {
    maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
    mavenCentral()
}



dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:22.2.0'
}
like image 945
Michael B Avatar asked Oct 31 '22 22:10

Michael B


1 Answers

to use appcompat-v7:22.2.0 you have to compile against API 21. There's no harm in doing it, even if it will never run on devices running 21.

You can try some older version of the app compat, but then you will be missing in "cool new features" and bug fixes from the latest app compat.

like image 142
Budius Avatar answered Nov 09 '22 10:11

Budius