Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: able to install app for unsupported Android version

We're dropping support for Android 2.3 (API level 9) devices because most of our users have a newer Android version on their phones. I've updated the minimum SDK version to api level 14.

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"

    defaultConfig {
        minSdkVersion 14
        targetSdkVersion 23
    }
}

However I'm still able to install the app on Android 2.3 devices manually (not by store). Is this expected behavior or am I doing something wrong? I couldn't find the answer somewhere else.

Another strange issue is that Lint doesn't detect the correct api level.

listView.setFastScrollAlwaysVisible(true);

This results in the warning: Call requires api level 11 (current min is 9). However my current minimum is now 14. So this indicates to me that i did something wrong. I tried cleaning and rebuilding the project, restarting Android Studio. It all didn't work.

Can anyone help me out?

Edit

Based on Sufians comment I started fiddling around with my gradle files and I came to the following solution. However some questions still remain. My project structure looks like this:

  • android.gradle (top-level build file which contains SDK versions)
  • main module (contains base code for other modules)
    • build.gradle (apply from: '../android.gradle')
  • sub module A (module specific changes)
    • build.gradle (has dependency on main module)
  • sub module B (module specific changes)
    • build.gradle (has dependency on main module)

I have a top-level build file android.gradle which contains the SDK versions. My modules then include the build file by apply from: '../android.gradle'. If I put the minSdkVersion directly in de main module the warnings disappear. Is that the way it should be? or do I need to set an minSdkVersion for every submodule? Or is there another way so that the SDK versions can stay within the android.gradle file?

like image 454
Wirling Avatar asked Sep 12 '25 06:09

Wirling


1 Answers

Ok... I finally realized that there is nothing wrong in my project structure. The only thing I needed to do was press the little 'Sync Project with Gradle Files' button. After that all errors disappear.

Also I concluded that it's possible to install unsupported apps manually. However the Google Play Store should prevent users from installing or updating the app.

like image 186
Wirling Avatar answered Sep 14 '25 22:09

Wirling