Not able to add platform after upgrading to ionic 3

I am not able to add platform after upgrading to ionic 3.

global packages:

@ionic/cli-utils : 1.3.0
Cordova CLI      : 7.0.1 
Ionic CLI        : 3.3.0

local packages:

@ionic/app-scripts              : 1.3.7
@ionic/cli-plugin-cordova       : 1.3.0
@ionic/cli-plugin-ionic-angular : 1.3.0
Cordova Platforms               : android 6.2.3 ios 4.4.0
Ionic Framework                 : ionic-angular 3.3.0

System:

Node       : v6.10.3
OS         : macOS Sierra
Xcode      : Xcode 8.3.1 Build version 8E1000a 
ios-deploy : not installed
ios-sim    : 5.0.13 

I am getting this error every time

parthas-MacBook-Pro:App parthpratim$ ionic cordova platform add android

cordova platform add android --save
:heavy_multiplication_x: Running command - failed!

[ERROR] Cordova encountered an error.
You may get more insight by running the Cordova command above directly.

[ERROR] An error occurred while running cordova platform add android --save (exit code 1):

    Using cordova-fetch for cordova-android@^6.2.3
   Error: Platform android already added.

i Have tried the below too
parthas-MacBook-Pro:App parthpratim$ cordova platform add android
Using cordova-fetch for cordova-android@^6.2.3
Error: Platform android already added.
parthas-MacBook-Pro:App parthpratim$ cordova run android
Error: Source path does not exist: resources/android/icon/drawable-hdpi-icon.png

Why do you want to add the platform again?

1 Like

Accually its not added, there is no platform folder, when i ran “cordova run android” it is asking me to add platform.

Really?
I thought it was ok since the msg says the platform is there

 Using cordova-fetch for cordova-android@^6.2.3
 Error: Platform android already added.

Maybe trying to remove it and add it again?

ionic cordova platform rm android --save
ionic cordova platform add android@latest --save

yes :frowning: also i cant see the platform folder like my old ionic 2 app.

Let me try your given command, will get back to you

parthas-MacBook-Pro:App parthpratim$ ionic cordova platform rm android --save

cordova platform remove android --save
:heavy_check_mark: Running command - done!
Removing platform android from config.xml file…
parthas-MacBook-Pro:App parthpratim$ ionic cordova platform add android@latest --save
cordova platform add android@latest --save
:heavy_multiplication_x: Running command - failed!

[ERROR] Cordova encountered an error.
You may get more insight by running the Cordova command above directly.

[ERROR] An error occurred while running cordova platform add android@latest --save (exit code 1):

    Using cordova-fetch for cordova-android@latest
    Adding android project...
    Creating Cordova project for the Android platform:
    	Path: platforms/android
    	Package: com.ionicframework.trapapp152823
    	Name: TrapApp
    	Activity: MainActivity
    	Android target: android-25
    Subproject Path: CordovaLib
    Android project created with cordova-android@6.2.3
    Error: Source path does not exist: resources/android/icon/drawable-hdpi-icon.png

This is strange, Package and name are showing the old app
Package: com.ionicframework.trapapp152823
Name: TrapApp

Looks better…now in your config.xml find the line where you’ve got

 drawable-hdpi-icon.png

and remove the line (or create the icon, but for test at least will be faster to remove it)

Then rm/add the platform again

Its not working , Package and name are showing the old app

what do you mean? did you remove the drawable-hdpi-icon.png in your config.xml? did you remove and add the platform again?

could you plz paste the ALL log of the cmd you are running?

yes i removed the drawable-hdpi-icon.png from config.xml then ran the below command

parthas-MacBook-Pro:App parthpratim$ ionic cordova platform rm android

cordova platform remove android --save
:heavy_check_mark: Running command - done!
Removing platform android from config.xml file…
parthas-MacBook-Pro:App parthpratim$ ionic cordova platform add android@latest
cordova platform add android@latest --save
:heavy_multiplication_x: Running command - failed!

[ERROR] Cordova encountered an error.
You may get more insight by running the Cordova command above directly.

[ERROR] An error occurred while running cordova platform add android@latest --save (exit code 1):

    Using cordova-fetch for cordova-android@latest
    Adding android project...
    Creating Cordova project for the Android platform:
    	Path: platforms/android
    	Package: com.ionicframework.trapapp152823
    	Name: TrapApp
    	Activity: MainActivity
    	Android target: android-25
    Subproject Path: CordovaLib
    Android project created with cordova-android@6.2.3
    Error: Source path does not exist: resources/android/icon/drawable-hdpi-icon.png

Can you see the name : TrapApp? why it is showing here any idea ? its my old project

Do you use windows?

Found that post https://stackoverflow.com/a/40458796/5404186 maybe this solution works for you?

i am using mac, i have seen the post earlier dint work for me either

well I’m out of ideas. If you removed the line

<icon density="hdpi" src="resources\android\icon\drawable-hdpi-icon.png" />

from your config.xml, I don’t understand why you still got the error.

I’d make sure that the file exists by running ionic cordova resources again (or just create one manually). Seems like an easy fix.

@partha_pratim: Please edit your post and use the </> button above the post input field to format your code or error message or wrap it in ``` (“code fences”) manually. This will make sure your text is readable and if it recognizes the programming language it also automatically adds code syntax highlighting. Thanks.[quote=“partha_pratim, post:10, topic:93486”]
Can you see the name : TrapApp? why it is showing here any idea ? its my old project
[/quote]

Are you sure you are in the right directory and everything?

1 Like
parthas-MacBook-Pro:App parthpratim$ clear

parthas-MacBook-Pro:App parthpratim$ ionic cordova resources
âś” Collecting resource configuration and source images - done!
[ERROR] No platforms have been added. Please run: ionic cordova platform add

yes i am on the right directory.

But when i run ionic cordova platform add android

parthas-MacBook-Pro:App parthpratim$ ionic cordova platform add android
> cordova platform add android --save
âś– Running command - failed!

[ERROR] Cordova encountered an error.
        You may get more insight by running the Cordova command above directly.
        
[ERROR] An error occurred while running cordova platform add android --save (exit code 1):
        
        Using cordova-fetch for cordova-android@^6.2.3
        Error: Platform android already added.

That is pretty clear.
If you want to add it again (for whatever reason), you have to remove it first: ionic cordova platform remove android

And again:
Please edit your post and use the </> button above the post input field to format your code or error message or wrap it in ``` (“code fences”) manually. This will make sure your text is readable and if it recognizes the programming language it also automatically adds code syntax highlighting. Thanks.

I already added </> button

if it is already added then why i am getting below error.
ionic cordova resources âś” Collecting resource configuration and source images - done! [ERROR] No platforms have been added. Please run: ionic cordova platform add

1 Like

Seems something is wrong.

Post your current ionic info output again please.

parthas-MacBook-Pro:App parthpratim$ ionic info

global packages:

    @ionic/cli-utils : 1.3.0
    Cordova CLI      : 7.0.1 
    Ionic CLI        : 3.3.0

local packages:

    @ionic/app-scripts              : 1.3.7
    @ionic/cli-plugin-cordova       : 1.3.0
    @ionic/cli-plugin-ionic-angular : 1.3.0
    Cordova Platforms               : android 6.2.3 ios 4.4.0
    Ionic Framework                 : ionic-angular 3.3.0

System:

    Node       : v6.10.3
    OS         : macOS Sierra
    Xcode      : Xcode 8.3.1 Build version 8E1000a 
    ios-deploy : not installed
    ios-sim    : 5.0.13 

Ok, so ionic info recognizes the platforms which means that cordova platform list does, too.

Now run ionic cordova resources --verbose.

1 Like