p238049y / beer-collection-app

ビールを飲んだ時に記録するアプリ
3 stars 0 forks source link

[バグ] Android12でアプリを使用する際、カメラ、ライブラリ機能が使用できない #72

Closed p238049y closed 1 year ago

p238049y commented 1 year ago

事象

解決策になりそうな記事

p238049y commented 1 year ago

メモ

Starting with version 0.8.1 the Android implementation support to pick (multiple) images on Android 4.3 or higher.

// バージョン0.8.1より、Android 4.3以降のAndroid実装で、画像のピック(複数枚)をサポートしました。
p238049y commented 1 year ago

調査過程

p238049y commented 1 year ago

調査過程

  $ flutter run --release
05-02 18:21:13.616 22705 22705 E MethodChannel#plugins.flutter.io/image_picker_android: Failed to handle method call
05-02 18:21:13.616 22705 22705 E MethodChannel#plugins.flutter.io/image_picker_android: java.lang.NullPointerException
05-02 18:21:13.616 22705 22705 E MethodChannel#plugins.flutter.io/image_picker_android:     at java.util.Objects.requireNonNull(Objects.java:220)
05-02 18:21:13.616 22705 22705 E MethodChannel#plugins.flutter.io/image_picker_android:     at java.util.Arrays$ArrayList.<init>(Arrays.java:4248)
05-02 18:21:13.616 22705 22705 E MethodChannel#plugins.flutter.io/image_picker_android:     at java.util.Arrays.asList(Arrays.java:4235)
05-02 18:21:13.616 22705 22705 E MethodChannel#plugins.flutter.io/image_picker_android:     at io.flutter.plugins.imagepicker.f.a(Unknown Source:16)
05-02 18:21:13.616 22705 22705 E MethodChannel#plugins.flutter.io/image_picker_android:     at io.flutter.plugins.imagepicker.f.b(Unknown Source:15)
05-02 18:21:13.616 22705 22705 E MethodChannel#plugins.flutter.io/image_picker_android:     at io.flutter.plugins.imagepicker.e$a.b(Unknown Source:2)
05-02 18:21:13.616 22705 22705 E MethodChannel#plugins.flutter.io/image_picker_android:     at io.flutter.plugins.imagepicker.e.E(Unknown Source:6)
05-02 18:21:13.616 22705 22705 E MethodChannel#plugins.flutter.io/image_picker_android:     at io.flutter.plugins.imagepicker.e.J(Unknown Source:10)
05-02 18:21:13.616 22705 22705 E MethodChannel#plugins.flutter.io/image_picker_android:     at io.flutter.plugins.imagepicker.ImagePickerPlugin.f(Unknown Source:229)
05-02 18:21:13.616 22705 22705 E MethodChannel#plugins.flutter.io/image_picker_android:     at c0.j$a.a(Unknown Source:17)
05-02 18:21:13.616 22705 22705 E MethodChannel#plugins.flutter.io/image_picker_android:     at p.c.k(Unknown Source:18)
05-02 18:21:13.616 22705 22705 E MethodChannel#plugins.flutter.io/image_picker_android:     at p.c.l(Unknown Source:40)
05-02 18:21:13.616 22705 22705 E MethodChannel#plugins.flutter.io/image_picker_android:     at p.c.h(Unknown Source:0)
05-02 18:21:13.616 22705 22705 E MethodChannel#plugins.flutter.io/image_picker_android:     at p.b.run(Unknown Source:12)
05-02 18:21:13.616 22705 22705 E MethodChannel#plugins.flutter.io/image_picker_android:     at android.os.Handler.handleCallback(Handler.java:938)
05-02 18:21:13.616 22705 22705 E MethodChannel#plugins.flutter.io/image_picker_android:     at android.os.Handler.dispatchMessage(Handler.java:99)
05-02 18:21:13.616 22705 22705 E MethodChannel#plugins.flutter.io/image_picker_android:     at android.os.Looper.loopOnce(Looper.java:226)
05-02 18:21:13.616 22705 22705 E MethodChannel#plugins.flutter.io/image_picker_android:     at android.os.Looper.loop(Looper.java:313)
05-02 18:21:13.616 22705 22705 E MethodChannel#plugins.flutter.io/image_picker_android:     at android.app.ActivityThread.main(ActivityThread.java:8582)
05-02 18:21:13.616 22705 22705 E MethodChannel#plugins.flutter.io/image_picker_android:     at java.lang.reflect.Method.invoke(Native Method)
05-02 18:21:13.616 22705 22705 E MethodChannel#plugins.flutter.io/image_picker_android:     at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:563)
05-02 18:21:13.616 22705 22705 E MethodChannel#plugins.flutter.io/image_picker_android:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1133)
05-02 18:21:13.619 22705 22730 I flutter : PlatformException(error, null, null, java.lang.NullPointerException
05-02 18:21:13.619 22705 22730 I flutter :  at java.util.Objects.requireNonNull(Objects.java:220)
05-02 18:21:13.619 22705 22730 I flutter :  at java.util.Arrays$ArrayList.<init>(Arrays.java:4248)
05-02 18:21:13.619 22705 22730 I flutter :  at java.util.Arrays.asList(Arrays.java:4235)
05-02 18:21:13.619 22705 22730 I flutter :  at io.flutter.plugins.imagepicker.f.a(Unknown Source:16)
05-02 18:21:13.619 22705 22730 I flutter :  at io.flutter.plugins.imagepicker.f.b(Unknown Source:15)
05-02 18:21:13.619 22705 22730 I flutter :  at io.flutter.plugins.imagepicker.e$a.b(Unknown Source:2)
05-02 18:21:13.619 22705 22730 I flutter :  at io.flutter.plugins.imagepicker.e.E(Unknown Source:6)
05-02 18:21:13.619 22705 22730 I flutter :  at io.flutter.plugins.imagepicker.e.J(Unknown Source:10)
05-02 18:21:13.619 22705 22730 I flutter :  at io.flutter.plugins.imagepicker.ImagePickerPlugin.f(Unknown Source:229)
05-02 18:21:13.619 22705 22730 I flutter :  at c0.j$a.a(Unknown Source:17)
05-02 18:21:13.619 22705 22730 I flutter :  at p.c.k(Unknown Source:18)
05-02 18:21:13.619 22705 22730 I flutter :  at p.c.l(Unknown Source:40)
05-02 18:21:13.619 22705 22730 I flutter :  at p.c.h(Unknown Source:0)
05-02 18:21:13.619 22705 22730 I flutter :  at p.b.run(Unknown Source:12)
05-02 18:21:13.619 22705 22730 I flutter :  at android.os.Handler.handleCallback(Handler.java:938)
05-02 18:21:13.619 22705 22730 I flutter :  at android.os.Handler.dispatchMessage(Handler.java:99)
05-02 18:21:13.619 22705 22730 I flutter :  at android.os.Looper.loopOnce(Looper.java:226)
05-02 18:21:13.619 22705 22730 I flutter :  at android.os.Looper.loop(Looper.java:313)
05-02 18:21:13.619 22705 22730 I flutter :  at android.app.ActivityThread.main(ActivityThread.java:8582)
05-02 18:21:13.619 22705 22730 I flutter :  at java.lang.refl
<uses-permission android:name="android.permission.CAMERA" />
p238049y commented 1 year ago

gitHubのREADME.mdには

Android
Starting with version 0.8.1 the Android implementation support to pick (multiple) images on Android 4.3 or higher.

No configuration required - the plugin should work out of the box. It is however highly recommended to prepare for Android killing the application when low on memory. How to prepare for this is discussed in the [Handling MainActivity destruction on Android](https://github.com/flutter/packages/tree/main/packages/image_picker/image_picker#handling-mainactivity-destruction-on-android) section.

It is no longer required to add android:requestLegacyExternalStorage="true" as an attribute to the <application> tag in AndroidManifest.xml, as image_picker has been updated to make use of scoped storage.

//
バージョン0.8.1より、Android 4.3以降のAndroid実装で、画像のピック(複数枚)をサポートしました。

設定は不要で、プラグインはすぐに動作するはずです。ただし、メモリ不足の際にAndroidがアプリケーションを終了させることを想定しておくことを強くお勧めします。その方法については、「AndroidにおけるMainActivityの破壊の処理」のセクションで説明しています。

image_pickerがscoped storageを使用するように更新されたため、AndroidManifest.xmlの<application>タグの属性としてandroid:requestLegacyExternalStorage="true "を追加する必要がなくなりました。

以下のように記載があるがセットアップが必要そう

image_pickerについて勉強してみるでは以下のような記載あり

カメラアプリを作るのをやっていたときに、minSdkVersion 21にしないとエラー出たことあるので、21にしておく。