Home>

How can I find out the installed Android SDKin an app and change it? I go to android/app/src/file build.gradle. Previously, there were numbers indicated versions, now they are not.

Project Structure is usually set to No SDK, I chose the latest Android SDK 32

Compiled the application, so far so good.

Now I manually changed the build.gradlefile to the Android SDKversion, instead of

flutter.compileSdkVersion

I wrote in numbers

32

Compiled the application, the application works, but there are many errors

QUESTION. How to correctly find out the installed version by default? Is it possible to manually change versions in a file like this?

  • Answer # 1

    Default values ​​are hardwired in the bowels of the Flutter SDK in file /packages/flutter_tools/gradle/flutter.gradle.

    For example, for version 2.8.1:

    /** For apps only. Provides the flutter extension used in app/build.gradle. */
    class FlutterExtension {
        /** Sets the compileSdkVersion used by default in Flutter app projects. */
        static int compileSdkVersion=31
        /** Sets the minSdkVersion used by default in Flutter app projects. */
        static int minSdkVersion= 16
        /** Sets the targetSdkVersion used by default in Flutter app projects. */
        static int targetSdkVersion=31
    

    This was done in the expectation that when you change the Flutter SDK, the versions of the Android SDKwill automatically change, which is quite acceptable for projects without platform-level refinement. Another thing is if changes were made to the Android project and they are tied to a certain version range. Here it is already necessary to set specific values.

    I can't say for sure about the errors, but if the Android project is inheritedfrom older versions and has not been modified, then you can simply delete the androidfolder and recreate it again teamflutter create .(having made, just in case, saving the entire project).

    Dear Spatz! Thank you very much!

    Sergey2022-01-20 17:47:26
  • Answer # 2

    Default values ​​are hardwired in the bowels of the Flutter SDK in file /packages/flutter_tools/gradle/flutter.gradle.

    For example, for version 2.8.1:

    /** For apps only. Provides the flutter extension used in app/build.gradle. */
    class FlutterExtension {
        /** Sets the compileSdkVersion used by default in Flutter app projects. */
        static int compileSdkVersion=31
        /** Sets the minSdkVersion used by default in Flutter app projects. */
        static int minSdkVersion= 16
        /** Sets the targetSdkVersion used by default in Flutter app projects. */
        static int targetSdkVersion=31
    

    This was done in the expectation that when you change the Flutter SDK, the versions of the Android SDKwill automatically change, which is quite acceptable for projects without platform-level refinement. Another thing is if changes were made to the Android project and they are tied to a certain version range. Here it is already necessary to set specific values.

    I can't say for sure about the errors, but if the Android project is inheritedfrom older versions and has not been modified, then you can simply delete the androidfolder and recreate it again teamflutter create .(having made, just in case, saving the entire project).

    Dear Spatz! Thank you very much!

    Sergey2022-01-20 17:47:26