Closed p238049y closed 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実装で、画像のピック(複数枚)をサポートしました。
$ flutter run --release
NullPointerException
で落ちている 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
Android 12のカメラが起動しない
権限を付与するかの確認画面が表示されなかった...
パーミッションの可能性がある AndroidManifest.xmlに以下を追記して再確認
<uses-permission android:name="android.permission.CAMERA" />
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にしておく。
事象
解決策になりそうな記事