bcko / flutter_qrcode_reader

Flutter qrcode reader
MIT License
233 stars 92 forks source link

Failed to create MD5 hash #1

Closed cstsortan closed 7 years ago

cstsortan commented 7 years ago

It is possible that I am screwing things up, but I am getting this error:

 FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':qrcode_reader:compileReleaseJavaWithJavac'.
> Failed to create MD5 hash for file 'C:\Users\tsort\AppData\Roaming\Pub\Cache\hosted\pub.dartlang.org\qrcode_reader-0.1.1\android\tmplibs\flutter.jar'.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
Finished with error: Gradle build failed: 1

Good luck developing the plugin!

villela commented 7 years ago

Hello cstsortan, thanks for the interest on the plugin.

I had a flutter.jar imported in the gradle file just as a stub so i could develop the Android part in the Android Studio and forgot to remove it. I just made a commit that commented the stub import in android gradle, it should be working now. Could you do a pull and check again please?

cstsortan commented 7 years ago

Indeed after removing provided files('tmplibs/flutter.jar') it compiles but now raises a java.lang.RuntimeException: Fail to connect to camera service although I'm just using the example code

villela commented 7 years ago

I'm not saying it is the case but that happens when we don't have the camera permission in the manifest or we are in the new permission system (targetSdk > 23). I double checked the manifests and the apk (aapt list -a app-debug.apk) and both permissions and target are ok. Nothing made with flutter is running on my emulator, probably some network stuff, and my phone is on 5.1 so I can't test if it is the new permission stuff, can you post the full stacktrace of the crash?

theobouwman commented 7 years ago

I am having the same issue when adding this plugin and running it for the first time. You should clarify the installation process.

D/com.dlazaro66.qrcodereaderview.QRCodeReaderView(12524): surfaceCreated
I/com.google.zxing.client.android.camera.open.OpenCameraInterface(12524): Opening camera #0
W/CameraBase(12524): An error occurred while connecting to camera 0: Service not available
D/AndroidRuntime(12524): Shutting down VM
E/AndroidRuntime(12524): FATAL EXCEPTION: main
E/AndroidRuntime(12524): Process: com.yourcompany.qrcodeapp, PID: 12524
E/AndroidRuntime(12524): java.lang.RuntimeException: Fail to connect to camera service
E/AndroidRuntime(12524):    at android.hardware.Camera.<init>(Camera.java:496)
E/AndroidRuntime(12524):    at android.hardware.Camera.open(Camera.java:345)
E/AndroidRuntime(12524):    at com.google.zxing.client.android.camera.open.OpenCameraInterface.open(OpenCameraInterface.java:76)
E/AndroidRuntime(12524):    at com.google.zxing.client.android.camera.CameraManager.openDriver(CameraManager.java:104)
E/AndroidRuntime(12524):    at com.dlazaro66.qrcodereaderview.QRCodeReaderView.surfaceCreated(QRCodeReaderView.java:213)
E/AndroidRuntime(12524):    at android.view.SurfaceView.updateWindow(SurfaceView.java:618)
E/AndroidRuntime(12524):    at android.view.SurfaceView$3.onPreDraw(SurfaceView.java:161)
E/AndroidRuntime(12524):    at android.view.ViewTreeObserver.dispatchOnPreDraw(ViewTreeObserver.java:944)
E/AndroidRuntime(12524):    at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2205)
E/AndroidRuntime(12524):    at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1254)
E/AndroidRuntime(12524):    at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6338)
E/AndroidRuntime(12524):    at android.view.Choreographer$CallbackRecord.run(Choreographer.java:874)
E/AndroidRuntime(12524):    at android.view.Choreographer.doCallbacks(Choreographer.java:686)
E/AndroidRuntime(12524):    at android.view.Choreographer.doFrame(Choreographer.java:621)
E/AndroidRuntime(12524):    at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:860)
E/AndroidRuntime(12524):    at android.os.Handler.handleCallback(Handler.java:751)
E/AndroidRuntime(12524):    at android.os.Handler.dispatchMessage(Handler.java:95)
E/AndroidRuntime(12524):    at android.os.Looper.loop(Looper.java:154)
E/AndroidRuntime(12524):    at android.app.ActivityThread.main(ActivityThread.java:6121)
E/AndroidRuntime(12524):    at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(12524):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:889)
E/AndroidRuntime(12524):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:779)|

Got this error when I removed: provided files('tmplibs/flutter.jar')

cstsortan commented 7 years ago

Yeah same error exactly

theobouwman commented 7 years ago

@cstsortan and what was your exact solution?

cstsortan commented 7 years ago

Haven't figured out how to solve it. To be honest I didn't try too much.

villela commented 7 years ago

I'm sorry I haven't had time in the last days. I did took a look again and still can't run anything from flutter in the emulator.

Since I'm almost sure this is a camera permission thing, and could not find any other examples in the flutter plugins I gave a go to add the permissions asking dialog without being able to really test or any way to be sure it would work.

Could you please update your sources and take a look? I wish I could be more helpful here but now is what I can do sorry

cstsortan commented 7 years ago

Ok thank you for trying to fix it, even though you can't test the result ;P Here's what happened to me just now: 1st. I upgrade the package, run the app, permission is asked when I hit the button but then nothing happens. 2nd. I say "Ok, maybe it wants a second time to press the fab", and then gives this error: E/flutter ( 8065): [ERROR:lib/tonic/logging/dart_error.cc(16)] Unhandled exception: E/flutter ( 8065): PlatformException(ALREADY_ACTIVE, QR Code reader is already active, null) E/flutter ( 8065): #0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:514) E/flutter ( 8065): #1 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:154) E/flutter ( 8065): <asynchronous suspension> E/flutter ( 8065): #2 QRCodeReader.scan (package:qrcode_reader/QRCodeReader.dart:53) E/flutter ( 8065): <asynchronous suspension> E/flutter ( 8065): #3 _MyHomePageState.build.<anonymous closure>.<anonymous closure> (file:///C:/Users/tsort/Documents/projects/l2/untitled/lib/main.dart:57) E/flutter ( 8065): #4 State.setState (package:flutter/src/widgets/framework.dart:1162) E/flutter ( 8065): #5 _MyHomePageState.build.<anonymous closure> (file:///C:/Users/tsort/Documents/projects/l2/untitled/lib/main.dart:52) E/flutter ( 8065): #6 _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:325) E/flutter ( 8065): #7 _InkResponseState.build.<anonymous closure> (package:flutter/src/material/ink_well.dart:377) E/flutter ( 8065): #8 GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:102) E/flutter ( 8065): #9 TapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:149) E/flutter ( 8065): #10 TapGestureRecognizer.acceptGesture (package:flutter/src/gestures/tap.dart:119) E/flutter ( 8065): #11 GestureArenaManager.sweep (package:flutter/src/gestures/arena.dart:156) E/flutter ( 8065): #12 BindingBase&SchedulerBinding&GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:147) E/flutter ( 8065): #13 BindingBase&SchedulerBinding&GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:121) E/flutter ( 8065): #14 BindingBase&SchedulerBinding&GestureBinding._handlePointerEvent (package:flutter/src/gestures/binding.dart:101) E/flutter ( 8065): #15 BindingBase&SchedulerBinding&GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:64) E/flutter ( 8065): #16 BindingBase&SchedulerBinding&GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:48) E/flutter ( 8065): #17 _invoke1 (file:///b/build/slave/Linux_Engine/build/src/flutter/lib/ui/hooks.dart:100) E/flutter ( 8065): #18 _dispatchPointerDataPacket (file:///b/build/slave/Linux_Engine/build/src/flutter/lib/ui/hooks.dart:58)

3rd. It says that the qrcode reader is already on which means it thinks it's open but nothing's shown in the screen. So what I did is try a couple things from the phone, restarting, erasing data, but nothing works.

4th. I delete the app, do 'flutter run', still exactly the same.

5th. I don't delete the app and I don't erase data. I just do a second 'flutter run', and this time it works. So something must be buggy over there, I wish you find some way around it bro Still thanks, keep up the great work. Actually I'm pretty new to flutter, I wish I could contribute to this.

villela commented 7 years ago

That's actually great, it was the permission them.

The flow to request the permission and the user having to click it again actually makes sense, there's probably some android callback that tells me the permission was granted but I'll just send back an error that there was no permission.

I'll update it now to return an error in the result and when I have time move the permission logic to the example and document it, or make the plugin handle the permission an option since I have no idea how this should be handled in flutter.

cstsortan commented 7 years ago

Actually, I've seen the change you made. and there's no need to check the platform, if it's API 21 or less then it returns true since the permissions are accepted on app's install. Of course this has nothing to do with our issue xD

villela commented 7 years ago

That's what I thought, that it could not be the permission due the API used, I even did the apk analysis to check that , but it looks like it really is.

Can you check if it crashes with the last commit?

cstsortan commented 7 years ago

Yes it's working. Now let me suggest one more thing to be completely functional: Right now when you hit the FAB, it requests the permissions and when I give them, it just does nothing, it only works when you hit the fab again. Well actually it only has to do with the first time you open the app but still it's important. You need to override onRequestPermissionResult() method and if it's granted, then call your startView() method. and it's not, maybe provide a callback for the developer (anyway idk if this is possible). Haha still good job

villela commented 7 years ago

Thanks. I took a look and there is a callback for that and even if it comes on the onActivityResult Flutter exposes it for us. I did a commit that should make it work as you wish, but again I can't test anything so I have no idea if it is 100%

cstsortan commented 7 years ago

image You forgot something ;P

villela commented 7 years ago

Ops :D Please let me know if it's working now

cstsortan commented 7 years ago

Yes it is. If it's also working for < API 23 devices as well, then I guess it's a wrap

villela commented 7 years ago

Thanks for the suggestions and the help provided, I'll be closing this issue them