简体   繁体   中英

Apache Cordova CordovaActivity cannot be resolved

I have a similar problem to this:

CordovaActivity cannot be resolved to a type in Phonegap 3.4 .

Means, in the main class, CordovaActivity cannot be resolved to a type.

However, I downloaded Cordova Android Zip from here (as explained in the comments): https://github.com/apache/cordova-android .

And included cordova-2.2.0.jar from ./lib/android to my build path.

The line:

import org.apache.cordova

works fine now, but still, it does not find any class called CordovaActivity for extension.

Which I prove by:

grep -r "CordovaActivity" *

on the unpacked cordova-2.2.0.jar folder.

What is wrong here?

在此输入图像描述


besides that, there seems to be a package problem: the main java file is located in ./src/com/testapp/test2 , in line 20 it says after I call cordova -d build :

package com.testapp.test;

with a red underline, that only disappears after I add src. before com.testsapp.test2 . However, that gets crushed with every time I call cordova -d build . If I correct the path in the config.xml from

<widget id="com.testapp.test2" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">

to

<widget id="src.com.testapp.test2" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">

I will have a new package in my package explorer: src.src.com.testapp.test2 , having the same problem.

That seems really weird.

So you are using Eclipse or Android Studio to build?

Anyway, you should add the Cordova module found in platforms/android/CordivaLib as a dependency to your project.

The way to do it for Eclipse is here >> http://red-folder.blogspot.de/2014/01/cordova-330-cordovalib-and-eclipse.html .

And the way to do it in Android Studio is here >> https://stackoverflow.com/a/19188384/1371913

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM