Skip to content

10.0.0/10.0.0+1 throw a compile error #593

@evanrich

Description

@evanrich

Updated from 9.1.0 to 10.0.0 and 10.0.0+1. Both of them give the following errors after running flutter build apk:

ERROR: Missing classes detected while running R8. Please add the missing classes or apply additional keep rules that are generated in C:\Users\evanr\Development\ShootBase\build\app\outputs\mapping\release\missing_rules.txt.
ERROR: R8: Missing class okhttp3.Call (referenced from: void com.yalantis.ucrop.task.BitmapLoadTask.downloadFile(android.net.Uri, android.net.Uri))
Missing class okhttp3.Dispatcher (referenced from: void com.yalantis.ucrop.task.BitmapLoadTask.downloadFile(android.net.Uri, android.net.Uri))
Missing class okhttp3.OkHttpClient (referenced from: okhttp3.OkHttpClient com.yalantis.ucrop.OkHttpClientStore.client and 2 other contexts)
Missing class okhttp3.Request$Builder (referenced from: void com.yalantis.ucrop.task.BitmapLoadTask.downloadFile(android.net.Uri, android.net.Uri))
Missing class okhttp3.Request (referenced from: void com.yalantis.ucrop.task.BitmapLoadTask.downloadFile(android.net.Uri, android.net.Uri))
Missing class okhttp3.Response (referenced from: void com.yalantis.ucrop.task.BitmapLoadTask.downloadFile(android.net.Uri, android.net.Uri))
Missing class okhttp3.ResponseBody (referenced from: void com.yalantis.ucrop.task.BitmapLoadTask.downloadFile(android.net.Uri, android.net.Uri))

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:minifyReleaseWithR8'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.R8Task$R8Runnable
   > Compilation failed to complete

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.

BUILD FAILED in 2m 51s
Running Gradle task 'assembleRelease'...                          172.6s
Gradle task assembleRelease failed with exit code 1

according to chatgpt, it suggests doing either of the following:

Option 1:

Create a proguard-rules.pro

# Keep OkHttp classes for UCrop (used by image_cropper)
-keep class okhttp3.** { *; }
-dontwarn okhttp3.**
-keep class com.yalantis.ucrop.** { *; }
-dontwarn com.yalantis.ucrop.**

then edit android/app/build.gradle to add the following:

android {
    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

or Option 2:

add okHttp as a dependency in my project:

dependencies {
    implementation 'com.squareup.okhttp3:okhttp:4.12.0'
    // your other dependencies
}

flutter version 3.35.3
plugin version 10.0.0 and 10.0.0+1

reverting to 9.1.0 works.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions