Issue
My app keeps crashing when I try to open image cropper in release mode.
I added everything in the manifest
as directed in the documentation:
<activity
android:name="com.yalantis.ucrop.UCropActivity"
android:screenOrientation="portrait"
android:theme="@style/Theme.AppCompat.Light.NoActionBar"/>
How I use it:
Future<void> _cropImage(File imageFile, int index) async {
if(imageFile != null){
File cropped = await ImageCropper.cropImage(
sourcePath: imageFile.path,
aspectRatio: CropAspectRatio(ratioX: 1.0, ratioY: 1.0),
compressQuality: 100,
maxHeight: height,
maxWidth: width,
androidUiSettings: AndroidUiSettings(
toolbarTitle: "",
toolbarWidgetColor: Colors.black.withOpacity(0.6),
statusBarColor: Colors.black,
activeControlsWidgetColor: Colors.white,
)
);
setState(() {
compress(cropped, index);
});
}}
As soon as I start the app in release mode, the following error message appears:
E/AndroidRuntime(13412): FATAL EXCEPTION: main
E/AndroidRuntime(13412): Process: com.packages.xxx, PID: 13412
E/AndroidRuntime(13412): java.lang.NoSuchMethodError: No static method
asAttributeSet(Li/a/a/a;)Landroid/util/AttributeSet; in class Landroid/util/Xml; or its super classes (declaration of 'android.util.Xml' appears in /system/framework/framework.jar!classes3.dex)
E/AndroidRuntime(13412): at a.a.n.g.inflate(Unknown Source:21)
E/AndroidRuntime(13412): at com.yalantis.ucrop.UCropActivity.onCreateOptionsMenu(Unknown Source:6)
E/AndroidRuntime(13412): at android.app.Activity.onCreatePanelMenu(Activity.java:4212)
E/AndroidRuntime(13412): at androidx.fragment.app.d.onCreatePanelMenu(Unknown Source:2)
E/AndroidRuntime(13412): at a.a.n.i.onCreatePanelMenu(Unknown Source:2)
E/AndroidRuntime(13412): at androidx.appcompat.app.g$j.onCreatePanelMenu(Unknown Source:8)
E/AndroidRuntime(13412): at a.a.n.i.onCreatePanelMenu(Unknown Source:2)
E/AndroidRuntime(13412): at androidx.appcompat.app.j.m(Unknown Source:25)
E/AndroidRuntime(13412): at androidx.appcompat.app.j$a.run(Unknown Source:2)
E/AndroidRuntime(13412): at android.os.Handler.handleCallback(Handler.java:938)
E/AndroidRuntime(13412): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(13412): at android.os.Looper.loop(Looper.java:233)
E/AndroidRuntime(13412): at android.app.ActivityThread.main(ActivityThread.java:7959)
E/AndroidRuntime(13412): at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(13412): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:631)
E/AndroidRuntime(13412): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:978)
How can I fix this?. Thanks.
Solution
We will go through multiple solutions try them and tell me which one is your problem
1- in your build.gradle(Module : app)
you will find this section remove it
if (details.requested.group == 'com.android.support'
&& !details.requested.name.contains('multidex') ) {
details.useVersion "27.1.1"
}
if (details.requested.group == 'androidx.core'
&& !details.requested.name.contains('androidx') ) {
details.useVersion "1.0.1"
}
if (requested.group == "androidx") {
if (!requested.name.startsWith("multidex")) {
details.useVersion "${targetSdk}.+"
}
2- Try adding the needed permissions to your manifest
<uses-permission android:name="android.permission.CAMERA"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
3- Try changing the gradle version into something like
classpath 'com.android.tools.build:gradle:3.6.3'
Answered By - Moaid ALRazhy
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.