hm21 / pro_image_editor

The pro_image_editor is a Flutter widget designed for image editing within your application. It provides a flexible and convenient way to integrate image editing capabilities into your Flutter project.
https://hm21.github.io/pro_image_editor/
BSD 3-Clause "New" or "Revised" License
138 stars 75 forks source link

Build error due to unconfigured namespace in image_editor dependency #23

Closed Milimeter closed 5 months ago

Milimeter commented 8 months ago

When attempting to build a project that includes the pro_image_editor package, the build fails with a configuration error related to its dependency, image_editor version 1.3.0. The error is as follows: `1: Task failed with an exception.

Steps to Reproduce Include pro_image_editor in a Flutter project's dependencies. Attempt to build the project for Android. Observe the build failure with the above error message.

Expected Behavior The project builds successfully without any configuration errors related to namespaces in dependencies.

Actual Behavior The build fails due to a missing namespace configuration in the image_editor package.

Suggested Fix According to the provided error message and the AGP documentation, it is necessary to specify a namespace in the module's build file for image_editor. This can be achieved by following the instructions provided in the AGP Upgrade Assistant documentation: . The necessary changes should be applied to the image_editor package to ensure compatibility with recent AGP versions and to avoid build failures due to unconfigured namespaces.

Additional Context Flutter version: 3.19.0 pro_image_editor version: ^2.5.7 image_editor version: 1.3.0 Android Gradle Plugin version: [include the version you are using] Gradle version: 8.2 Please let me know if you need any more information or if there's anything else I can do to help resolve this issue.

hm21 commented 8 months ago

Thanks for reporting this issue with a lot of details.

It seems that only the external package image_editor is the problem. Currently, this package and the extended_image package are required for the crop/rotate editor. I have a plan to remove both packages completely in the future with a better solution. In the dev branch you can see the progress and if you want you can also help to replace the current crop/rotate editor. However, these changes will take a lot of time, which I do not have at the moment. The other option is if you open a new issue in the image_editor package, maybe the owner will fix it then. I try to update always all packages so that will also resolve the issue then.

Milimeter commented 7 months ago

There is a new update 2 days ago on image_editor. They added AGP 8 support for Android. Fixing the issue i raised. How soon would you be able to update the dependency?

Thank you for your hard work in the community brother :)

hm21 commented 7 months ago

Thanks for the info bro. I updated and released it right away ;)

Milimeter commented 7 months ago

Can you reopen this as the error still exists. Can you try to make a build with the specifications to test this out?

Screenshot 2024-03-24 at 5 48 29 PM
hm21 commented 7 months ago

Hmm, I don't know why, but I can't reproduce this problem after updating the image_editor package. May I ask, have you already run flutter clean? If you have already run this command can I maybe take a look at your files like build.gradle, gradle-wrapper.properties and settings.gradle maybe I can reproduce it then.

Milimeter commented 7 months ago

Okay. I will share them:

  1. Settings.gradle `pluginManagement { def flutterSdkPath = { def properties = new Properties() file("local.properties").withInputStream { properties.load(it) } def flutterSdkPath = properties.getProperty("flutter.sdk") assert flutterSdkPath != null, "flutter.sdk not set in local.properties" return flutterSdkPath } settings.ext.flutterSdkPath = flutterSdkPath()

    includeBuild("${settings.ext.flutterSdkPath}/packages/flutter_tools/gradle")

    repositories { google() mavenCentral() gradlePluginPortal() } }

plugins { id "dev.flutter.flutter-plugin-loader" version "1.0.0" id "com.android.application" version "8.2.2" apply false id "org.jetbrains.kotlin.android" version "1.9.22" apply false id "com.google.gms.google-services" version "4.4.0" apply false }

include ":app"`

  1. gradle-wrapper.properties distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-all.zip

  2. build.gradle(app level) `plugins { id "com.android.application" id "org.jetbrains.kotlin.android" id "dev.flutter.flutter-gradle-plugin" id "com.google.gms.google-services" }

def localProperties = new Properties() def localPropertiesFile = rootProject.file('local.properties') if (localPropertiesFile.exists()) { localPropertiesFile.withReader('UTF-8') { reader -> localProperties.load(reader) } }

def flutterVersionCode = localProperties.getProperty('flutter.versionCode') if (flutterVersionCode == null) { flutterVersionCode = '1' }

def flutterVersionName = localProperties.getProperty('flutter.versionName') if (flutterVersionName == null) { flutterVersionName = '1.0' }

def keystoreProperties = new Properties() def keystorePropertiesFile = rootProject.file('key.properties') if (keystorePropertiesFile.exists()) { keystoreProperties.load(new FileInputStream(keystorePropertiesFile)) }

android { namespace "com.tech.app" compileSdkVersion 34 ndkVersion "26.2.11394342"

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}

kotlinOptions {
    jvmTarget = '1.8'
}

sourceSets {
    main.java.srcDirs += 'src/main/kotlin'
}

defaultConfig {
    // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
    applicationId "com.tech.app"
    // You can update the following values to match your application needs.
    // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
    minSdkVersion 26
    targetSdkVersion 34
    versionCode flutterVersionCode.toInteger()
    versionName flutterVersionName
    multiDexEnabled true
}

signingConfigs { release { keyAlias keystoreProperties['keyAlias'] keyPassword keystoreProperties['keyPassword'] storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null storePassword keystoreProperties['storePassword'] } }

buildTypes {
    release {
       shrinkResources true
        minifyEnabled true
        // TODO: Add your own signing config for the release build.
        // Signing with the debug keys for now, so `flutter run --release` works.
        signingConfig signingConfigs.release
    }
}

}

flutter { source '../..' }

dependencies { implementation 'com.google.firebase:firebase-messaging:20.1.0' implementation platform('com.google.firebase:firebase-bom:32.7.4') implementation 'com.google.firebase:firebase-analytics' } `

I will try to flutter clean once again to validate

Milimeter commented 7 months ago

just tried it. Still the same.

FAILURE: Build completed with 2 failures.

1: Task failed with an exception.

2: Task failed with an exception.

BUILD FAILED in 23s Error: Gradle task assembleDebug failed with exit code 1

hm21 commented 7 months ago

Thanks for testing with flutter clean. When I use your configurations, I also run into this issue. The problem is I can't fix this issue cuz it is still from the package image_editor_common which is used by the package image_editor. We can only wait or report this issue in the image_editor package and hope they will fix this issue quickly.

I still have the plan to remove this package and create an own solution for the crop/rotate editor, but currently I don't have much time to do this task cuz it need a lot of time.

Tameflame commented 7 months ago

Getting similar errors, and stuff like crop and rotate aren't working. I would love to see a solution to this! Thanks again for all your hard work on this project, it is a gem!

hm21 commented 7 months ago

Thanks Azam for your feedback.

Yeah, I think the only good solution now is to completely replace the existing crop-rotate-editor, which currently depends on the image_editor, extended_image and image packages. This will not only solve this problem, it will also speed up the editor, and we will be able to export only the states of the transformation, not full images of how the image is cropped. However, as you guys can see in the dev branch, I have already started to create my own solution for this editor. There are many tasks to do, so I don't know how long I will need to finish these tasks. If some of you have free time and want to help a little bit to finish these tasks, I will post below all the tasks we need to do.

hm21 commented 6 months ago

Hey Everyone,

For all of you who are running in this issue and still want/need to use the new Gradle version from Android, you can now try the “pre-release” here. This version replaces the crop rotate editor with a completely custom solution of mine. It's still a work in progress and has some issues and needs more testing, but it should work on every device now.

Please take a look at the changelog file first to get information about what is new and especially what breaking changes this update brings.

The list of open tasks to finish this project can be checked out here, so in case you find a problem, please check first if it's not already an open task.

hm21 commented 5 months ago

I have just released version 3.0.0 which finally resolves this issue.