Start a new topic

Bug when using PhoneGap and opening AR view multiple times

Bug when using PhoneGap and opening AR view multiple times

I am noticing a bug in the Android version of the WIkitude PhoneGap plugin.

The app crashes consistently after the following steps:

load the app

click JS button in PhoneGap view to load the AR view

click JS button to close the AR view and return to PhoneGap view

pause and resume the app

click JS button to load the AR view again - the app loading animation shows, but then the camera freezes and the app crashes

If you pause and resume the app while the AR view is open, the AR view continues to work but if you close it and try to re-load it then the same thing occurs.

The crash log that it gives is:

11-14 14:51:45.992: D/AndroidRuntime(10959): Shutting down VM

11-14 14:51:45.992: W/dalvikvm(10959): threadid=1: thread exiting with uncaught exception (group=0x40a9fa08)

11-14 14:51:45.992: E/AndroidRuntime(10959): FATAL EXCEPTION: main

11-14 14:51:45.992: E/AndroidRuntime(10959): java.lang.IllegalStateException: onResume() needs to be called before this method is called in the appropriate lifecycle method

11-14 14:51:45.992: E/AndroidRuntime(10959): at com.wikitude.architect.ArchitectView.onPause(Unknown Source)

11-14 14:51:45.992: E/AndroidRuntime(10959): at com.wikitude.phonegap.WikitudePlugin.removeArchitectView(

11-14 14:51:45.992: E/AndroidRuntime(10959): at com.wikitude.phonegap.WikitudePlugin.access$1(

11-14 14:51:45.992: E/AndroidRuntime(10959): at com.wikitude.phonegap.WikitudePlugin$

11-14 14:51:45.992: E/AndroidRuntime(10959): at android.os.Handler.handleCallback(

11-14 14:51:45.992: E/AndroidRuntime(10959): at android.os.Handler.dispatchMessage(

11-14 14:51:45.992: E/AndroidRuntime(10959): at android.os.Looper.loop(

11-14 14:51:45.992: E/AndroidRuntime(10959): at

11-14 14:51:45.992: E/AndroidRuntime(10959): at java.lang.reflect.Method.invokeNative(Native Method)

11-14 14:51:45.992: E/AndroidRuntime(10959): at java.lang.reflect.Method.invoke(

11-14 14:51:45.992: E/AndroidRuntime(10959): at$

11-14 14:51:45.992: E/AndroidRuntime(10959): at

11-14 14:51:45.992: E/AndroidRuntime(10959): at dalvik.system.NativeStart.main(Native Method)


Am I missing something out in my code, or is this a bug in the plugin? Any tips greatly appreciated.





Hi Dan!

This is in fact  not expected behavior.
Which phonegap version are you using? Current one is optimized for 2.0 but we'll publish an update for 2.2+ very soon.
Could you please try the Basic-Sample project and check if same error occurs there as well since we cannot reproduce the issue.


Hi Andi,

I'm using Phonegap 2.0.0 and Wikitude SDK 1.1 in my app.

I've tried with the Basic sample project from the Phonegap Github repo, and I can replicate the same thing by making the following changes to mirror roughly what I'm trying to do...

update index.html to include:

<a href="javascript:app.launchWikitude();">Launch Wikitude</a>

update main.js to add the commands from onDeviceIsReadyCallback (and comment out the commands in onDeviceIsReadyCallback):

    launchWikitude: function() 




        WikitudePlugin.callJavaScript("didReceivedNewTextForLabel('Hello World')");     



and update onClickInARchitectWorld to inlcude the following command so the plugin closes when the label is clicked:




You should then be able to click the link in the Phonegap page to load up Wikitude and click the label to close it. This works fine, even multiple times, but stops working after you've clicked the home button while looking at the Phonegap page and then come back into the app. If you click the home button while you're in the Wikitude view and then come back in, the Wikitude view resumes fine, but won't load again if you click the label to close the view and then try clicking the link.


Hopefully that makes sense, and helps you replicate the issue?




Hi Dan!

Your line

will register a function that is called each time you use something like


document.location = "architectsdk://YOURHOST?YOURPARAM=YOURVALUE";

in your World's code.

Please aso have a look at the error-console, implement the error callbacks and ensure the close() function is really called, since we do not support more than one active architectView being open at any time.

Hope that helps.

Kind regards,

Login or Signup to post a comment