Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NullPointerException in UCropActivity during onCreateOptionsMenu() causing crash in release mode #544

Open
mbfakourii opened this issue Dec 22, 2024 · 4 comments

Comments

@mbfakourii
Copy link

mbfakourii commented Dec 22, 2024

Description

The app crashes with a NullPointerException in the UCropActivity during the onCreateOptionsMenu() method, but only in release mode. This issue does not occur in debug mode.

FATAL EXCEPTION: main
 Process: com.example.app, PID: 4046
   java.lang.NullPointerException: throw with null exception
    at m.i.inflate(SourceFile:25)
    at com.yalantis.ucrop.UCropActivity.onCreateOptionsMenu(SourceFile:7)
    at android.app.Activity.onCreatePanelMenu(Activity.java:4228)
    at e.n.onCreatePanelMenu(SourceFile:3)
    at j.y.onCreatePanelMenu(SourceFile:11)
    at e.j.run(SourceFile:925)
    at android.os.Handler.handleCallback(Handler.java:888)
    at android.os.Handler.dispatchMessage(Handler.java:100)
    at android.os.Looper.loop(Looper.java:213)
    at android.app.ActivityThread.main(ActivityThread.java:8178)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:513)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1101)

Additional Information
settings.gradle:

id "com.android.application" version "8.2.1" apply false

gradle-wrapper.properties:

distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-all.zip

Other:

Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 3.27.1, on Microsoft Windows [Version 10.0.26100.2454], locale en-US)
[√] Windows Version (Installed version of Windows is version 10 or higher)
[√] Android toolchain - develop for Android devices (Android SDK version 35.0.0)
[√] Chrome - develop for the web
[√] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.11.5)
[√] Android Studio (version 2024.2)
[√] Connected device (5 available)
[√] Network resources
@mbfakourii
Copy link
Author

mbfakourii commented Dec 22, 2024

app/build.gradle:

buildTypes {
    release {
        minifyEnabled false
        shrinkResources false
        signingConfig signingConfigs.release
    }
}

I solved the problem with this code, but the program size increased by 7 MB!

@GuimG
Copy link

GuimG commented Dec 27, 2024

@mbfakourii works for me too. We had the same problem in production and I needed a quick fix, thanks.

@PisethChuon
Copy link

Add the UCropActivity to your Android projects AndroidManifest.xml file.

<activity     
            android:name="com.yalantis.ucrop.UCropActivity"
            android:theme="@style/Theme.AppCompat.NoActionBar" />

Open android/app/src/main/AndroidManifest.xml.

It works for me.
This specifies the UCropActivity class that handles the image cropping.

@hnvn
Copy link
Owner

hnvn commented Dec 27, 2024

add following lines to your android/app/proguard-rules.pro:

-dontwarn com.yalantis.ucrop**
-keep class com.yalantis.ucrop** { *; }
-keep interface com.yalantis.ucrop** { *; }

Fyi why it happened? https://developer.android.com/build/shrink-code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants