Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DroidGap cannot be resolved into a type

hi i am getting an error that DroidGap cannot be resolved as a type my code is

package com.hello.ponegap;

import android.app.Activity;
import android.os.Bundle;
import com.hello.*;

public class HelloponegapActivity extends DroidGap  {
  /** Called when the activity is first created. */ 

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

thanks in advance also i am not getting build path when i right click on lib

like image 912
kavinhuh Avatar asked Jun 28 '12 10:06

kavinhuh


2 Answers

Add this line to the imports

import org.apache.cordova.DroidGap;

EDIT:

If you are using Eclipse, you can use the key combination Ctrl + Shift + O to organize imports. This removes unused imports, and also will import the needed packages and/or classes (If there are multiple possibilities, e.g. android.view.View.OnClickListener and android.content.DialogInterface.OnClickListener, Eclipse will give you the chance to select the desired class to import).


EDIT:

You did not add the cordova jar to the build path. I checked your .classpath file on the github repo, and it lacks this line: <classpathentry kind="lib" path="libs/cordova-1.8.1.jar"/>.

Solution: Right-click on the codova-1.x.x.jar -> Build path -> Add to build path.

Please try to follow the steps defined here.


EDIT

Do the following: 1. Right-click the project. 2. Click properties. 3. On the left, select Java Build Path. 4. You see four tabs: Source, Projects, Libraries, Order and Export. Select Libraries. 5. On the right click the button Add JARs.... 6. Search for cordova-1.x.x.jar in your project, and select it. 7. Click OK. 8. Done

like image 137
overbet13 Avatar answered Oct 22 '22 13:10

overbet13


Eclpise: This might be stupid, but if you added the cordova jar and the app is STILL not working on your emulator or device, check that you have also checked the checkbox left of the jar file in

"Project Properties > Java Build Path > Order and Export"

like image 38
ToBe Avatar answered Oct 22 '22 13:10

ToBe