skip to Main Content

My app run properly in flutter latest version 3.24.5 but when i create release build i got error. how i can fix this?

"/Users/imac/Documents/flutter_sdk/flutter 3.24.5/bin/flutter" --no-color build apk

Running Gradle task 'assembleRelease'...                        
You are applying Flutter's app_plugin_loader Gradle plugin imperatively using the apply script method, which is deprecated and will be removed in a future release. Migrate to applying Gradle plugins with the declarative plugins block: https://flutter.dev/to/flutter-gradle-plugin-apply


FAILURE: Build failed with an exception.

* Where:
Build file '/Users/imac/mobile-app-flutter/android/app/build.gradle' line: 2

* What went wrong:
Plugin [id: 'com.android.application'] was not found in any of the following sources:

- Gradle Core Plugins (plugin is not in 'org.gradle' namespace)
- Plugin Repositories (plugin dependency must include a version number for this source)

* 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 753ms
Running Gradle task 'assembleRelease'...                         1,319ms
Gradle task assembleRelease failed with exit code 1
Process finished with exit code 1

here is my settings.gradle

include ':app'

def localPropertiesFile = new File(rootProject.projectDir, "local.properties")
def properties = new Properties()

assert localPropertiesFile.exists()
localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) }

def flutterSdkPath = properties.getProperty("flutter.sdk")
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle"

I got above error. I also try to change kotlin version but still i got same error. if anyone have any idea than help me to solve.

2

Answers


  1. you need to update your android/build.gradle , android/app/build.gradle and settings.gradle prefer 👉🏻
    this document.

    Login or Signup to reply.
  2. If your app runs properly in Flutter version 3.24.5 but fails during a release build, follow these steps to fix it:

    Check Logs: Use flutter build apk –release and review the error logs for details.
    Dependencies: Ensure all dependencies are compatible with the Flutter version by running flutter pub outdated and updating them if needed.
    ProGuard/R8: If using ProGuard, check your rules in proguard-rules.pro to avoid obfuscation issues.
    Clean Build: Run flutter clean and then rebuild with flutter build apk –release.
    Platform-Specific Code: Verify platform configurations (e.g., Android build.gradle or iOS settings) for compatibility.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search