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

Android app just crashes on startup just by adding the plugin to pubspec.yaml #61

Open
peterlauri opened this issue Jan 22, 2020 · 13 comments

Comments

@peterlauri
Copy link

Just by simply adding the package the Android version crashes on startup. iOS works perfectly in debug and released version. We are not refering to the qrcode_reader anywhere in our code. We have android.permission.CAMERA in uses.permissions. Removing the package from pubspec.yaml gets the app going on Android again.

dependencies:
  flutter:
    sdk: flutter
  http: ^0.12.0
  shared_preferences: ^0.5.6
  qrcode_reader:
    git:
      url: git://github.com/bcko/flutter_qrcode_reader.git
      ref: f47a459

  # The following adds the Cupertino Icons font to your application.
  # Use with the CupertinoIcons class for iOS style icons.
  cupertino_icons: ^0.1.2

dev_dependencies:
  flutter_test:
    sdk: flutter

Flutter doctor.

➜  flutter_poc git:(impersonate-with-qrcode) ✗ flutter doctor -v
[✓] Flutter (Channel beta, v1.13.6, on Mac OS X 10.15.2 19C57, locale en-GB)
    • Flutter version 1.13.6 at /Users/plauri/.applications/flutter
    • Framework revision 659dc8129d (3 weeks ago), 2019-12-30 09:24:47 -0800
    • Engine revision bdc9708d23
    • Dart version 2.8.0 (build 2.8.0-dev.0.0 c547f5d933)

[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
    • Android SDK at /Users/plauri/Library/Android/sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-28, build-tools 28.0.3
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1136-b06)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 11.3)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 11.3, Build version 11C29
    • CocoaPods version 1.8.4

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[!] Android Studio (version 3.2)
    • Android Studio at /Applications/Android Studio.app/Contents
    ✗ Flutter plugin not installed; this adds Flutter specific functionality.
    ✗ Dart plugin not installed; this adds Dart specific functionality.
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1136-b06)

[✓] VS Code (version 1.41.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.7.1

[✓] Connected device (3 available)
    • PRA LX1    • 8NH7N17B04000425 • android-arm64  • Android 8.0.0 (API 26)
    • Chrome     • chrome           • web-javascript • Google Chrome 79.0.3945.130
    • Web Server • web-server       • web-javascript • Flutter Tools

! Doctor found issues in 1 category.
@peterlauri
Copy link
Author

@daadu did you test to build and use the plugin after this PR #57?

@daadu
Copy link
Contributor

daadu commented Jan 25, 2020

Yes, it is working for me.

@peterlauri
Copy link
Author

@daadu is there any other permission than android.permission.CAMERA needed for this plugin to work?

@peterlauri
Copy link
Author

@daadu after the commit a34c10c the app builds and launches, the scanner also launches, but now crashes on scan. No errors...

@lfwells
Copy link
Collaborator

lfwells commented Feb 6, 2020

@daadu after the commit a34c10c the app builds and launches, the scanner also launches, but now crashes on scan. No errors...

This one was my commit. So just to clarify, before my commit the plugin was crashing on startup, but after if you are able to launch, just cannot scan?

Unsure what the issue is, but some questions:
Did you place the camera permission in the correct part of the android manifest, and is it spelt correctly?
What does Logcat say?
Is your app using FlutterFragmentActivity (that is what my fix intended to address). Any other native code changes in your app?

@peterlauri
Copy link
Author

peterlauri commented Feb 9, 2020

@lfwells

Actually, so the camera preview shows up, but crashes as soon as it finds a QR code it crashes. Same code works fine on iOS.

I'm don't know if the app uses FlutterFragmentActivity, I'm using a basic startup project, with no additional changes than added qrcode_reader@a34c10c to the pubspec.yaml

I'm not using Android Studio, just running it from VScode. Do not have Logcat enabled.

This is my full debug AndroidManifest.xml:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.flutter_poc">
    <!-- Flutter needs it to communicate with the running application
         to allow setting breakpoints, to provide hot reload, etc.
    -->
    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.CAMERA"/>

    <uses-feature android:name="android.hardware.camera"/>
    <uses-feature android:name="android.hardware.camera.autofocus"/>
</manifest>

@aegislp
Copy link
Contributor

aegislp commented Feb 16, 2020

hi @peterlauri i had the same error.
I modified que line 141 in the class QRCodeReaderPlugin in my local repo.
if (requestCode == REQUEST_CODE_SCAN_ACTIVITY )
to
if (requestCode == REQUEST_CODE_SCAN_ACTIVITY && pendingResult != null)

@peterlauri
Copy link
Author

Might the comment #61 (comment) be a valid solution?

@aegislp submit a PR?

@rgbinnovation
Copy link

Same issue for me. Just adding it to my app in pubspec.yaml crashes the app on Android simulator immediately after boot. iOS simulator has no issues.

@rgbinnovation
Copy link

@aegislp can you please push this fix?

@rgbinnovation
Copy link

@peterlauri or maybe you can do the fix and push it? I'm reliant on this package, would be greatly appreciated.

@johanhenselmans
Copy link
Collaborator

Dit you get the pubspec.yaml to get the plugin as:

qrcode_reader:
git: https://github.com/bcko/flutter_qrcode_reader.git

I can not publish to pub.dev unfortunately.

@rgbinnovation
Copy link

Had the same issue, adding the .git package worked for me. 4 days trying to solve this crap! Thanks for the fix.

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

No branches or pull requests

6 participants