0

I am having some problems with PhoneGap 3.0 Everything was working as should on PhoneGap 2.9

Now I upgraded to 3.0 And created a new PhoneGap Project.

$> phonegap create new_project

added to config.xml :

<feature name="http://api.phonegap.com/1.0/geolocation"/>

and for index.html I used the full example from http://docs.phonegap.com/en/edge/cordova_geolocation_geolocation.md.html#geolocation.getCurrentPosition_full_example

then

$> phonegap build android

I imported the project to Eclipse and checked the following : AndroidManifest.xml has

<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

xml/config.xml has

<feature name="Geolocation">
    <param name="android-package" value="org.apache.cordova.geolocation.GeoBroker" />
</feature>

I also used this cmd :

$> phonegap local plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation.git

and that created the package src/

org.apache.cordova.geolocation

now when I run my app. I got the Following errors :

I/System.out(15155): Error adding plugin org.apache.cordova.geolocation.GeoBroker.
D/PluginManager(15155): exec() call to unknown plugin: Geolocation

error Trace :

09-14 18:07:50.185: W/System.err(28211): java.lang.ClassNotFoundException: org.apache.cordova.geolocation.GeoBroker
09-14 18:07:50.195: W/System.err(28211):    at java.lang.Class.classForName(Native Method)
09-14 18:07:50.195: W/System.err(28211):    at java.lang.Class.forName(Class.java:217)
09-14 18:07:50.195: W/System.err(28211):    at java.lang.Class.forName(Class.java:172)
09-14 18:07:50.195: W/System.err(28211):    at org.apache.cordova.PluginEntry.getClassByName(PluginEntry.java:117)
09-14 18:07:50.195: W/System.err(28211):    at org.apache.cordova.PluginEntry.createPlugin(PluginEntry.java:93)
09-14 18:07:50.195: W/System.err(28211):    at org.apache.cordova.PluginManager.getPlugin(PluginManager.java:267)
09-14 18:07:50.205: W/System.err(28211):    at org.apache.cordova.PluginManager.execHelper(PluginManager.java:221)
09-14 18:07:50.205: W/System.err(28211):    at org.apache.cordova.PluginManager.exec(PluginManager.java:216)
09-14 18:07:50.205: W/System.err(28211):    at org.apache.cordova.ExposedJsApi.exec(ExposedJsApi.java:53)
09-14 18:07:50.205: W/System.err(28211):    at android.webkit.JWebCoreJavaBridge.sharedTimerFired(Native Method)
09-14 18:07:50.205: W/System.err(28211):    at android.webkit.JWebCoreJavaBridge.sharedTimerFired(Native Method)
09-14 18:07:50.205: W/System.err(28211):    at android.webkit.JWebCoreJavaBridge.fireSharedTimer(JWebCoreJavaBridge.java:107)
09-14 18:07:50.215: W/System.err(28211):    at android.webkit.JWebCoreJavaBridge.handleMessage(JWebCoreJavaBridge.java:136)
09-14 18:07:50.215: W/System.err(28211):    at android.os.Handler.dispatchMessage(Handler.java:99)
09-14 18:07:50.215: W/System.err(28211):    at android.os.Looper.loop(Looper.java:154)
09-14 18:07:50.215: W/System.err(28211):    at android.webkit.WebViewCore$WebCoreThread.run(WebViewCore.java:780)
09-14 18:07:50.215: W/System.err(28211):    at java.lang.Thread.run(Thread.java:864)
09-14 18:07:50.225: W/System.err(28211): Caused by: java.lang.NoClassDefFoundError: org/apache/cordova/geolocation/GeoBroker
09-14 18:07:50.225: W/System.err(28211):    ... 17 more
09-14 18:07:50.225: W/System.err(28211): Caused by: java.lang.ClassNotFoundException: org.apache.cordova.geolocation.GeoBroker
09-14 18:07:50.225: W/System.err(28211):    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
09-14 18:07:50.225: W/System.err(28211):    at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
09-14 18:07:50.225: W/System.err(28211):    at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
09-14 18:07:50.235: W/System.err(28211):    ... 17 more

and the Javascript function onError() alert with code:null & message:

Any suggestions ?

Thank you in Advance

4

1 回答 1

1

I thinks it's strange, but it was solved by following the steps from this link.

You need to download Cordova Android from here. Then run these commands to build cordova-dev.jar:

android update project -p . -t android-17
ant jar

This will create cordova-dev.jar. Alternatively you can download the jar from here.

Copy cordova-dev.jar to libs folder in the Android project in eclipse and add it to the project classpath. Now all the compilation errors will be resolved, and the project will compile successfully.

于 2013-09-14T18:28:22.540 回答