Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CordovaActivity cannot be resolved to a type in Phonegap 3.4

Hi I am working on PhoneGap through a command line interface.

I am able to create a project, and run an android emulator from the command prompt in Windows 7.

Since I imported and copied the project into my workspace in eclipse, it is showing some errors in the main class which extends CordovaActivity.

The error is:

"CordovaActivity cannot be resolved to a type".

What should I do?

like image 911
user3610969 Avatar asked May 22 '14 12:05

user3610969


3 Answers

For those who don't want to use it from command line just add an external library cordova-android project to resolve this issue.

Follow these steps:

1- Download Cordova android zip from here https://github.com/apache/cordova-android.

2- Extract zip anywhere on your PC. Go inside framework folder.

3- Import this extracted zip folder/framework in your eclipse as an existing project which will result in Cordova project(library) in your workspace.

4- Now right click on your app project -> Properties -> Android. In the Library section choose 'Add' and select Cordova project(library).

5- Finally add import org.apache.cordova; to use extend CordovaActivity.

like image 167
Amrit Pal Singh Avatar answered Nov 16 '22 09:11

Amrit Pal Singh


click the project and select Properties -> Java Build Path -> Source and Add Folder to include the CordovaLib\src folder.

(or)

if you have appname-CordovaLib as an existing project; You can add it to the sourcepath.

like image 29
phani Avatar answered Nov 16 '22 08:11

phani


I was able to get rid of the error by cleaning the project:

From the menu: Project > Clean...

Mac OS X 10.10, Eclipse Luna, and phonegap 3.6.0-0.21.18

like image 3
wesamly Avatar answered Nov 16 '22 09:11

wesamly