Skip to content

Latest commit

 

History

History
60 lines (39 loc) · 2.1 KB

try-code-scanner.md

File metadata and controls

60 lines (39 loc) · 2.1 KB
title emoji type topics published publication_name
Android で QR コードスキャンを実装する
📷
tech
android
camera
qr
true
yumemi_inc

はじめに

Android で QR コードスキャンを実装するのに code-scanner を利用します。README の通りの手順ではうまくいかないので Workaround の記録です。

Workaround

変更後の URL が反映されていない?

README には以下のように記載されていますが、まだ反映されていないのか、 Failed to resolve: com.github.yuriy-budiyev:code-scanner:2.1.0 となって失敗します。

dependencies {
    implementation 'com.github.yuriy-budiyev:code-scanner:2.1.0'
}

変更前の URL を指定すると取得可能です。

dependencies {
-   implementation 'com.github.yuriy-budiyev:code-scanner:2.1.0'
+   implementation 'com.budiyev.android:code-scanner:2.1.0'
}

この変更は以下の Pull Request で直近発生していたのでまだ反映されていなくて、直に反映される解消される可能性があります。

yuriy-budiyev/code-scanner#140

パーミッションの許可を求める

別のデモプロジェクトにあるように API 23 以上ではカメラパーミッションの許可を求める必要があります。

https://github.com/yuriy-budiyev/lib-demo-app/blob/2e5faf841d04eb4c9580ae4bbd9b6dc405c6dddf/app/src/main/java/com/budiyev/android/libdemoapp/codescanner/CodeScannerActivity.java#L55-L64

確認リポジトリ

最終的に動作を確認できた状態を以下のリポジトリに反映しました。

https://github.com/ykws/code-scanner-example

確認手順

以下の QR コード生成サイトで FREE TEXT に code-scanner-example と入力します。 https://www.the-qrcode-generator.com/

生成された QR コードをスキャンした結果のスクリーンショットです。

![](https://storage.googleapis.com/zenn-user-upload/010ca5afdc26-20220210.png =200x)