5

I tried to build my Flutter app(bundle).
but i has some problem.

this is my error code:

-Error message
FAILURE: Build failed with an exception.

* Where:
Build file 'C:\Users\user\IdeaProjects\relayWriting\android\app\build.gradle' line: 42

* What went wrong:
A problem occurred evaluating project ':app'.
> No signature of method: build_c3l4fjlvmd1tu5wmv81djoazh.android() is applicable for argument types: (build_c3l4fjlvmd1tu5wmv81djoazh$_run_closure2)
values: [build_c3l4fjlvmd1tu5wmv81djoazh$_run_closure2@7e4ad7b4]

* 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 10s

I think I have some problems with my 'android\build.gradle'&'app\build.gradle'.
at android\build.gradle:

subprojects {
    project.evaluationDependsOn(':app')
}

I think some problems with this ':app'->cause my builder has problem with evaluating project ':app'.

and 'app\build.gradle':

android {

this line has problem. but i don't know how to solve it.
I will write all code of this file at bottom of the article.

I tried to...

  1. delete all cash at Intellij & restart
  2. add classpath at my 'android\build.gradle'
dependencies {
        classpath 'com.android.tools.build:gradle:3.5.4'
        classpath 'com.google.gms:google-services:4.3.13'
//        classpath 'com.android.tools.build:gradle:7.1.3'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.21"
    }
  1. add jcenter()&mavenCentral() at my 'android\build.gradle'
  2. remove some code at app build file
useProguard true

& add some code.

shrinkResources true
  1. move my key.jks file to '..\android'directory.

I have some Qs

  1. in key.properties file, I write my PW with ''. ex: storePassword='myPWHere' this form is right?
  2. At Intellij, my proguard-rules.pro file looks like has some ERRORS like this I think this is just Intellij's mistake. It is true?
  3. at Flutter project, android directory's moduel name has some form?

Here is my code

this is app\build.gradle:

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

def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
    throw new FileNotFoundException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}


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))
}

//def flutterCompileSdkVersion = localProperties.getProperty('flutter.flutterCompileSdkVersion')
//if (flutterCompileSdkVersion == null) {
//    flutterCompileSdkVersion = '31'
//}


apply plugin: 'com.android.application'
//apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
    compileSdkVersion 31
    ndkVersion "25.0.8775105"

    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.tastywaffle.relayWriting"
        // You can update the following values to match your application needs.
        // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration.
        minSdkVersion 20
        targetSdkVersion 31
        versionCode 1.0
        versionName "1.0.0"
    }

    signingConfigs {
        release {
            keyAlias keystoreProperties['keyAlias']
            keyPassword keystoreProperties['keyPassword']
            storeFile file(keystoreProperties['storeFile'])
            storePassword keystoreProperties['storePassword']
        }
    }
    buildTypes {
        release {
            signingConfig signingConfigs.release
            minifyEnabled true
//            useProguard true
            shrinkResources true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'

        }
    }

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

flutter {
    source '../..'
}

dependencies {

    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.6.10"
}
apply plugin: 'com.google.gms.google-services'
com.google.gms.googleservices.GoogleServicesPlugin.config.disableVersionCheck = true

this is my android\build.gradle:

buildscript {
    ext.kotlin_version = '1.6.10'
    repositories {
        google()
        jcenter()
        mavenCentral()
    }

    dependencies {
//        classpath 'com.android.tools.build:gradle:3.5.4'
        classpath 'com.android.tools.build:gradle:7.1.2'
        classpath 'com.google.gms:google-services:4.3.13'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.21"
    }
}



allprojects {
    repositories {
        google()
        jcenter()
        mavenCentral()
    }
}

rootProject.buildDir = '../build'
subprojects {
    project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
    project.evaluationDependsOn(':app')
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

& my gradle-wrapper.properties

#Fri Jun 23 08:50:38 CEST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip

I really appreciate that your help.

tastywaffle
  • 51
  • 1
  • 1
  • 3

3 Answers3

3

Try This

put minSdkVersion 20+

in android/build.gradle

 dependencies {
      classpath 'com.android.tools.build:gradle:7.1.2'

in gradle-wrapper.properties

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

OR

in android/build.gradle

 dependencies {
      classpath 'com.android.tools.build:gradle:4.1.0'

in gradle-wrapper.properties

distributionUrl=https\://services.gradle.org/distributions/gradle-7.0-bin.zip
Ninad7N
  • 544
  • 4
  • 13
0

THis worked for me: I just opened Task Manager Click on Details Right click on anything with jave.exe Select end task Rerun your application

Shexa
  • 1
  • This does not provide an answer to the question. Once you have sufficient [reputation](https://stackoverflow.com/help/whats-reputation) you will be able to [comment on any post](https://stackoverflow.com/help/privileges/comment); instead, [provide answers that don't require clarification from the asker](https://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-can-i-do-instead). - [From Review](/review/late-answers/33677286) – V-rund Puro-hit Jan 25 '23 at 07:17
-1

Change build gradle latest version.

In android/build.gradle:

dependencies{
  classpath 'com.android.tools.build:gradle:7.3.1'

In gradle-wrapper.properties:

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

If you have still the same error, try to remove properties from the release section in app/build.gradle, like minifyEnabled, shrinkResources.

buildTypes{
      release{
            minifyEnabled false
            shrinkResources false
            useProguard false
            debuggable false

hope so it will be helpful.

Moritz Ringler
  • 9,772
  • 9
  • 21
  • 34