android - Cordova 2.7项目无法编译

标签 android cordova

我已按照 http://cordova.apache.org/docs/en/edge/guide_getting-started_android_index.md.html#Getting%20Started%20with%20Android 中的说明进行操作根据指南,我的项目上有一个“红色 x”;我按照说明清理构建,但没有任何改变。

我收到以下 5 个错误

The import org.apache.cordova cannot be resolved    Bathurst.java   /Bathurst/src/com/aligma/bathurst   line 23 Java Problem
DroidGap cannot be resolved to a type   Bathurst.java   /Bathurst/src/com/aligma/bathurst   line 25 Java Problem
The method onCreate(Bundle) of type Bathurst must override or implement a supertype method  Bathurst.java   /Bathurst/src/com/aligma/bathurst   line 28 Java Problem
DroidGap cannot be resolved to a type   Bathurst.java   /Bathurst/src/com/aligma/bathurst   line 30 Java Problem
Config cannot be resolved   Bathurst.java   /Bathurst/src/com/aligma/bathurst   line 32 Java Problem

生成的包含上述问题的文件如下

package com.aligma.bathurst;

import android.os.Bundle;
import org.apache.cordova.*;

public class Bathurst extends DroidGap
{
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        // Set by <content src="index.html" /> in config.xml
        super.loadUrl(Config.getStartUrl());
        //super.loadUrl("file:///android_asset/www/index.html")
    }
}

这就是我目前遇到的问题。

与此同时,我设法构建了一个 cordova-2.7.0.jar。在项目属性 > Java 构建路径 > 库中,我使用“添加外部 JAR...”按钮添加了它。所有构建错误都消失了,但我无法运行该应用程序。

寻找关于我下一步可以做什么的想法。

最佳答案

In project properties > Java Build Path > Libraries, I added this using the "Add External JARs..." button. All the build errors disappeared but I can't run the application.

撤消它。将 cordova-2.7.0.jar 放入项目的 libs/ 目录中。这不仅会将其添加到您的构建路径中,还会将 JAR 的内容打包到您的 APK 中,而“添加外部 JAR...”则不会。

至于为什么这个JAR在你创建项目的时候没有自动放入libs/中,我没法回答,因为我没有试过2.7。

关于android - Cordova 2.7项目无法编译,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16300894/

相关文章:

cordova - 为桌面 + 移动应用程序选择技术堆栈

javascript - 在 App Browser 中处理 cordova 中的 Payumoney 响应

android - 如何在 Android 上查找每个应用程序的数据使用情况?

android - Espresso : how to click on image click button on phone camera

android - 在 EditText 焦点上抑制软键盘的出现

android - ionic 安卓构建错误 : "All flavors must now belong to a named flavor dimension"

javascript - 减少 Phonegap 项目大小 (Android)

Android 自定义 View onDraw 不工作

android - 如何在Android上检查文件扩展名

android - Cordova 文件传输插件不上传视频到服务器