I am really struggling here. I finished my cordova app and then went to change the project identifier and broke the whole thing. I wasn't able to get it working again so I thought I would just start a new cordova project, install the facebook plugin again (which I remember as being about 6 hours to figure out the first time) and then just copy the code over.
cordova create PGLunchBox com.roberts.pglunchbox PGLunchBox
cd PGLunchBox/
cordova platform add android
cordova build
But when I start a new project I keep getting errors whenever I try to open it with eclipse. I open eclipse. New -> project -> android project from existing code, then I try selecting the android folder underneath myapp/platforms. Whenever I do this I get an error that and it wont let me build. When I right click the project and go to properties -> java build path -> dependencies then I see an error:
platforms/android/CordovaLib/bin (missing)
I then tried removing the project from eclipse and deleting it. I then created a new one from the CLI and went to import it into eclipse. Instead of importing the project from the platforms/android folder I created a project from my main app directory (PGLunchBox). After restarting eclipse and cleaning the project I was able to get it to run, WOO.
So then I tried to install the facebook plugin (https://github.com/wizcorp/phonegap-facebook-plugin). I went back to the command line and tried:
cordova -d plugin add /Users/croberts/Downloads/phonegap-facebook-plugin-master --variable APP_ID="364000000000002" --variable APP_NAME="PGLunchBox"
in the README for the plugin they say to import the project into eclipse (I don't know if I should import just the android dir or the whole project, but either way it doesn't work for me). When I import the entire cordova project I get 5 different android projects showing up including HelloCordova and whatnot. I do their little steps to add the library but still it won't compile. There are errors all over the place. I then try to close and remove all the android projects and import android project from existing code again and this time select the PGLunchBox/platforms/android directory and then I just get the three projects which looks more like what the README looks like. Then I do their steps and now I get:
One time I was lucky enough to only get one missing library, but I can't seem to get this thing to sort itself out no matter what I do.
Ok so I hope this can help someone. After playing around with this for like 6 hours today, here is what I have discovered:
As far as selecting your app directory goes, you can get the project to work with either app directory, in my case I could choose LunchBox
or the android directory LunchBox/platforms/android
. Then select both projects to add to the workspace (you probably don't want to copy the projects into the workspace because then you will have two separate copies of your code and the eclipse versions will be different then the ones you create with cordova CLI).
Once you have both projects in the workspace you can go to the project properties (right click on myApp
-> properties) then go to java build path and make sure that the cordova library is included under the libraries tab (this was my problem). You should be able to just hit the add button and select it. (in my picture below I have also included the FacebookLib that I am using, you probably will only have the CordovaLib).
Then you can go into the android tab and make sure the library is referenced there as well. If it's not go ahead and hit add again and select it. Again, I have the facebookLib in there but not everyone will.
Save and then you may want need to clean the project or maybe even restart eclipse (eclipse can be funny sometimes). I also had to go back in again into settings and add the library again because it didn't get synced up the first time. So if it still isn't working, double check all that stuff again.