Flutter 将 activity 添加到 Android ImageCropper 清单
Flutter add activity to Android Manifest for ImageCropper
我正在尝试在我的应用程序中实施 ImageCropper。在 Android 上,我需要根据文档向清单中添加一些内容,但我无法使其正常工作...这是我的清单:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.memories">
<!-- Flutter needs it to communicate with the running application
to allow setting breakpoints, to provide hot reload, etc.
-->
<application>
<activity>
android:name="com.yalantis.ucrop.UCropActivity"
android:screenOrientation="portrait"
android:theme="@style/Theme.AppCompat.Light.NoActionBar"
</activity>
</application>
<uses-permission android:name="android.permission.INTERNET"/>
但这会因以下错误而崩溃:
E/AndroidRuntime( 9936): at android.os.Looper.loop(Looper.java:223)
E/AndroidRuntime( 9936): at android.app.ActivityThread.main(ActivityThread.java:7656)
E/AndroidRuntime( 9936): at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime( 9936): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
E/AndroidRuntime( 9936): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
E/AndroidRuntime( 9936): Caused by: java.lang.IllegalStateException: Reply already submitted
E/AndroidRuntime( 9936): at io.flutter.embedding.engine.dart.DartMessenger$Reply.reply(DartMessenger.java:155)
E/AndroidRuntime( 9936): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.success(MethodChannel.java:238)
E/AndroidRuntime( 9936): at vn.hunghd.flutter.plugins.imagecropper.ImageCropperDelegate.onActivityResult(ImageCropperDelegate.java:106)
E/AndroidRuntime( 9936): at io.flutter.embedding.engine.FlutterEngineConnectionRegistry$FlutterEngineActivityPluginBinding.onActivityResult(FlutterEngineConnectionRegistry.java:739)
E/AndroidRuntime( 9936): at io.flutter.embedding.engine.FlutterEngineConnectionRegistry.onActivityResult(FlutterEngineConnectionRegistry.java:426)
E/AndroidRuntime( 9936): at io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.onActivityResult(FlutterActivityAndFragmentDelegate.java:677)
E/AndroidRuntime( 9936): at io.flutter.embedding.android.FlutterActivity.onActivityResult(FlutterActivity.java:624)
E/AndroidRuntime( 9936): at android.app.Activity.dispatchActivityResult(Activity.java:8310)
E/AndroidRuntime( 9936): at android.app.ActivityThread.deliverResults(ActivityThread.java:5008)
E/AndroidRuntime( 9936): ... 11 more
I/Process ( 9936): Sending signal. PID: 9936 SIG: 9
我在这里错过了什么?添加 activities
的正确方法是什么?
在 AndroidMainfest 中尝试此代码。可能是您在应用程序级别缺少启动器 Activity。
<application
android:name="io.flutter.app.FlutterApplication"
android:label="example"
android:icon="@mipmap/ic_launcher">
<activity
android:name=".MainActivity"
android:launchMode="singleTop"
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<meta-data
android:name="flutterEmbedding"
android:value="2" />
<activity
android:name="com.yalantis.ucrop.UCropActivity"
android:screenOrientation="portrait"
android:theme="@style/Theme.AppCompat.Light.NoActionBar"/>
</application>
aaah...我改错了manifest
...重要的是改main:
/android/app/src/main/AndroidManifest.xml
现在一切正常。
我正在尝试在我的应用程序中实施 ImageCropper。在 Android 上,我需要根据文档向清单中添加一些内容,但我无法使其正常工作...这是我的清单:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.memories">
<!-- Flutter needs it to communicate with the running application
to allow setting breakpoints, to provide hot reload, etc.
-->
<application>
<activity>
android:name="com.yalantis.ucrop.UCropActivity"
android:screenOrientation="portrait"
android:theme="@style/Theme.AppCompat.Light.NoActionBar"
</activity>
</application>
<uses-permission android:name="android.permission.INTERNET"/>
但这会因以下错误而崩溃:
E/AndroidRuntime( 9936): at android.os.Looper.loop(Looper.java:223) E/AndroidRuntime( 9936): at android.app.ActivityThread.main(ActivityThread.java:7656) E/AndroidRuntime( 9936): at java.lang.reflect.Method.invoke(Native Method) E/AndroidRuntime( 9936): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592) E/AndroidRuntime( 9936): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947) E/AndroidRuntime( 9936): Caused by: java.lang.IllegalStateException: Reply already submitted E/AndroidRuntime( 9936): at io.flutter.embedding.engine.dart.DartMessenger$Reply.reply(DartMessenger.java:155) E/AndroidRuntime( 9936): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.success(MethodChannel.java:238) E/AndroidRuntime( 9936): at vn.hunghd.flutter.plugins.imagecropper.ImageCropperDelegate.onActivityResult(ImageCropperDelegate.java:106) E/AndroidRuntime( 9936): at io.flutter.embedding.engine.FlutterEngineConnectionRegistry$FlutterEngineActivityPluginBinding.onActivityResult(FlutterEngineConnectionRegistry.java:739) E/AndroidRuntime( 9936): at io.flutter.embedding.engine.FlutterEngineConnectionRegistry.onActivityResult(FlutterEngineConnectionRegistry.java:426) E/AndroidRuntime( 9936): at io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.onActivityResult(FlutterActivityAndFragmentDelegate.java:677) E/AndroidRuntime( 9936): at io.flutter.embedding.android.FlutterActivity.onActivityResult(FlutterActivity.java:624) E/AndroidRuntime( 9936): at android.app.Activity.dispatchActivityResult(Activity.java:8310) E/AndroidRuntime( 9936): at android.app.ActivityThread.deliverResults(ActivityThread.java:5008) E/AndroidRuntime( 9936): ... 11 more I/Process ( 9936): Sending signal. PID: 9936 SIG: 9
我在这里错过了什么?添加 activities
的正确方法是什么?
在 AndroidMainfest 中尝试此代码。可能是您在应用程序级别缺少启动器 Activity。
<application
android:name="io.flutter.app.FlutterApplication"
android:label="example"
android:icon="@mipmap/ic_launcher">
<activity
android:name=".MainActivity"
android:launchMode="singleTop"
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<meta-data
android:name="flutterEmbedding"
android:value="2" />
<activity
android:name="com.yalantis.ucrop.UCropActivity"
android:screenOrientation="portrait"
android:theme="@style/Theme.AppCompat.Light.NoActionBar"/>
</application>
aaah...我改错了manifest
...重要的是改main:
/android/app/src/main/AndroidManifest.xml
现在一切正常。