I've created an Android library project with a custom Fragment implementing the Wikitude SDK. I've added the library to an Android application Project which is working fine. Everything works fine and the Wikitude startup screen appears, but when this.architectView.onCreate(architectConfig); gets called. The system throws an exception:
04-01 13:03:25.242: D/ArchitectView(7748): Exception while getting Camera Parameters
04-01 13:03:25.242: D/ArchitectView(7748): java.lang.RuntimeException: Fail to connect to camera service
04-01 13:03:25.242: D/ArchitectView(7748): at android.hardware.Camera.native_setup(Native Method)
04-01 13:03:25.242: D/ArchitectView(7748): at android.hardware.Camera.<init>(Camera.java:343)
04-01 13:03:25.242: D/ArchitectView(7748): at android.hardware.Camera.open(Camera.java:318)
04-01 13:03:25.242: D/ArchitectView(7748): at com.wikitude.architect.ArchitectView.a(Unknown Source)
04-01 13:03:25.242: D/ArchitectView(7748): at com.wikitude.architect.ArchitectView.<init>(Unknown Source)
04-01 13:03:25.242: D/ArchitectView(7748): at java.lang.reflect.Constructor.constructNative(Native Method)
04-01 13:03:25.242: D/ArchitectView(7748): at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
04-01 13:03:25.242: D/ArchitectView(7748): at android.view.LayoutInflater.createView(LayoutInflater.java:594)
04-01 13:03:25.242: D/ArchitectView(7748): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696)
04-01 13:03:25.242: D/ArchitectView(7748): at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
04-01 13:03:25.242: D/ArchitectView(7748): at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
04-01 13:03:25.242: D/ArchitectView(7748): at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
04-01 13:03:25.242: D/ArchitectView(7748): at com.infosupport.isca_ar.ARFragment.onCreateView(ARFragment.java:31)
04-01 13:03:25.242: D/ArchitectView(7748): at android.app.Fragment.performCreateView(Fragment.java:1695)
04-01 13:03:25.242: D/ArchitectView(7748): at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:861)
04-01 13:03:25.242: D/ArchitectView(7748): at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1035)
04-01 13:03:25.242: D/ArchitectView(7748): at android.app.FragmentManagerImpl.addFragment(FragmentManager.java:1137)
04-01 13:03:25.242: D/ArchitectView(7748): at android.app.Activity.onCreateView(Activity.java:4746)
04-01 13:03:25.242: D/ArchitectView(7748): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:689)
04-01 13:03:25.242: D/ArchitectView(7748): at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
04-01 13:03:25.242: D/ArchitectView(7748): at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
04-01 13:03:25.242: D/ArchitectView(7748): at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
04-01 13:03:25.242: D/ArchitectView(7748): at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
04-01 13:03:25.242: D/ArchitectView(7748): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:267)
04-01 13:03:25.242: D/ArchitectView(7748): at android.app.Activity.setContentView(Activity.java:1895)
04-01 13:03:25.242: D/ArchitectView(7748): at com.infosupport.isca_ar_test.MainFragment.onCreate(MainFragment.java:12)
04-01 13:03:25.242: D/ArchitectView(7748): at android.app.Activity.performCreate(Activity.java:5133)
04-01 13:03:25.242: D/ArchitectView(7748): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
04-01 13:03:25.242: D/ArchitectView(7748): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2175)
04-01 13:03:25.242: D/ArchitectView(7748): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
04-01 13:03:25.242: D/ArchitectView(7748): at android.app.ActivityThread.access$600(ActivityThread.java:141)
04-01 13:03:25.242: D/ArchitectView(7748): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
04-01 13:03:25.242: D/ArchitectView(7748): at android.os.Handler.dispatchMessage(Handler.java:99)
04-01 13:03:25.242: D/ArchitectView(7748): at android.os.Looper.loop(Looper.java:137)
04-01 13:03:25.242: D/ArchitectView(7748): at android.app.ActivityThread.main(ActivityThread.java:5103)
04-01 13:03:25.242: D/ArchitectView(7748): at java.lang.reflect.Method.invokeNative(Native Method)
04-01 13:03:25.242: D/ArchitectView(7748): at java.lang.reflect.Method.invoke(Method.java:525)
04-01 13:03:25.242: D/ArchitectView(7748): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
04-01 13:03:25.242: D/ArchitectView(7748): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
04-01 13:03:25.242: D/ArchitectView(7748): at dalvik.system.NativeStart.main(Native Method)
I've added permissions and features to both Manifest files:
Did you manage to reproduce the problem? I can e-mail you the Eclipse projects if that's easier for you.
B
Bastiaan
said
over 9 years ago
I solved the problem, but still don't know what the problem really was. I did exactly the same coding, but this time on a Windows computer instead of a Mac.
G
Gabriele Boccone
said
over 9 years ago
Good to know.
I tried your permission with the sample app, and everything was Ok.
I would suggest that you upgrade to the new SDK version anyway (3.3), which will be released very soon.
T
Thibaud RENAUX
said
about 8 years ago
Hi,
I'm facing the same problem right now with som Marshmallow devices or randomly, but it's not my purpose to genrate an app running randomly!
Here's my code for the onCreate() in MainActivity called from CustomMainActivity wich extends MainActivity
final StartupConfiguration configuration = new StartupConfiguration(wikitudeAPIKey); this.architectView.onCreate(configuration);
And the wirdest thing is that i run the app just after boot so no other app use the camera !
Any idea?
Thanks for helping
S
Simon 248601
said
about 8 years ago
Hi Thibaud,
could you please elaborate a little further on what devices you have this problem? Does it only happen on Marshmallow or lower OS versions too?
Best regards, Simon
T
Thibaud RENAUX
said
about 8 years ago
Hi Simon,
I'm working on a Moto X with Lollipop where it's works fine and on two others : Nexus 5 and Nexus 9 both running Marshmallow.
The wird thing is that a version of my app worked fine on the nexus 5 and the problem appeared when I uninstall the app and installed it again. But on the nexus 9 never worked.
the error thar occurs on the Activity's onCreate() method with the architectView.oncreate(configuration); so I tried to run it on a try catch as :
Since Marshmallow ( Android 6.0 API 23) the OS let user choose which permission for the app.
To proper use Wikitude we need to access Camera, so if user forbid acces to the camera we can't get Camera service it's linked.
So when I uninstall/reinstall the app Android suppress all permissions including Camera!
I will find a way to search if app camera parameter is allowed by user and if not ask him to activate it, but I think for the next SDK of Wikitude I guess i could be great to add these feature to the managment of architectView as in isDeviceSupported() method cause for the moment this method include just the fact that a camera hardware is present.
If i found the way to ask user to activate permission on start I will publish it ;)
S
Simon 248601
said
about 8 years ago
Hi Thibaud,
you beat me to it. I was just about to write you about that too. For a quick fix you can switch your compile and target sdk version to 22 or lower.
I will investigate this further and look for a convenient way to integrate it into the SDK/Example Application.
Don't be sorry, It's normal from Android to add this feature for actual and future versions, it's normal too to let user choose his permission.
Now we know and we can go with it.
I stayed with 23 and did a job as I said that's work , I forbid acces to ArchitectActivity if user is 23 or above and hasn't got his camera permission OK
Thanks for helping
S
Simon 248601
said
about 8 years ago
Hi Thibaud,
I'm glad you found a solution so quickly. Thank you for pointing out this issue.
Bastiaan
1 person has this problem