facundomedica / fast_qr_reader_view

A Fast QR Reader widget for Flutter. For both Android and iOS
MIT License
295 stars 163 forks source link

Needs to be migrated to AndroidX. #32

Closed pneves001 closed 4 years ago

pneves001 commented 5 years ago

/Users/philipneves/flutter/.pub-cache/hosted/pub.dartlang.org/fast_qr_reader_view-0.1.5/android/src/main/java/co/apperto/fastqrreaderview/java/VisionProcessorBase.java:18: error: package android.support.annotation does not exist import android.support.annotation.NonNull;
^
/Users/philipneves/flutter/.pub-cache/hosted/pub.dartlang.org/fast_qr_reader_view-0.1.5/android/src/main/java/co/apperto/fastqrreaderview/java/barcodescanning/BarcodeScanningProcessor.java:16: error: package android.support.annotation does not exist import android.support.annotation.NonNull;
^
/Users/philipneves/flutter/.pub-cache/hosted/pub.dartlang.org/fast_qr_reader_view-0.1.5/android/src/main/java/co/apperto/fastqrreaderview/common/CameraSource.java:25: error: package android.support.annotation does not exist import android.support.annotation.Nullable;
^
/Users/philipneves/flutter/.pub-cache/hosted/pub.dartlang.org/fast_qr_reader_view-0.1.5/android/src/main/java/co/apperto/fastqrreaderview/common/CameraSource.java:26: error: package android.support.annotation does not exist import android.support.annotation.RequiresPermission;
^
/Users/philipneves/flutter/.pub-cache/hosted/pub.dartlang.org/fast_qr_reader_view-0.1.5/android/src/main/java/co/apperto/fastqrreaderview/FastQrReaderViewPlugin.java:18: error: package android.support.annotation does not exist import android.support.annotation.NonNull;
^
/Users/philipneves/flutter/.pub-cache/hosted/pub.dartlang.org/fast_qr_reader_view-0.1.5/android/src/main/java/co/apperto/fastqrreaderview/FastQrReaderViewPlugin.java:19: error: package android.support.annotation does not exist import android.support.annotation.Nullable;
^
/Users/philipneves/flutter/.pub-cache/hosted/pub.dartlang.org/fast_qr_reader_view-0.1.5/android/src/main/java/co/apperto/fastqrreaderview/java/VisionProcessorBase.java:133: error: cannot find symbol @NonNull T results,
^
symbol: class NonNull
location: class VisionProcessorBase
where T is a type-variable:
T extends Object declared in class VisionProcessorBase
/Users/philipneves/flutter/.pub-cache/hosted/pub.dartlang.org/fast_qr_reader_view-0.1.5/android/src/main/java/co/apperto/fastqrreaderview/java/VisionProcessorBase.java:134: error: cannot find symbol @NonNull FrameMetadata frameMetadata);//,
^
symbol: class NonNull
location: class VisionProcessorBase
where T is a type-variable:
T extends Object declared in class VisionProcessorBase
/Users/philipneves/flutter/.pub-cache/hosted/pub.dartlang.org/fast_qr_reader_view-0.1.5/android/src/main/java/co/apperto/fastqrreaderview/java/VisionProcessorBase.java:137: error: cannot find symbol protected abstract void onFailure(@NonNull Exception e);
^
symbol: class NonNull
location: class VisionProcessorBase
where T is a type-variable:
T extends Object declared in class VisionProcessorBase
/Users/philipneves/flutter/.pub-cache/hosted/pub.dartlang.org/fast_qr_reader_view-0.1.5/android/src/main/java/co/apperto/fastqrreaderview/java/barcodescanning/BarcodeScanningProcessor.java:78: error: cannot find symbol @NonNull List barcodes,
^
symbol: class NonNull
location: class BarcodeScanningProcessor
/Users/philipneves/flutter/.pub-cache/hosted/pub.dartlang.org/fast_qr_reader_view-0.1.5/android/src/main/java/co/apperto/fastqrreaderview/java/barcodescanning/BarcodeScanningProcessor.java:79: error: cannot find symbol @NonNull FrameMetadata frameMetadata) { //,
^
symbol: class NonNull
location: class BarcodeScanningProcessor
/Users/philipneves/flutter/.pub-cache/hosted/pub.dartlang.org/fast_qr_reader_view-0.1.5/android/src/main/java/co/apperto/fastqrreaderview/java/barcodescanning/BarcodeScanningProcessor.java:93: error: cannot find symbol protected void onFailure(@NonNull Exception e) {
^
symbol: class NonNull
location: class BarcodeScanningProcessor
/Users/philipneves/flutter/.pub-cache/hosted/pub.dartlang.org/fast_qr_reader_view-0.1.5/android/src/main/java/co/apperto/fastqrreaderview/common/CameraSource.java:159: error: cannot find symbol @RequiresPermission(Manifest.permission.CAMERA)
^
symbol: class RequiresPermission
location: class CameraSource
/Users/philipneves/flutter/.pub-cache/hosted/pub.dartlang.org/fast_qr_reader_view-0.1.5/android/src/main/java/co/apperto/fastqrreaderview/common/CameraSource.java:186: error: cannot find symbol @RequiresPermission(Manifest.permission.CAMERA)
^
symbol: class RequiresPermission
location: class CameraSource
/Users/philipneves/flutter/.pub-cache/hosted/pub.dartlang.org/fast_qr_reader_view-0.1.5/android/src/main/java/co/apperto/fastqrreaderview/common/CameraSource.java:402: error: cannot find symbol @Nullable Camera.Size pictureSize) {
^
symbol: class Nullable
location: class SizePair
/Users/philipneves/flutter/.pub-cache/hosted/pub.dartlang.org/fast_qr_reader_view-0.1.5/android/src/main/java/co/apperto/fastqrreaderview/common/CameraSource.java:413: error: cannot find symbol @Nullable
^
symbol: class Nullable
location: class SizePair
/Users/philipneves/flutter/.pub-cache/hosted/pub.dartlang.org/fast_qr_reader_view-0.1.5/android/src/main/java/co/apperto/fastqrreaderview/FastQrReaderViewPlugin.java:263: error: cannot find symbol void startScanning(@NonNull Result result) {
^
symbol: class NonNull
location: class FastQrReaderViewPlugin
/Users/philipneves/flutter/.pub-cache/hosted/pub.dartlang.org/fast_qr_reader_view-0.1.5/android/src/main/java/co/apperto/fastqrreaderview/FastQrReaderViewPlugin.java:329: error: cannot find symbol void stopScanning(@NonNull Result result) {
^
symbol: class NonNull
location: class FastQrReaderViewPlugin
/Users/philipneves/flutter/.pub-cache/hosted/pub.dartlang.org/fast_qr_reader_view-0.1.5/android/src/main/java/co/apperto/fastqrreaderview/FastQrReaderViewPlugin.java:392: error: cannot find symbol QrReader(final String cameraName, final String resolutionPreset, final ArrayList formats, @NonNull final Result result) { ^ symbol: class NonNull
location: class FastQrReaderViewPlugin.QrReader
/Users/philipneves/flutter/.pub-cache/hosted/pub.dartlang.org/fast_qr_reader_view-0.1.5/android/src/main/java/co/apperto/fastqrreaderview/FastQrReaderViewPlugin.java:563: error: cannot find symbol private void open(@Nullable final Result result) {
^
symbol: class Nullable
location: class FastQrReaderViewPlugin.QrReader
/Users/philipneves/flutter/.pub-cache/hosted/pub.dartlang.org/fast_qr_reader_view-0.1.5/android/src/main/java/co/apperto/fastqrreaderview/java/VisionProcessorBase.java:116: error: cannot find symbol public void onFailure(@NonNull Exception e) { ^
symbol: class NonNull
Note: /Users/philipneves/flutter/.pub-cache/hosted/pub.dartlang.org/fast_qr_reader_view-0.1.5/android/src/main/java/co/apperto/fastqrreaderview/common/CameraSource.java uses or overrides a deprecated API. Note: Recompile with -Xlint:deprecation for details.
21 errors

FAILURE: Build failed with an exception.

BUILD FAILED in 4s
Running Gradle task 'assembleDebug'...
Running Gradle task 'assembleDebug'... Done 5.0s


The Gradle failure may have been because of AndroidX incompatibilities in this Flutter app. See https://goo.gl/CP92wY for more information on the problem and how to fix it.


Gradle task assembleDebug failed with exit code 1

bradintheusa commented 5 years ago

I would appreciate this to.

facundomedica commented 5 years ago

Have you tried using this library from the git repo instead of the pub?

bradintheusa commented 5 years ago

When I do this

  fast_qr_reader_view: 
     git:
      url: git://github.com/facundomedica/fast_qr_reader_view.git

I get this


* What went wrong:
Could not determine the dependencies of task ':firebase_core:compileReleaseAidl'.
> Failed to notify dependency resolution listener.
   > The library com.google.android.gms:play-services-measurement-api is being requested by various other libraries at [[16.0.3,16.0.3]], but resolves to 16.0.2. Disable the plugin and check your dependencies tree using
./gradlew :app:dependencies.
   > The library com.google.firebase:firebase-analytics is being requested by various other libraries at [[16.0.5,16.0.5]], but resolves to 16.0.4. Disable the plugin and check your dependencies tree using ./gradlew :app:dependencies.
kcin9 commented 5 years ago

I tried with pub/git/local importing to run the App, resulted the same error @pneves001 first experienced.

James-A-White commented 5 years ago

I finally got it working under AndroidX ... I'm not guaranteeing that this will work for you or that you need to do all of these steps, but here's what I did...

1. In your pubspec.yaml file, include two things

  fast_qr_reader_view: 
    git:
      url: git://github.com/facundomedica/fast_qr_reader_view.git

.... and also ...

permission_handler: 2.2.0

Note: on the permission_handler, I didn't use 3.0.0 or ^2.0.0 because there were dependency issues with geolocator.

2. As in the documentation for fast_qr_reader_view, increase the minSdkVersion to 21 in your build.gradle file located in the ../android/app folder.

3. In the documentation for fast_qr_reader_view, it says "Add Firebase to your project following this step (only that step, not the entire guide).", with "this step" pointing to Step 6, "Create a Firebase Project". In fact, you need to do both Step 6 AND Step 7 (the documentation for fast_qr_reader_view should be updated to say do both steps). Start with this step and then do this step.

4. One thing that threw me off (as primarily an iOS developer) is that there are two build.gradle files. One at the ../android level and the other at the ../android/app level. At the ../android level add

classpath 'com.google.gms:google-services:3.2.1'

Make sure you use 3.2.1, it is the latest that is compatible with Flutter. There are later releases (4.0 and 4.2, I think), but they are not compatible with Flutter.

At the ../android/app level, modify the build.gradle file by ensuring the minSdkVersion is 21 or greater and also by adding this as the last line in the file.

apply plugin: 'com.google.gms.google-services'

also, don't forget... in step 7 of the Add Firebase instructions, you have to download the google-services.json file that has been generated with your specific project details and include it in the ../android/app folder.

5. With these changes above, it might be enough to get it working... however, I also added permissions for the camera in the various AndroidManifest.xml files for main, profile and debug

<uses-permission android:name="android.permission.CAMERA" />

Then in my code, near to where the app is launched, I added:

import 'package:permission_handler/permission_handler.dart';

and

await PermissionHandler().requestPermissions([PermissionGroup.camera]);

That should do it!!!

There are a lot of steps, and more than a few places where you could go wrong. For me what was causing me the most problems is I didn't notice that there were two separate build.gradle files that needed to be modified... the first time around, I put all of the changes in the build.gradle file at ../android instead of also putting the necessary changes in the build.gradle file at ../android/app.

The good news is it now works fine. For me, there are two areas I'm still a bit concerned about. When it executes it produces a lot of errors in the debug console even though it is working fine. The other problem I have is that the camera is fixed on "far focus", making it nearly impossible to read complex QR codes with a lot of detail by moving them closer to the lens.

I hope this helps. There aren't many good QR readers out there, and this one seems to be the best in my opinion. Hopefully this will stabilize over the next few releases and / or the documentation will be updated to make it more clear how to get this working under AndroidX.

Good luck! :-)

JW

Just for additional context, I'm running on a fairly new Nokia phone (6.1) with Android 1. I recently had to downgrade my Flutter and Dart plugins, along with VS Code to the January 2019 versions because hot reload seems to be broken in the Feb release. I'm working on a Mac.

bradintheusa commented 5 years ago

I still get this after following the steps

* What went wrong:
Could not determine the dependencies of task ':fast_qr_reader_view:compileDebugAidl'.
> Failed to notify dependency resolution listener.
   > The library com.google.android.gms:play-services-measurement-api is being requested by various other libraries at [[16.3.0,16.3.0]], but resolves to 16.0.3. Disable the plugin and check your dependencies tree using ./gradlew :app:dependencies.
   > The library com.google.firebase:firebase-analytics is being requested by various other libraries at [[16.3.0,16.3.0]], but resolves to 16.0.5. Disable the plugin and check your dependencies tree using ./gradlew :app:dependencies.
kcin9 commented 5 years ago

I still get this after following the steps

* What went wrong:
Could not determine the dependencies of task ':fast_qr_reader_view:compileDebugAidl'.
> Failed to notify dependency resolution listener.
   > The library com.google.android.gms:play-services-measurement-api is being requested by various other libraries at [[16.3.0,16.3.0]], but resolves to 16.0.3. Disable the plugin and check your dependencies tree using ./gradlew :app:dependencies.
   > The library com.google.firebase:firebase-analytics is being requested by various other libraries at [[16.3.0,16.3.0]], but resolves to 16.0.5. Disable the plugin and check your dependencies tree using ./gradlew :app:dependencies.

Because there are other dependencies in your project implementing google services(gms, firebase) as well, and there's conflict between the firebase-core and the deps.

In order to resolve the problem, I think you will have to unifying the dep versions.

To find a clue of what deps are included in which package, you may cd android then ./gradlew :app:dependencies to print the dep tree.

Anyways, same situation here, and am still searching for the one-for-all solution.

x4080 commented 5 years ago

I tried with AndroidX and works flawlessly (only 1st time crash when dont have permission yet)

parcool commented 4 years ago

@James-A-White Why I have to use Firebase and gsm? just for it?

SoftWyer commented 4 years ago

@James-A-White Why I have to use Firebase and gsm? just for it?

Because it uses Firebase ML Vision library for Barcode detection.