Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash with Android 6 Marshmallow? #50

Open
ilvalerione opened this issue Feb 25, 2016 · 24 comments
Open

Crash with Android 6 Marshmallow? #50

ilvalerione opened this issue Feb 25, 2016 · 24 comments
Labels

Comments

@ilvalerione
Copy link

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?

@uniphonic
Copy link
Contributor

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...

@dcousens
Copy link
Contributor

@uniphonic what is the new error?

@ilvalerione ilvalerione changed the title Crash with Android 6? Crash with Android 6 Marshmallow? Feb 26, 2016
@ilvalerione
Copy link
Author

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

@uniphonic
Copy link
Contributor

@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/

@ilvalerione
Copy link
Author

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

uniphonic pushed a commit to uniphonic/csZBar that referenced this issue Feb 29, 2016
@uniphonic
Copy link
Contributor

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

@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 ).

@ilvalerione
Copy link
Author

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

Thanks so much!

@gnumbers
Copy link

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

@ilvalerione
Copy link
Author

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

https://github.com/uniphonic/csZBar

@gnumbers
Copy link

@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.

@ilvalerione
Copy link
Author

Are you using PhoneGap build service?

@gnumbers
Copy link

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

@ilvalerione
Copy link
Author

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

@gnumbers
Copy link

Ah, got it. Thanks.

@dcousens
Copy link
Contributor

@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.

@uniphonic
Copy link
Contributor

@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

dcousens pushed a commit that referenced this issue Apr 21, 2016
dcousens pushed a commit that referenced this issue Apr 21, 2016
dcousens pushed a commit that referenced this issue Apr 22, 2016
@Gp2mv3
Copy link

Gp2mv3 commented Apr 29, 2016

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
Copy link

Gp2mv3 commented May 6, 2016

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

@dcousens
Copy link
Contributor

dcousens commented May 6, 2016

@Gp2mv3 try disabling Bitcode in your compilation options.

@Gp2mv3
Copy link

Gp2mv3 commented May 6, 2016

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

@dcousens
Copy link
Contributor

dcousens commented May 6, 2016

True. ping @rubensayshi ?

@tjwoon tjwoon mentioned this issue May 19, 2016
uniphonic pushed a commit to itraycer/csZBar that referenced this issue May 20, 2016
* uniphonic_csZbar_master:
  Version updated
  adding support lib to plugin.xml
  Wrapping some code in try catches, so they don't fail on older devices. Samsung Tab 4 was crashing because it didn't have a flash or autofocus.
  Increasing the autoFocusInterval, so that it allows slower devices such as the Galaxy S3, to finish focusing before it tries to refocus. Before this change it was appearing as if the autofocus wasn't working at all, because it kept resetting the focus before it got a chance to focus.
  - fixing orientation of camera viewport for Android Nexus 5x devices
  Adding files for Android 6 Marshmallow compatibility and 64 bit devices, such as the Nexus 5x. Fixes issue # 50 tjwoon#50
  Added button bar for iOS
  Camera Flash icon added
  Icon Updated
  Android barcode layout changes
  Status bar hided  in camera view
  Fix to main application android manifest file
  Update README.md
  Removed button black background
  Change on flash button style, icon and position
  UI adaptation on orientation
  Button to activate flash
  README: remove quirk, now fixed
  Resolve alternating flash during autofocus
@shiro-42
Copy link

shiro-42 commented Jul 1, 2016

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

@jayjupdhig
Copy link

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
Copy link

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??

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants