activity.java中的错误,用于phonegap

Har*_*pal 6 java android cordova

我只是配置我的phonegap应用程序并设置为运行"HelloWorld"问题.但我无法正确执行它,因为它总是抛出以下错误.

Cannot reduce the visibility of the inherited method from DroidGap
The import com.phonegap cannot be resolve
Run Code Online (Sandbox Code Playgroud)

这是我在MainActivity.java中的代码

package com.example.mobile;

import org.apache.cordova.DroidGap;

import android.os.Bundle;
import android.view.Menu;
import com.phonegap.*;


public class MainActivity extends DroidGap {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        super.loadUrl("file:///android_asset/www/index.html");
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.activity_main, menu);
        return true;
    }

}
Run Code Online (Sandbox Code Playgroud)

我创建了libs文件夹并添加了cordova-2.2.0.jar,并添加到bulid路径中.但仍然无法弄清楚问题,请建议我解决问题.

谢谢

Tom*_*mer 14

好像你有两个问题:

  1. Cannot reduce the visibility of the inherited method from DroidGap- 尝试protected void onCreate改为public void onCreate.
  2. The import com.phonegap cannot be resolve - 尝试删除该行 import com.phonegap.*;