-2

I need to compile my project(which is very simple, it's almost empty) with targetSdk and compileSdk versions 19. Here is my gradle file:

apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'

android {
    compileSdkVersion 19
    buildToolsVersion '23.0.3'

    defaultConfig {
        applicationId "com.my.app"
        minSdkVersion 15
        targetSdkVersion 19
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

repositories {
    mavenCentral()
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:19.1.0'
    compile 'com.google.android.gms:play-services:8.3.0'
    compile 'com.appsflyer:af-android-sdk:4.6.0@aar'
}

As far as I know, I am using the proper appcompat library - it must be the same as targetSdk and compileSdk versions, though it does not compile with 19.0.0, it says, that it is out of date and automatically switches it to 19.1.0. I even tried to get rid of the appcompat library at all(there was a hint that at this sdk version I have no need in that).

After every change in gradle file I clean and resync the project. Though I still get the same bunch of errors:

Error:(13) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Inverse'.
Error:(15) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Large.Inverse'.
Error:(21) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Medium.Inverse'.
Error:(28) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Small.Inverse'.
Error:(206) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.ProgressBar'.
Error:(208) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.ProgressBar.Horizontal'.
Error:(211) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Spinner'.

I did not insert all the errors, they are pretty much the same and there are 203 of them. What could be the problem?

P.S. This is not a duplicate. I need to compile for version 19, not 21. Please, before downvoting, make sure, that you understood the question. I need to make it work!

Sam Stone
  • 457
  • 1
  • 7
  • 32

3 Answers3

1

Material Design was introduced in API 20.

When importing:

compile 'com.google.android.gms:play-services:8.3.0'

You really import appcompat-v7:22.2.0. See the dependencies here

You should declare at most:

compile 'com.google.android.gms:play-services:5.0.89'
R. Zagórski
  • 18,351
  • 5
  • 59
  • 86
  • It seems that while I have that appsflyer library in my project I will not be able to compile 19 version. Thank you for the answer. – Sam Stone Dec 01 '16 at 10:33
1

Why would you target SDK19? It's recommended to always target the latest SDK. Your code isn't compiling because Material wasn't introduced until SDK21.

If you're trying to make your app compatible with older Android versions, that's what minSdkVersion is for.

See AppCompat v7 r21 returning error in values.xml? for more information.

If you really need to use SDK19 you will have to downgrade other dependencies that do require SDK21+. Otherwise what you are trying to achieve is impossible. How could those dependencies work if they don't get the proper SDK to compile with

Community
  • 1
  • 1
Raymond
  • 1,943
  • 2
  • 18
  • 30
0

I agree with R. Zagórski but couldn't comment due to reputation points. It is essential to understand that if you include dependencies that require newer versions of Android SDK your project will be automatically updated to required Version. If you insist on using sdk19 and also wish to maintain the material design look please consider looking into third party libraries that let you mimic the look of Google Material design.Here is a great resource for those free libraries https://android-arsenal.com/

kPieczonka
  • 384
  • 1
  • 13