user2320724
user2320724

Reputation: 676

cordova platform add android gives the error: "Error: The provided path is not an Android project."

When I run the command, I get the error:

C:\Users\me\adtworkspace\project1>cordova platform add android [Error: The provided path "C:\Users\me\adtworkspace\project1\platforms\android" is not an Android project.]

What am I doing wrong?

Upvotes: 18

Views: 33220

Answers (7)

This is happening when you missing some files in your android platform folder in your cordova project.

Same thing can happen with the windows projects as well.

Visual Studio or Cordova engine has the capability of creating platform directories even if you delete them. But in this case the folder was there and it had some files in it. So the best solutions for this issue is trying one of these steps.

Clean your project. ( Visual Studio ) Rebuild your project ( Visual Studio ) Delete platform directory that you have the issue and build the project.

Upvotes: 1

wf9a5m75
wf9a5m75

Reputation: 6158

For cordova 3.x users:

Create ".cordova" file at root in the project.

"isCordova" returns true if finds ".cordova" file at line 42 https://github.com/apache/cordova-cli/blob/cordova-3.1.x/src/util.js


"Current working directory is not a Cordova-based project." causes at line 31 in plugin.js https://github.com/apache/cordova-cli/blob/cordova-3.1.x/src/plugin.js

Upvotes: 1

Juergen Klasen
Juergen Klasen

Reputation: 829

Yes it's indeed a Cordova Metadata issue. So Krystofs' answer is correct. Where: The "right thing" to do is, to give a

# cordova platform rm <platform>

command :) Then - afterwards - another adding of the plaform shall sort the issue

Upvotes: 43

fdibartolo
fdibartolo

Reputation: 45

I have faced the same but building for iOS. I had an old build within the platforms folder. Try deleting it, then build again:

phonegap build [ios/android]

Hope this helps!

Upvotes: 0

Kryštof Hilar
Kryštof Hilar

Reputation: 639

Delete C:/users/yourusername/.cordova and run command again, files are propably corrupted, it fixed this issue for me

Upvotes: 4

user2621227
user2621227

Reputation: 41

If you were to do a "cordova -d platform add android", you'll probably see that it is because a prior error happened due to "There is no script engine for file extension ".js"".

Windows associated .js files with some other editors, so you have to disassociate this by typing:

assoc .js=JSFILE

After doing this, just run the add platform ("cordova platform add android") command again and it should work fine.

Upvotes: 4

Nick Holcombe
Nick Holcombe

Reputation: 171

I had the same problem which I solved using the -d flag to show debug output

cordova -d platform add android

My debug output showed that I need to set a JAVA_HOME environment variable and then I needed to add JAVA and ANT to the path.

Upvotes: 17

Related Questions