Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Errors upgrading cordova app

I'm trying to update a phonegap Android app from cordova 3.5.0 to cordova 5.1.1 because of security concerns. When I launch the app I get the following errors but I just can't understand where they come from.. Could you help me by suggesting where to investigate?

W/System.err( 1672): org.json.JSONException: Value PluginManager at 0 of type java.lang.String cannot be converted to int
W/System.err( 1672):    at org.json.JSON.typeMismatch(JSON.java:100)
W/System.err( 1672):    at org.json.JSONArray.getInt(JSONArray.java:357)
W/System.err( 1672):    at org.apache.cordova.CordovaBridge.promptOnJsPrompt(CordovaBridge.java:131)
W/System.err( 1672):    at org.apache.cordova.engine.SystemWebChromeClient.onJsPrompt(SystemWebChromeClient.java:119)
W/System.err( 1672):    at android.webkit.CallbackProxy.handleMessage(CallbackProxy.java:655)
W/System.err( 1672):    at android.os.Handler.dispatchMessage(Handler.java:99)
W/System.err( 1672):    at android.os.Looper.loop(Looper.java:137)
W/System.err( 1672):    at android.app.ActivityThread.main(ActivityThread.java:4745)
W/System.err( 1672):    at java.lang.reflect.Method.invokeNative(Native Method)
W/System.err( 1672):    at java.lang.reflect.Method.invoke(Method.java:511)
W/System.err( 1672):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
W/System.err( 1672):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
W/System.err( 1672):    at dalvik.system.NativeStart.main(Native Method)
W/System.err( 1672): org.json.JSONException: Value App at 0 of type java.lang.String cannot be converted to int
W/System.err( 1672):    at org.json.JSON.typeMismatch(JSON.java:100)
W/System.err( 1672):    at org.json.JSONArray.getInt(JSONArray.java:357)
W/System.err( 1672):    at org.apache.cordova.CordovaBridge.promptOnJsPrompt(CordovaBridge.java:131)
W/System.err( 1672):    at org.apache.cordova.engine.SystemWebChromeClient.onJsPrompt(SystemWebChromeClient.java:119)
W/System.err( 1672):    at android.webkit.CallbackProxy.handleMessage(CallbackProxy.java:655)
W/System.err( 1672):    at android.os.Handler.dispatchMessage(Handler.java:99)
W/System.err( 1672):    at android.os.Looper.loop(Looper.java:137)
W/System.err( 1672):    at android.app.ActivityThread.main(ActivityThread.java:4745)
W/System.err( 1672):    at java.lang.reflect.Method.invokeNative(Native Method)
W/System.err( 1672):    at java.lang.reflect.Method.invoke(Method.java:511)
W/System.err( 1672):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
W/System.err( 1672):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
W/System.err( 1672):    at dalvik.system.NativeStart.main(Native Method)
W/System.err( 1672): org.json.JSONException: Value File at 0 of type java.lang.String cannot be converted to int
W/System.err( 1672):    at org.json.JSON.typeMismatch(JSON.java:100)
W/System.err( 1672):    at org.json.JSONArray.getInt(JSONArray.java:357)
W/System.err( 1672):    at org.apache.cordova.CordovaBridge.promptOnJsPrompt(CordovaBridge.java:131)
W/System.err( 1672):    at org.apache.cordova.engine.SystemWebChromeClient.onJsPrompt(SystemWebChromeClient.java:119)
W/System.err( 1672):    at android.webkit.CallbackProxy.handleMessage(CallbackProxy.java:655)
W/System.err( 1672):    at android.os.Handler.dispatchMessage(Handler.java:99)
W/System.err( 1672):    at android.os.Looper.loop(Looper.java:137)
W/System.err( 1672):    at android.app.ActivityThread.main(ActivityThread.java:4745)
W/System.err( 1672):    at java.lang.reflect.Method.invokeNative(Native Method)
W/System.err( 1672):    at java.lang.reflect.Method.invoke(Method.java:511)
W/System.err( 1672):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
W/System.err( 1672):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
W/System.err( 1672):    at dalvik.system.NativeStart.main(Native Method)
like image 994
Surfer on the fall Avatar asked Jul 02 '15 09:07

Surfer on the fall


People also ask

Is Cordova outdated 2021?

And nowadays, according to Statista, Cordova's popularity is decreasing. The number of software developers who used Apache Cordova in 2019–2021 fell from 29% to 16%.

Is Cordova discontinued?

Effective immediately, App Center will no longer offer the option to create Apache Cordova apps through the portal, CLI or API. Starting April 1, 2022, the App Center service will no longer accept calls from the Cordova SDK.


3 Answers

To update a cordova project you have to do this:

First update the CLI version with

npm update -g cordova

then go to your project folder and do

cordova platform update android
like image 81
jcesarmobile Avatar answered Oct 02 '22 12:10

jcesarmobile


Edit: I haden't gone through all the coments of the other answer and I now realize this answer may not be really usefull to the OP, but anyway it may help someone fighting with Cordova 3.x->5 migration...

When you update cordova you often have to also update the platform and the plugins.

So after you upgraded the CLI like you did, you have to remove all platforms and plugins then re-install it.

(if you have content that is only in the platform think to save it before)

Before we start, save the list of the plugins you use

cordova plugin list

Then we clean everything (windows command prompt):

rd /s/q platforms
rd /s /q plugins

or for linux/OS X :

rm -rf platforms
rm -rf plugins

please note that it is a kind of "brute" way to remove platforms and plugins, you could just run cordova platform remove android but then you would have to deal with the file platforms.json and you could use cordova plugin remove ... for each plugin but it would be longer.

Then you use cordova plugin add ... to re-add all your plugins.

Be carefull, the core plugins in cordova 5 are now using npm instead of git, so for each plugin you have to check the new id or you may get the old versions.

For ex, use

cordova plugin add cordova-plugin-camera

instead of

cordova plugin add org.apache.cordova.camera

And finally you have to add the new plugin responsible for the security

cordova plugin add cordova-plugin-whitelist

And configure it in config.xml and add a CSP meta tag in your html.

And re-add the platform :

cordova plugin add android
like image 38
QuickFix Avatar answered Oct 02 '22 11:10

QuickFix


Seems like you had 'partially upgraded' you project. I would recommend to start with a fresh 5.11 Cordova project and build it the same you did with the original 3.5.0 project.

Try to automate (as in script) the process of building your project such that you can always start with a fresh Cordova project and auto build it to become your full blown app.

I have used that option in the past to overcome some unexplained issues - all due to upgrades not being as smooth as they should be.

like image 24
davidhadas Avatar answered Oct 02 '22 11:10

davidhadas