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...
- delete all cash at Intellij & restart
- 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"
}
- add jcenter()&mavenCentral() at my 'android\build.gradle'
- remove some code at app build file
useProguard true
& add some code.
shrinkResources true
- move my key.jks file to '..\android'directory.
I have some Qs
- in
key.properties
file, I write my PW with ''. ex:storePassword='myPWHere'
this form is right? - 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? - 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.