7

I have a device with android version 10.

Also, I have an emulator with API 22

this is a part of my build.gradle(:app) file:

apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-kapt'

apply plugin: 'kotlin-android-extensions'

android {
    dataBinding {
        enabled = true
    }
    compileSdkVersion 'android-R'
    defaultConfig {
        applicationId "com.example.android.sOnline"
        minSdkVersion 17
        targetSdkVersion 'R'
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
//        android.defaultConfig.javaCompileOptions.annotationProcessorOptions.includeCompileClasspath = true
    }
}

It just not working on 'android-R'

Thank you for helping me :)

hamid keyhani
  • 451
  • 3
  • 12

3 Answers3

15

targetSdkVersion "R" will restrict your app to only running on Android R, by artificially raising your minSdkVersion to R. This has been the case for the past several years: each developer preview only supports running the app on the developer preview itself, not older devices.

Sometime later this year, we will be able to switch to using targetSdkVersion 30, at which point normal behavior returns with respect to minSdkVersion.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • 1
    @user1090751: I do not know what you consider "the problem" to be. If you want to experiment with `targetSdkVersion 'R'`, you can do so, but that app cannot be installed on Android 10 or older devices. So, your experiments need to be a bit separate from other work. That could be by using product flavors (one flavor for normal, one flavor for R). Or, it could be by using a separate development branch in your version control system. Or, it could be by simply making a copy of your project and experimenting with the copy. – CommonsWare Apr 06 '20 at 11:37
1
  1. Go to build.gradle file
  2. in defaultConfig: change minSdk to 28 and targetSdk to 30

I use a samsung s9 plus, had the same problem and now it works

defaultConfig {
        applicationId "com.example.consigness"
        minSdk 28
        targetSdk 30
        versionCode 1
        versionName "1.0"

        multiDexEnabled true
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
0

For me it was that the virtual device was corrupted , to fix this follow these steps :

  1. open the AVD manager from the top right corner.
  2. delete the device from the actions menu.
  3. create a new one.
  4. choose the new device and run your application.

For future safety before exiting the android studio make sure to close the emulator first.

amr samy
  • 71
  • 1
  • 5