csZBar icon indicating copy to clipboard operation
csZBar copied to clipboard

Crash with Android 6 Marshmallow?

Open ilvalerione opened this issue 8 years ago • 24 comments

I installed my app on a Nexus 5x with Android 6.0.1 but when i call this plugin to open scanner the app go shoutdown.

Someone knows this problem?

ilvalerione avatar Feb 25 '16 16:02 ilvalerione

I found the same thing on an Nexus 5x with Android 6.0.1, and it seems to be because it needs a 64 bit version of zbar.

I've followed the steps suggested in the top answer here: http://stackoverflow.com/questions/32426861/zbar-android-arm-64-couldnt-find-libiconv-so and it doesn't give the same error any more, but it's now giving a different one. Still trying to resolve...

uniphonic avatar Feb 26 '16 03:02 uniphonic

@uniphonic what is the new error?

dcousens avatar Feb 26 '16 04:02 dcousens

I'm sorry for imprecision, my phone is also Nexus 5x with Android 6.0.1. I changed my first message.

ilvalerione avatar Feb 26 '16 10:02 ilvalerione

@dcousens We found the problem was a permissions issue, after we had added the 64 bit versions of the libraries, as mentioned. The problem is that for Android 6.0 devices do not automatically accept sensitive permissions at install time. Instead they are accepted at run-time. By default, sensitive (also known as dangerous) permissions, such as the camera, are not allowed, even if they are requested in the manifest file.

One fix for the permissions issue would be to request the permission in code manually during the runtime of the app in order to activate the scanner. This way would require a code change to the native Java code within the ZBarcodeScanner class. However, this new permissions rule only applies when the app is target at an targetSdkVersion of 23, so setting the version lower would be another way to solve the permissions issue. Setting that target lower causes the app to behave as it used to, and will automatically allow the camera permission when the app is installed.

I will try to commit what we've got working, after we do some more testing with it. One thing we've noticed is that the camera image seems to be upside down on the Nexux 5x, but that doesn't seem to affect the scan, and it seems to show up that way on the some other scanning software, so it could be more of a hardware issue. Will have to do some more investigation.

[Update] Looks like the upside down image is partially a hardware issue: http://www.theverge.com/2015/11/9/9696774/google-nexus-5x-upside-down-camera More official response here: https://www.reddit.com/r/Android/comments/3rjbo8/nexus5x_marshmallow_camera_problem/

uniphonic avatar Feb 29 '16 14:02 uniphonic

Thanks for report! let us know when you fix the bug to update the apps.

ilvalerione avatar Feb 29 '16 15:02 ilvalerione

OK, i've got the fix committed to my fork: https://github.com/uniphonic/csZBar

  • Please note that the Upside down camera image is a separate issue, and we haven't fixed that as yet.
  • Please also note that my fork also has other changes merged with it including: https://github.com/tjwoon/csZBar/pull/39 and https://github.com/tjwoon/csZBar/pull/36 (merged in that order).

@dcousens I noticed you had some concerns with pull #39, and I'm guessing you might have the same concerns here, since additional .so files are being added, in addition to the ones from pull 39. If you have any ideas on how to alleviate your concerns, please let me know? The files added from commit 39 don't seem to be much difference in size from the previous version, and they still seem to work, so it didn't seem so likely that something could be wrong with them. For the .so files that I added, they are from the repository mentioned on the StackOverflow article mentioned above ( https://github.com/SkillCollege/ZBarAndroidSDK/tree/master/ZBarScanProjAll/libs ).

uniphonic avatar Feb 29 '16 19:02 uniphonic

I tested on Nexus 5 with Android 6.0.1 and it's working fine.

Thanks so much!

ilvalerione avatar Mar 07 '16 09:03 ilvalerione

@ilvalerione I also have the same issue right now. Can you please tell me what fork#commit you tried and verified working?

gnumbers avatar Mar 16 '16 09:03 gnumbers

uniphonic fixed this bug and committed new code in this new fork:

https://github.com/uniphonic/csZBar

ilvalerione avatar Mar 16 '16 09:03 ilvalerione

@ilvalerione Thanks for your prompt reply. I just tried it, and it gives me an error. Did you try his latest commit? My ionic code used to work/build well with tjwoon's original repo.

int permissionCheck = ContextCompat.checkSelfPermission(this.getBaseContext(), Manifest.permission.CAMERA); ^ symbol: method checkSelfPermission(Context,String) location: class ContextCompat .../platforms/android/src/org/cloudsky/cordovaPlugins/ZBarScannerActivity.java:102: error: cannot find symbol ActivityCompat.requestPermissions(this, ^ symbol: method requestPermissions(ZBarScannerActivity,String[],int) location: class ActivityCompat Note: Some input files use or override a deprecated API. Note: Recompile with -Xlint:deprecation for details.

gnumbers avatar Mar 16 '16 09:03 gnumbers

Are you using PhoneGap build service?

ilvalerione avatar Mar 16 '16 10:03 ilvalerione

No, I am just using ionic-cli ionic run android.

gnumbers avatar Mar 16 '16 11:03 gnumbers

my experience is on PhoneGap build service... i don't know for ionic cli

ilvalerione avatar Mar 16 '16 11:03 ilvalerione

Ah, got it. Thanks.

gnumbers avatar Mar 16 '16 11:03 gnumbers

@dcousens I noticed you had some concerns with pull #39, and I'm guessing you might have the same concerns here, since additional .so files are being added, in addition to the ones from pull 39.

I'll just need to go over the build process myself, and hopefully come up with the same deterministic hash. If you could put that process in a README.md file, then it'd be much easier for me to go over.

dcousens avatar Apr 13 '16 04:04 dcousens

@dcousens I didn't try compiling the .so files my self, I just got the one that I added from this repo: https://github.com/SkillCollege/ZBarAndroidSDK/tree/master/ZBarScanProjAll/libs , which was referenced in this stackoverflow article: http://stackoverflow.com/questions/32426861/zbar-android-arm-64-couldnt-find-libiconv-so

uniphonic avatar Apr 13 '16 21:04 uniphonic

I also have a crash on 6.0.1 with a Nexus 5...

The exact error from logcat is:

04-29 22:17:07.916   858  1737 I ActivityManager: START u0 {cmp=be.kwiker.app/org.cloudsky.cordovaPlugins.ZBarScannerActivity (has extras)} from uid 10174 on display 0
04-29 22:17:07.952 21209 21209 D AndroidRuntime: Shutting down VM
04-29 22:17:07.962 21209 21209 E AndroidRuntime: FATAL EXCEPTION: main
04-29 22:17:07.962 21209 21209 E AndroidRuntime: Process: be.kwiker.app, PID: 21209
04-29 22:17:07.962 21209 21209 E AndroidRuntime: java.lang.UnsatisfiedLinkError: dlopen failed: /data/app/be.kwiker.app-1/lib/arm/libiconv.so: has text relocations
04-29 22:17:07.962 21209 21209 E AndroidRuntime:    at java.lang.Runtime.loadLibrary(Runtime.java:372)
04-29 22:17:07.962 21209 21209 E AndroidRuntime:    at java.lang.System.loadLibrary(System.java:1076)
04-29 22:17:07.962 21209 21209 E AndroidRuntime:    at org.cloudsky.cordovaPlugins.ZBarScannerActivity.<clinit>(ZBarScannerActivity.java:77)
04-29 22:17:07.962 21209 21209 E AndroidRuntime:    at java.lang.Class.newInstance(Native Method)
04-29 22:17:07.962 21209 21209 E AndroidRuntime:    at android.app.Instrumentation.newActivity(Instrumentation.java:1067)
04-29 22:17:07.962 21209 21209 E AndroidRuntime:    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2317)
04-29 22:17:07.962 21209 21209 E AndroidRuntime:    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
04-29 22:17:07.962 21209 21209 E AndroidRuntime:    at android.app.ActivityThread.-wrap11(ActivityThread.java)
04-29 22:17:07.962 21209 21209 E AndroidRuntime:    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
04-29 22:17:07.962 21209 21209 E AndroidRuntime:    at android.os.Handler.dispatchMessage(Handler.java:102)
04-29 22:17:07.962 21209 21209 E AndroidRuntime:    at android.os.Looper.loop(Looper.java:148)
04-29 22:17:07.962 21209 21209 E AndroidRuntime:    at android.app.ActivityThread.main(ActivityThread.java:5417)
04-29 22:17:07.962 21209 21209 E AndroidRuntime:    at java.lang.reflect.Method.invoke(Native Method)
04-29 22:17:07.962 21209 21209 E AndroidRuntime:    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
04-29 22:17:07.962 21209 21209 E AndroidRuntime:    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
04-29 22:17:07.962 21209 21209 E AndroidRuntime:    at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:114)
04-29 22:17:07.964   858  1030 W ActivityManager:   Force finishing activity be.kwiker.app/org.cloudsky.cordovaPlugins.ZBarScannerActivity
04-29 22:17:07.967   858  1030 W ActivityManager:   Force finishing activity be.kwiker.app/.MainActivity

Looking at the libs folder arm is not present...

Gp2mv3 avatar Apr 29 '16 20:04 Gp2mv3

I will check this weekend but looking at the stack-trace that I sent, I doesn't seems to be linked to a permission.

Gp2mv3 avatar May 06 '16 09:05 Gp2mv3

@Gp2mv3 try disabling Bitcode in your compilation options.

dcousens avatar May 06 '16 09:05 dcousens

@dcousens This stack-trace is from Android. Bitcode is for iOS right ? I have no problem on iOS, even with Bitcode enabled.

Gp2mv3 avatar May 06 '16 09:05 Gp2mv3

True. ping @rubensayshi ?

dcousens avatar May 06 '16 09:05 dcousens

Hi, any news about the new release ? I have the same issue with some customers who upgrade to android 6

shiro-42 avatar Jul 01 '16 09:07 shiro-42

have problem with cam access in version 6. sometime it works, sometime not. i don't always see the cam permmmission dialog after delete cache, data & reinstalltion.ö

jayjupdhig avatar Apr 24 '20 15:04 jayjupdhig

have problem with cam access in version 6. sometime it works, sometime not. i don't always see the cam permmmission dialog after delete cache, data & reinstalltion.ö

Maybe there is a relation between that??

jayjupdhig avatar Apr 28 '20 07:04 jayjupdhig