Closed nicolomonili closed 6 years ago
check this example https://github.com/appcelerator-modules/ti.barcode/issues/59#issuecomment-403747604 You only need the normal Android camera permissions, like you would use to display and use the normal camera in Titanium. So you can check the official documentation too.
If you check your app permission on your phone it should allow storage and camera in order to work. Do you have any error message in the log?
This is the actual permissions of the app
Unfortunately there is no log on the console
check adb logcat
there should be a lot of output and stop it right after the crash to see if you can spot something. That would help alot. Permissions should be fine.
--------- beginning of main
07-20 06:21:09.511 7355 7377 E Surface : getSlotFromBufferLocked: unknown buffer: 0xdedd3540
07-20 06:21:26.794 7355 7369 D BarcodeModule: (KrollRuntimeThread) [19391,19391] QR_CODE
--------- beginning of system
07-20 06:21:26.800 598 841 I ActivityManager: START u0 {act=com.google.zxing.client.android.SCAN flg=0x10000 pkg=com.-.- cmp=com.-.-/com.google.zxing.client.android.CaptureActivity (has extras)} from uid 10084 on display 0
07-20 06:21:26.821 598 1070 D Sensors : batch handle 1, but there is no batch sensor in genymotion
07-20 06:21:26.862 7355 7355 D AndroidRuntime: Shutting down VM
--------- beginning of crash
07-20 06:21:26.863 7355 7355 E AndroidRuntime: FATAL EXCEPTION: main
07-20 06:21:26.863 7355 7355 E AndroidRuntime: Process: com.-.-, PID: 7355
07-20 06:21:26.863 7355 7355 E AndroidRuntime: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.-.-/com.google.zxing.client.android.CaptureActivity}: java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.
07-20 06:21:26.863 7355 7355 E AndroidRuntime: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)
07-20 06:21:26.863 7355 7355 E AndroidRuntime: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
07-20 06:21:26.863 7355 7355 E AndroidRuntime: at android.app.ActivityThread.-wrap11(ActivityThread.java)
07-20 06:21:26.863 7355 7355 E AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
07-20 06:21:26.863 7355 7355 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:102)
07-20 06:21:26.863 7355 7355 E AndroidRuntime: at android.os.Looper.loop(Looper.java:148)
07-20 06:21:26.863 7355 7355 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:5417)
07-20 06:21:26.863 7355 7355 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
07-20 06:21:26.863 7355 7355 E AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
07-20 06:21:26.863 7355 7355 E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
07-20 06:21:26.863 7355 7355 E AndroidRuntime: Caused by: java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.
07-20 06:21:26.863 7355 7355 E AndroidRuntime: at android.view.ViewGroup.addViewInner(ViewGroup.java:4309)
07-20 06:21:26.863 7355 7355 E AndroidRuntime: at android.view.ViewGroup.addView(ViewGroup.java:4145)
07-20 06:21:26.863 7355 7355 E AndroidRuntime: at android.view.ViewGroup.addView(ViewGroup.java:4086)
07-20 06:21:26.863 7355 7355 E AndroidRuntime: at android.view.ViewGroup.addView(ViewGroup.java:4059)
07-20 06:21:26.863 7355 7355 E AndroidRuntime: at com.google.zxing.client.android.CaptureActivity.onCreate(CaptureActivity.java:179)
07-20 06:21:26.863 7355 7355 E AndroidRuntime: at android.app.Activity.performCreate(Activity.java:6237)
07-20 06:21:26.863 7355 7355 E AndroidRuntime: at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
07-20 06:21:26.863 7355 7355 E AndroidRuntime: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
07-20 06:21:26.863 7355 7355 E AndroidRuntime: ... 9 more
07-20 06:21:26.863 598 1070 W ActivityManager: Force finishing activity com.-.-/com.google.zxing.client.android.CaptureActivity
07-20 06:21:26.868 598 1070 W ActivityManager: Force finishing activity com.-.-/org.appcelerator.titanium.TiActivity
07-20 06:21:26.934 598 1859 I OpenGLRenderer: Initialized EGL, version 1.4
07-20 06:21:26.961 598 1859 W EGL_emulation: eglSurfaceAttrib not implemented
07-20 06:21:26.961 598 1859 W OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0xdb45f160, error=EGL_SUCCESS
07-20 06:21:27.369 598 612 W ActivityManager: Activity pause timeout for ActivityRecord{5c57a28 u0 com.-.-/com.google.zxing.client.android.CaptureActivity t266 f}
07-20 06:21:36.819 598 612 W ActivityManager: Launch timeout has expired, giving up wake lock!
07-20 06:21:36.880 598 612 W ActivityManager: Activity destroy timeout for ActivityRecord{7642755 u0 com.-.-/org.appcelerator.titanium.TiActivity t266 f}
07-20 06:21:46.834 598 612 W ActivityManager: Activity destroy timeout for ActivityRecord{5c57a28 u0 com.-.-/com.google.zxing.client.android.CaptureActivity t266 f}
is this on device or emulator (I see genymotion in the log)? But interesting error, I'll check that later
Emulator, Genymotion yes
I tried to remove only the Barcode.capture from my code
Barcode.capture({
animate: true,
overlay: overlayQrcode,
showCancel: false,
showRectangle: false,
keepOpen: true,
//acceptedFormats: [
// Barcode.FORMAT_QR_CODE
//]
});
and i replaced it with the code to open the camera
Ti.Media.showCamera({
success: function(e) {
//callback(null, e);
},
cancel: function(e) {
//callback(e, null);
},
error: function(e) {
//callback(e, null);
},
saveToPhotoGallery: true,
// save our media to the gallery
mediaTypes: [Ti.Media.MEDIA_TYPE_PHOTO]
});
the app don't crash, and camera opens correctly
Something is wrong with your overlay:
Unable to start activity ComponentInfo{com.-.-/com.google.zxing.client.android.CaptureActivity}: java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.
Please refer to general help via Slack or StackOverflow. This issue tracker is focussed on module bugs, which this one isn't.
Incredible ... I found what caused the crash ... it's the property borderColor of the view overlayQrcode...
On iOS the property borderColor is not a problem, on Android cause the crash
On iOS i have no problem, i only ask the permission for the camera
But now on Android i think i have some problems with the permission... For Android i use the same code above, plus this on the tiapp.xml
On Android , when i have to open the camera, two permission requests are displayed
After the permissions are accepted, the function
openQrcode()
is called, and the app crashes.