Not able to add platform after upgrading to ionic 3


#1

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


#2

Why do you want to add the platform again?


#3

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


#4

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

#5

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


#6

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


#7

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


#8

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


#9

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?


#10

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


#11

Do you use windows?

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


#12

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


#13

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.


#14

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?


#15
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.

#16

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.


#17

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


#18

Seems something is wrong.

Post your current ionic info output again please.


#19
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 

#20

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

Now run ionic cordova resources --verbose.