Java 新PhoneGap 3.0 无法解析import org.apache.cordova

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18097370/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-11 22:21:26  来源:igfitidea点击:

New PhoneGap 3.0 The import org.apache.cordova cannot be resolved

javajavascriptandroideclipsecordova

提问by grmmph

I'm installing the new phone gap 3.0 with the all-mighty command line.

我正在使用全能命令行安装新的手机间隙 3.0。

cordova create hello com.example.hello HelloWorld
cordova platform add android

When I open the android project in eclipse I get this error on HelloWorld.java:

当我在 Eclipse 中打开 android 项目时,出现以下错误HelloWorld.java

The import org.apache.cordova cannot be resolved

I guess I have a missing library but how to I solve this if the only way to install 3.0 is thought the command line.

我想我缺少一个库,但是如果认为安装 3.0 的唯一方法是命令行,我该如何解决这个问题。

采纳答案by David Rust-Smith

Update:If you upgrade to Phonegap 3.3 you shouldn't need to do this anymore. Details on updating Phonegap: http://phonegap.com/blog/2013/12/13/phonegap-release/

更新:如果您升级到 Phonegap 3.3,则不再需要这样做。更新Phonegap详情:http://phonegap.com/blog/2013/12/13/phonegap-release/

Note:Make sure in eclipse you import Existing Android Code into WorkspaceNOT 'Existing Projects into Workspace

注意:确保在 eclipse 中将Existing Android Code 导入 Workspace 而不是“Existing Projects into Workspace

I had the exact same problem and found a solution that works:

我遇到了完全相同的问题,并找到了一个有效的解决方案:

  1. Download the source ZIP for Cordova: http://cordova.apache.org/#download
  2. Extract the 'cordova-android' ZIP anywhere. Inside will be a 'framework' folder.
  3. In eclipse open the newly unzipped 'cordova-android/framework' folder as an existing project.
  4. In eclipse right click on this new 'Cordova' project -> Properties -> Android. Make sure 'Is Library' is checked.
  5. Right click on your app's project -> Properties -> Android. In the Library section choose 'Add'. Select your Cordova project.
  1. 下载 Cordova 的源 ZIP:http: //cordova.apache.org/#download
  2. 在任何地方提取“cordova-android”ZIP。里面将是一个“框架”文件夹。
  3. 在 Eclipse 中,将新解压的“cordova-android/framework”文件夹作为现有项目打开。
  4. 在 Eclipse 中右键单击这个新的“Cordova” 项目 -> 属性 -> Android。确保选中“是库”。
  5. 右键单击您应用的项目 -> 属性 -> Android。在库部分选择“添加”。选择您的 Cordova 项目。

All done, import should now resolve!

全部完成,导入现在应该解决了!