Android Phonegap 2.1> 2.2 Update Error

I am working on a Phonegap application and saw that Phonegap has recently been updated to version 2.2 with many fixes for Android. Therefore, I immediately update, replacing the xml, jar and JS file. My application worked perfectly. It uses the Javascript user interface to add additional features. Unfortunately, when upgrading to version 2.2, I get the following error log:

Pastebin Error Log

This is the error I get when starting the application on my Samsung Galaxy S2 running 4.0.4. This is the main Java application file I use.

Java Pastebin File

Hope you guys can help me. I do not know what might cause the JNI error.

EDIT: I tried the same code on Android 2.2 emulator, and this gave me a more descriptive error:

10-31 13:02:12.945: I/dalvikvm(543): Could not find method android.webkit.WebView.<init>, referenced from method org.apache.cordova.CordovaWebView.<init> 10-31 13:02:12.945: W/dalvikvm(543): VFY: unable to resolve direct method 3298: Landroid/webkit/WebView;.<init> (Landroid/content/Context;Landroid/util/AttributeSet;IZ)V 10-31 13:02:12.945: D/dalvikvm(543): VFY: replacing opcode 0x70 at 0x0001 10-31 13:02:12.945: D/dalvikvm(543): VFY: dead code 0x0004-005b in Lorg/apache/cordova/CordovaWebView;.<init> (Landroid/content/Context;Landroid/util/AttributeSet;IZ)V 10-31 13:02:13.195: I/CordovaLog(543): Changing log level to DEBUG(3) 10-31 13:02:13.205: I/CordovaLog(543): Found preference for useBrowserHistory=false 10-31 13:02:13.205: D/CordovaLog(543): Found preference for useBrowserHistory=false 10-31 13:02:13.205: I/CordovaLog(543): Found preference for exit-on-suspend=false 10-31 13:02:13.205: D/CordovaLog(543): Found preference for exit-on-suspend=false 10-31 13:02:13.215: W/CordovaWebView(543): useBrowserHistory=false is deprecated as of Cordova 2.2.0 and will be removed six months after the 2.2.0 release. Please use the browser history and use history.back(). 10-31 13:02:13.245: D/JsMessageQueue(543): Set native->JS mode to 2 10-31 13:02:13.245: I/CordovaWebView(543): Disabled addJavascriptInterface() bridge since Android version is old. 10-31 13:02:13.255: D/CordovaWebView(543): Origin to allow: http://127.0.0.1* 10-31 13:02:13.255: D/CordovaWebView(543): Unlimited access to network resources 10-31 13:02:13.265: D/CordovaWebView(543): Origin to allow: http://api.enkhuizenapp.nl 10-31 13:02:13.265: D/CordovaWebView(543): Origin to allow: .* 10-31 13:02:13.265: I/CordovaLog(543): Found log level DEBUG 10-31 13:02:13.265: I/CordovaLog(543): Changing log level to DEBUG(3) 10-31 13:02:13.265: I/CordovaLog(543): Found preference for useBrowserHistory=false 10-31 13:02:13.265: D/CordovaLog(543): Found preference for useBrowserHistory=false 10-31 13:02:13.265: I/CordovaLog(543): Found preference for exit-on-suspend=false 10-31 13:02:13.265: D/CordovaLog(543): Found preference for exit-on-suspend=false 10-31 13:02:13.265: W/CordovaWebView(543): useBrowserHistory=false is deprecated as of Cordova 2.2.0 and will be removed six months after the 2.2.0 release. Please use the browser history and use history.back(). 10-31 13:02:13.285: D/JsMessageQueue(543): Set native->JS mode to 2 10-31 13:02:13.285: I/CordovaWebView(543): Disabled addJavascriptInterface() bridge since Android version is old. 10-31 13:02:13.285: D/CordovaWebView(543): >>> loadUrl(file:///android_asset/www/menu.html) 10-31 13:02:13.285: D/PluginManager(543): init() 10-31 13:02:13.296: D/CordovaWebView(543): >>> loadUrlNow() 10-31 13:02:13.296: D/CordovaWebView(543): >>> loadUrl(file:///android_asset/www/main.html) 10-31 13:02:13.296: D/PluginManager(543): init() 10-31 13:02:13.315: D/CordovaWebView(543): >>> loadUrlNow() 10-31 13:02:13.955: D/dalvikvm(543): GC_FOR_MALLOC freed 1775 objects / 133528 bytes in 76ms 10-31 13:02:14.765: D/Cordova(543): onPageFinished(file:///android_asset/www/menu.html) 10-31 13:02:15.365: D/Cordova(543): onPageFinished(file:///android_asset/www/main.html) 10-31 13:02:15.685: I/Database(543): sqlite returned: error code = 14, msg = cannot open file at source line 25467 10-31 13:02:15.945: D/CordovaLog(543): Falling back on PROMPT mode since _cordovaNative is missing. 10-31 13:02:15.955: D/CordovaLog(543): file:///android_asset/www/scripts/cordova-2.2.0.js: Line 1032 : Falling back on PROMPT mode since _cordovaNative is missing. 10-31 13:02:15.955: I/Web Console(543): Falling back on PROMPT mode since _cordovaNative is missing. at file:///android_asset/www/scripts/cordova-2.2.0.js:1032 10-31 13:02:16.065: D/AndroidRuntime(543): Shutting down VM 10-31 13:02:16.065: W/dalvikvm(543): threadid=1: thread exiting with uncaught exception (group=0x4001d800) 10-31 13:02:16.075: E/AndroidRuntime(543): FATAL EXCEPTION: main 10-31 13:02:16.075: E/AndroidRuntime(543): java.lang.NullPointerException 10-31 13:02:16.075: E/AndroidRuntime(543): at org.apache.cordova.api.Plugin.execute(Plugin.java:74) 10-31 13:02:16.075: E/AndroidRuntime(543): at org.apache.cordova.api.CordovaPlugin.execute(CordovaPlugin.java:61) 10-31 13:02:16.075: E/AndroidRuntime(543): at org.apache.cordova.api.PluginManager.exec(PluginManager.java:224) 10-31 13:02:16.075: E/AndroidRuntime(543): at org.apache.cordova.ExposedJsApi.exec(ExposedJsApi.java:43) 10-31 13:02:16.075: E/AndroidRuntime(543): at org.apache.cordova.CordovaChromeClient.onJsPrompt(CordovaChromeClient.java:213) 10-31 13:02:16.075: E/AndroidRuntime(543): at android.webkit.CallbackProxy.handleMessage(CallbackProxy.java:566) 10-31 13:02:16.075: E/AndroidRuntime(543): at android.os.Handler.dispatchMessage(Handler.java:99) 10-31 13:02:16.075: E/AndroidRuntime(543): at android.os.Looper.loop(Looper.java:123) 10-31 13:02:16.075: E/AndroidRuntime(543): at android.app.ActivityThread.main(ActivityThread.java:4627) 10-31 13:02:16.075: E/AndroidRuntime(543): at java.lang.reflect.Method.invokeNative(Native Method) 10-31 13:02:16.075: E/AndroidRuntime(543): at java.lang.reflect.Method.invoke(Method.java:521) 10-31 13:02:16.075: E/AndroidRuntime(543): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868) 10-31 13:02:16.075: E/AndroidRuntime(543): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626) 10-31 13:02:16.075: E/AndroidRuntime(543): at dalvik.system.NativeStart.main(Native Method) 

Thanks in advance!

+4
source share
2 answers

There is a current solution to this problem, and you add a thread pool to your CordovaActivity:

 private final ExecutorService threadPool = Executors.newCachedThreadPool(); 

And, of course, implement the newly added getThreadPool () method. This was added by accident, and hopefully will be encapsulated in a future release somehow.

 public ExecutorService getThreadPool() { return threadPool; } 
+7
source

I had this problem, but after following the steps described in the Cordoba Android Update docs, this error went away.

-1
source

Source: https://habr.com/ru/post/1443642/


All Articles