Start a new topic

Fails to connect to camera after upgrade

Fails to connect to camera after upgrade


Hi, our users reported that no POIs could be selected on Android 5.0 Lollipop so I've just upgraded our Wikitude android app to Wikitude version 4.0.3. I pasted in the Wikitude jar file, ade.js and changed the target API to 19. Now whenever I try to start to AR activity, I get the attached error. No other code in the app has changed. Android SDK was updated to the newest version about a week ago. Should I have updated anything else?

Hi,

which device are you using for testing? Is there another app running on the phone, which still actively uses the camera?

Hi Philipp, thanks for your reply. It's a Samsung Galaxy S3 with Android 4.3. It's a clean phone with only the default apps plus the one I'm testing. I have ensured that nothing else is open and it does the same thing when the app is the first thing I open after restarting the phone.

Hi,

I'm little bit confused. So the error you are reporting has nothing to do with Android 5.0 - this was just the starting point for you, wasn't it? Did you follow the migration guide form 3.3 to 4.0? Which SDK version did you use before you added 4.0.3? Are you using PhoneGap or any other framework? We do have tested the 4.0.3 release on a SIII with 4.3, so I'm looking for additional hints to the problem.

Hi Philipp,

No, the error isn't associated with Android 5.0 - I just mentioned that as the reason we had to upgrade. The error seems to be associated with the Wikitude 4.0.3 upgrade.

The last version that I was using was 3.3. The instructions I followed were these (from the Android documentation):

MIGRATE FROM 3.3 TO 4.0


Make sure to set the required permissions for your application when using the new AR.context.hardware.flashlight API.

Starting with Wikitude SDK 4.0 a valid license key is mandatory for starting the SDK. An empty license key will block the SDK. A free trial key can be generated on the license page (free account required).

The Wikitude SDK 4.0 introduces a new file format for target collections (wtc). In order to unleash the full power of the new Wikitude SDK 4.0 read this section and re-generate your targets.


To address these points in turn:

- We aren't using the flashlight feature at all so I don't believe I need to add this permission

- We have a valid SDK Lite license key which worked prior to the upgrade

- The app is POI-based so I don't think that the last point is relevant to us.

 

To to the upgrade, my procedure was:

- Download the new version

- Copy wikitude.jar over the previous version

- Copy ade.js over the previous version

- Update target API version to 19 (I hadn't done this during the last upgrade so I did it now)

 

That's a full list of what I did between when it worked and when it stopped working. I don't know whether I should have done anything else! Perhaps you can advise.

We are not using PhoneGap or any other frameworks.

I've just had an opportunity to test it on a Galaxy Nexus (also Android 4.3) and that failed with the same exception.

Looking at your stack trace, I can't find any reference to classes of our SDK, it looks like you are trying to open the camera directly inside your application, and that doesn't work because the camera is already in use (maybe by an instance of the ArchitectView that's already running?)

If you want to use the camera in your application, you should call the onDestroy() method on any ArchitectView object first.

Have you already tried debugging your application inside the Eclipse IDE? Can you check which threads are running when the exception occurs?

Hi Gabriele,

Thank you for your response. The exception comes right at the very start of when it's loading the AR View and the camera shouldn't be invoked for any other purpose. The app hasn't really done anything at that point apart from go through a simple splash screen (which doesn't use the camera at all). The attached image shows the threads at the step where the exception comes up.

It's worth noting that all of this worked in version 3.3 a couple of days ago. The app isn't in active development at the moment from our point of view and nothing has been changed apart from this Wikitude upgrade, so I don't see how it could be a fundamental problem of the app like that.

The ArchitectView is already running when the exception occurs.

According to the stack trace in your first message, the Exception is thrown when your class ARActivity tries to open the camera (ARActivity.java, line 112).

In Version 4.0 of our SDK, we changed the initialization procedure, and we open the camera immediately when the ArchitectView is initialized, to improve the overall performance. You should not call Camera.open() after ArchitectView.onCreate(), if you need any information about the camera, you can open (and then close) it before initializing the ArchitectView.

Any other operation on the camera when the ArchitectView is active is actually "undefined behaviour" and was not supposed to work even in previous SDK versions.

Ok, that was the key piece of information that was missing! I'm surprised that a fundamental change like that wasn't in the upgrade docs. It works fine now though, thank you for your help!
Login or Signup to post a comment