5

Due to some problems with permissions in SDK API 23 (Marshmallow) I wanted to switch back to API 21, yet I'm encountering some issues... I've read so many posts with similiar problems and tried (almost I guess) everything: I've updated all SDK Build/Platform Tools, features for API 21, Suport and Repository Libraries. Then I've cleaned up the project, rebuilt it and synchronized. Yet, I'm getting those errors: enter image description here

My build.gradle looks like following:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 21
    buildToolsVersion "21.1.2"
    defaultConfig {
        applicationId "com.example.pablo.appcontacts"
        minSdkVersion 19
        targetSdkVersion 21
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    productFlavors {
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    testCompile 'junit:junit:4.12'
    compile 'com.jakewharton:butterknife:7.0.1'
    compile 'com.android.support:appcompat-v7:23.1.1'
}

I'm not very familiar with this, can anybody help me to fix this cause I really can't find a way to..?

josedlujan
  • 5,357
  • 2
  • 27
  • 49
Paweł Poręba
  • 1,084
  • 1
  • 14
  • 37
  • 3
    "Due to some problems with permissions in SDK API 23 (Marshmallow) I wanted to switch back to API 21" -- that won't solve any of your problems. The `compileSdkVersion`, libraries, etc. have nothing to do with [the runtime permission problems you are encountering](https://stackoverflow.com/questions/34095129/android-frustrating-permissions). `targetSdkVersion` does, but you do not have to change anything else in your app to reduce your `targetSdkVersion` to 22 or something. – CommonsWare Dec 04 '15 at 22:45
  • @CommonsWare Ok, thank you, I didn't know that. – Paweł Poręba Dec 04 '15 at 22:52
  • 2
    For more information, see [our blog post on compileSdkVersion vs targetSdkVersion](https://medium.com/google-developers/picking-your-compilesdkversion-minsdkversion-targetsdkversion-a098a0341ebd) – ianhanniballake Jan 23 '16 at 02:58

1 Answers1

4

3 Steps:

1 Edit build.grade

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.1"

    defaultConfig {
        applicationId "com.stackoverflow.answer"
        minSdkVersion 16
        targetSdkVersion 21
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}

dependencies {
    androidTestCompile 'junit:junit:4.12'
    compile fileTree(dir: 'libs', include: ['*.jar'])
}

2 Sync gradle button

3 Rebuild project

josedlujan
  • 5,357
  • 2
  • 27
  • 49
  • 1
    It's nice, but I think not totally correct. I also needed to add the lines to the repository support in dependencies, otherwise I was getting some errors about missing resources in `styles.xml`. – Paweł Poręba Dec 05 '15 at 20:27
  • But that changes @PawełPoręba depends for the android version, each version has differents options. – josedlujan Jan 26 '17 at 13:28