Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ionic add platform android with custom android-target

Anybody knows how to add platform in ionic with custom android target ? If I try this command :

ionic platform add android

It always add android platform with newest android-target platform, anybody knows how to custom the android target without edit the manifest and custom platform add android version ?

like image 954
Redturbo Avatar asked Feb 23 '16 09:02

Redturbo


People also ask

How do you deploy an ionic app on Android?

Running Your App To run your app, all you have to do is enable USB debugging and Developer Mode on your Android device, then run ionic cordova run android --device from the command line. Enabling USB debugging and Developer Mode can vary between devices, but is easy to look up with a Google search.

How do I change the target SDK version in ionic?

To change the build version you want change your config. xml located at the root project's path. Following lines add in config. xml and then settings are updated automatically at the time building android app.


4 Answers

To change the build version you want change your config.xml located at the root project's path.

Following lines add in config.xml and then settings are updated automatically at the time building android app.

<platform name="android">

  <preference name="android-minSdkVersion" value="XX"/> 
  <preference name="android-targetSdkVersion" value="XX"/>

  <!--other line code -->

</platform>

For Ionic2 please check my gist to here.

Hope this will help you !

like image 187
Santosh Shinde Avatar answered Oct 17 '22 02:10

Santosh Shinde


You should be able to see all the versions of platforms installed in your project with:

cordova platform list

Then you can remove the current version with:

cordova platform remove android

And install the version you want/need with: (in my case 6.1.1)

cordova platform add [email protected]

Source: cordova.apache.org documentation

like image 37
Nikola Avatar answered Oct 17 '22 02:10

Nikola


if you are unaware about the version number try following command

cordova platform add android@latest

this will add latest platform to your application, make sure you try the following command to verify if it breaks anything.

cordova build android
like image 4
Swapnil Kadam Avatar answered Oct 17 '22 03:10

Swapnil Kadam


Tested and it worked.

I changed on config.xml to :

<preference name="android-targetSdkVersion" value="30" />

but it didn’t work so, I remove the platform by using :

cordova platform remove android

then add the latest cordova android version :

cordova platform add android@latest

finally build the project :

cordova build android

It worked! Amazing.

You can check it by going to this file. \platforms\android\app\build\intermediates\merged_manifests\debug\AndroidManifest.xml

like image 3
Chamara Indrajith Avatar answered Oct 17 '22 02:10

Chamara Indrajith