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

R8 Minification Fails Due to Missing java.beans Classes in SnakeYAML #88

Open
kanakapalli opened this issue Jan 23, 2025 · 3 comments
Open
Labels
dependencies Dependencies and packages devops GitHub Devops or MLops

Comments

@kanakapalli
Copy link

Description
While building the release APK for the example project, the build process fails during the R8 minification step. The error indicates missing java.beans classes that are referenced by the SnakeYAML library. Since java.beans is not supported in the Android runtime, the following error is encountered:

Error Log:


ERROR: Missing classes detected while running R8.
Missing class java.beans.BeanInfo
Missing class java.beans.FeatureDescriptor
Missing class java.beans.IntrospectionException
Missing class java.beans.Introspector
Missing class java.beans.PropertyDescriptor

Steps to Reproduce
Clone the yolo-flutter-app repository.
Navigate to the example directory.
Run the following commands to build the release APK:

flutter clean
flutter build apk --release

Observe the build failure during the :app:minifyReleaseWithR8 task.
Expected Behavior
The release APK should be generated successfully without build errors.

Actual Behavior
The build fails with missing classes during the R8 minification step.

Environment
Flutter version: 3.27.1
Android Studio: 2024.1
Kotlin version: 1.7.0 or above
Android Gradle Plugin: 8.0.0

Image Image
@UltralyticsAssistant UltralyticsAssistant added dependencies Dependencies and packages devops GitHub Devops or MLops labels Jan 23, 2025
@UltralyticsAssistant
Copy link
Member

👋 Hello @kanakapalli, thank you for submitting a ultralytics/yolo-flutter-app 🚀 Issue. To help us address your concern efficiently, please ensure you've provided all the necessary information outlined below:

  1. For bug reports:

    • A clear and concise description of the bug 💡
    • A minimum reproducible example (MRE) that demonstrates the issue. This is crucial for us to understand and address the problem effectively.
    • Your environment details (OS, Flutter version, Android Studio version, etc.) 🛠️
    • Expected behavior vs. actual behavior
    • Any error messages or logs related to the issue (you've included some here, which is helpful! 👍)
  2. For feature requests:

    • A detailed description of your feature proposal
    • The problem this feature aims to solve
    • Any alternative approaches you've considered
  3. For questions:

    • Provide as much context as possible about your question
    • Include any research you've done on the topic so far
    • Specify which parts of the documentation or examples you've already reviewed

Please make sure to search through existing issues to avoid duplicates 🔍. If there's anything else you'd like to add, feel free to comment here!

An Ultralytics engineer will look into this issue soon and assist you further. Thanks for helping us improve the project! 🚀

@kanakapalli
Copy link
Author

Suggested Workaround: Add R8 Keep Rules

Locate the proguard-rules.pro file under android/app/proguard-rules.pro.
Add the following rules to prevent R8 from removing java.beans and SnakeYAML classes:

proguard

-keep class java.beans.** { *; }
-dontwarn java.beans.**
-keep class org.yaml.snakeyaml.** { *; }
-dontwarn org.yaml.snakeyaml.**
Rebuild the project with the following commands:
flutter clean
flutter pub get
flutter build apk --release

@pderrenger
Copy link
Member

@kanakapalli thank you for sharing the suggested workaround. Adding the specified R8 keep rules to proguard-rules.pro is an effective solution to prevent class removal issues during minification. If the issue persists, ensure you are using the latest versions of all dependencies and tools. For further assistance, please verify if these steps resolve the problem and share any additional error logs if needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Dependencies and packages devops GitHub Devops or MLops
Projects
None yet
Development

No branches or pull requests

3 participants