43

I created a Phonegap project according to instructions, checked it into SVN, checked it out and then discovered I could no longer run the build command--necessary to have changes to www be replicated to each platform. Terminal in Mac OS X shows this error:

[Error: Current working directory is not a Cordova-based project.]

Kevin Panko
  • 8,356
  • 19
  • 50
  • 61
Chad Schultz
  • 7,770
  • 6
  • 57
  • 96

9 Answers9

59

Yes as others have stated already you need to check into your SVN a few config files and folders in order to make PhoneGap work when you check it out. This is what defines a PhoneGap project:

  • Has a .cordova directory, with a config.json inside.
  • Has a www directory, with a config.xml inside.
  • Has a platforms directory.

I found that with that in place you can use PhoneGap commands without problems. If you need to see an example of those config files, just run phonegap create myapp.

Jesús Carrera
  • 11,275
  • 4
  • 63
  • 55
  • 3
    Thanks ;)! I had deleted the 'www' directory (since Android uses the assets/www directory instead..). – Dillen Meijboom May 08 '14 at 11:31
  • 1
    I had also deleted the www as was using Yeoman/Grunt to generate it – Damo Aug 21 '14 at 03:59
  • 3
    If you're building ios apps with a fresh pull down of your app code (from git), all you have to do is manually create “www”, “platforms” and “plugins” folders as these are normally ignored in .gitignore. – alexkb Jan 13 '15 at 01:55
  • 3
    I have a working project with config.xml in the root directory. A www and a platforms directory are present, but I have no.cordova directory. To summarize, my config.xml is in the root and .cordova is not needed – mico Feb 25 '16 at 10:16
  • Just a note, the www/ directory does not have a config.xml inside. – f1lt3r Feb 01 '18 at 20:36
13

In a new directory, I just typed

cordova create . 

and that created the .cordova directory as required. Then copy into that directory the phonegap files you want to use.

Thunder Rabbit
  • 5,405
  • 8
  • 44
  • 82
8

When i am creating my project, I got a same error too. You need to enter into the folder what you create before.

cd exampleapp

cell-in
  • 709
  • 2
  • 11
  • 27
  • Yup. Visit this page and scroll down to Add Platform title: http://cordova.apache.org/docs/en/3.3.0/guide/cli/index.html#The%20Command-Line%20Interface – alejnavab Sep 11 '16 at 02:03
5

Doing some searching, I found quite a few complaints about the PhoneGap documentation, but eventually figured this out on my own.

when creating a project, a hidden .cordova folder is created with some project information. For whatever reason, this didn't go into the repository the first time. I copied it over to the checked-out version and fortunately, now Cornerstone sees it and will let me check it into SVN so other team members will not run into this issue.

If you get this error, there's probably a problem with the hidden .cordova folder inside your project folder. Either recreate the project in PhoneGap, or copy it over if you have another version of that same project.

Chad Schultz
  • 7,770
  • 6
  • 57
  • 96
  • 1
    newest versions of Cordova don't create a .cordova folder (not sure starting from which version). For me the issue was solved by creating a new project and moving the www folder to the root folder of the project I was having troubles with (..not a Cordova project..). This worked for me in Ionic2 – dragonmnl Sep 14 '16 at 11:49
5

In my project I had nothing in www, so when I put into git the www folder was missing. I put a .gitignore into www and pushed, than it worked.

balazs
  • 5,698
  • 7
  • 37
  • 45
1

I experienced this problem when working in an Xcode project that somehow didn't build properly with the needed Cordova files. While the existing Cordova plugins are working, installing new ones does not.

My example is for the InAppBrowser plugin.

What I did:

  1. Created a new cordova project with cordova create .
  2. Install the needed plugins in that directory with cordova plugin add https://github.com/apache/cordova-plugin-inappbrowser.git
  3. Go to the plugins folder in that root directory and copy the plugin folders to the plugin folder of your Xcode project. (e.g org.apache.cordova.PLUGIN_NAME)
  4. In the plugin specific folder (inside plugins directory) copy the source files to the Plugins folder inside Xcode (just drag and drop them in and copy to the targets you need)
  5. Be sure to make the necessary changes to your config.xml file (the plugin documentation should tell you)
  6. Rebuild and run - plugin should be working fine

Hope this helps!

bgallz
  • 111
  • 6
1

To complete other answers, this thread will help you understand what should be put in version control or not. The .cordova file should rather be versionned to avoid this kind of problems.

What parts of cordova cli generated projects can be safely versioned in source control?

Community
  • 1
  • 1
Sebastien Lorber
  • 89,644
  • 67
  • 288
  • 419
1

Wrong path!!

go to your workspace and run code again.

NuuoeiZ
  • 94
  • 1
  • 4
0

Make sure you are in your project directory. I made this mistake.

Ashish Kwatra
  • 129
  • 1
  • 5