Question

I have downloaded Phonegap from CLI (working on windows7) and made a project from command line

phonegap create hello com.example.hello HelloWorld

and built it

phonegap build android

When i import project (project/platforms/android) in Intelijj and try to build it, it gives me this error

java: duplicate class: org.apache.cordova.BuildConfig

Any advice?

Était-ce utile?

La solution

The steps that I did to import project in IntelliJ, after I built the application with "cordova build":

  1. Import project
  2. select "PROJECT_FOLDER/platforms"
  3. Import project from external model "Eclipse"
  4. In select Eclipse project, select all.
  5. Import JDK and SDK (JDK 1.7 and SDK Android API 17 and 19 in my case)
  6. Import Android Dependencies From Property Files (Add dependency helloworls --> helloworld-cordovaLib) OK.

At last this build and run without problem to me.

Autres conseils

There are an issue with IntelliJ and Maven, maybe you can apply the same solution. http://youtrack.jetbrains.com/issue/IDEA-94901

1.) Delete the "gen", "target" and "out" folders

2.) Revert the changes within the "ipr" and "iml" files

3.) Start IntelliJ 11.1.5 EAP / 12 EAP

4.) Open the pom file

5.) Right click -> "Maven" -> "Reimport"

6.) "Build" -> "Rebuild project"

A better workaround (tl;dr): Don't do the 'cordova build' step from the Cordova workflow (Getting Started Guide for Android)

We ran into this issue while doing Cordova training for our students. The recommended tool from developer.android.com switched from the Eclipse ADT Bundle to Android Studio, so we made the switch.

Unfortunately, you can't follow the same workflow. The Cordova 'Getting Started' guide for the Android platform spells out the commands to execute from the command line. But, they are for the Eclipse platform. One step needs to omitted for it to work with Android Studio.

One of the links above (http://www.tricedesigns.com/2013/05/16/phonegap-android-studio/) shows the correct workflow, but if you're used to the Cordova workflow, you may just assume it's the same and complete the steps in the same way. However! Omit the 'cordova build' step. Building the project (instead of letting Android Studio build it) causes Android Studio to get the error from the question.

The accepted answer above didn't work for us, because when we attempt to import the project, there is no 'Import project from external model "Eclipse"' option. This, however, worked just fine. Hope this saves you the hours we spent looking for answers/troubleshooting.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top