Nativescript: [Android] Cannot overwrite minSdkVersion in AndroidManifest.xml

Created on 12 Dec 2017  路  7Comments  路  Source: NativeScript/NativeScript

Please, provide the details below:

Did you verify this is a real problem by searching [Stack Overflow]

Yes

Tell us about the problem

I am trying to change the minSdkVersion in my AndroidManifest.xml

    <uses-sdk android:minSdkVersion="21" android:targetSdkVersion="__APILEVEL__" />

This is not merged into the generated AndroidManifest.xml.

    <uses-sdk android:minSdkVersion="17"  android:targetSdkVersion="__APILEVEL__"/>

Which platform(s) does your issue occur on?

Android

Please provide the following version numbers that your issue occurs with:

  • CLI: 3.1.2
  • Cross-platform modules: 3.1.0
  • Runtime(s):
  "nativescript": {
    "id": "com.foo.bla",
    "tns-android": {
      "version": "3.1.1"
    },
    "tns-ios": {
      "version": "3.1.0"
    }
  },
android

Most helpful comment

I can confirm: It works with the new version of {N}.

  "nativescript": {
    "id": "com.foo.bla",
    "tns-android": {
      "version": "3.3.1"
    }
  },

This issue can be closed :-)

    <uses-sdk android:minSdkVersion="21" android:targetSdkVersion="25" />

All 7 comments

Hi @simonox,
Thank you for contacting us,
I tested this scenario while using the latest version of NativeScript, however, was unable to recreate this problem. Regarding that could you try upgrading the NativeScritp on your side to the latest available version 3.3.1 and all dependencies in the project while following the below-attached packag.json file.

{
  "description": "NativeScript Application",
  "license": "SEE LICENSE IN <your-license-filename>",
  "readme": "NativeScript Application",
  "repository": "<fill-your-repository-here>",
  "nativescript": {
    "id": "org.nativescript.test",
    "tns-android": {
      "version": "3.3.1"
    }
  },
  "dependencies": {
    "nativescript-theme-core": "~1.0.2",
    "tns-core-modules": "~3.3.0"
  },
  "devDependencies": {
    "babel-traverse": "6.26.0",
    "babel-types": "6.26.0",
    "babylon": "6.18.0",
    "lazy": "1.0.11",
    "nativescript-dev-typescript": "~0.5.0",
    "typescript": "~2.4.2"
  }
}

After those changes remove the platform while using:
tns platform remove android command, delete the node_modules folder and try again to rebuild the project

@tsonevn I will have a try, stay tuned.

I can confirm: It works with the new version of {N}.

  "nativescript": {
    "id": "com.foo.bla",
    "tns-android": {
      "version": "3.3.1"
    }
  },

This issue can be closed :-)

    <uses-sdk android:minSdkVersion="21" android:targetSdkVersion="25" />

@tsonevn I'm currently on NativeScript 4.1.2 and I saw this piece of code in AndroidManifest.xml

<uses-sdk android:minSdkVersion="17" android:targetSdkVersion="__APILEVEL__"/>

Where does the variable __APILEVEL__ came from? I need to change it to support API level 27

HI @weijyewang,
Currently, you can set up the target SDK version of the project via app/App_Resources/Android/app.gradle file. In the upcoming Android runtime version, you will be able to do that also via XML file. For further info, review issue #1104

@tsonevn many thanks. I took the opportunity to update my SDK version using SDK manager from Android Studio as well as the emulator. After that, I tried out the solution you suggested and it works!

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings