본문 바로가기

개발하자

Visual Studio 코드(플리터)의 build.gradle 오류

반응형

Visual Studio 코드(플리터)의 build.gradle 오류

나는 현재 구글 플레이 스토어용 앱을 구축하려고 하고 있으며, 서명 및 출시된 APK를 만들어야 한다. 두 build.gradle 파일을 모두 업데이트하려고 했지만 다음 오류가 표시됩니다:

FAILURE: Build failed with an exception.

* Where:
Build file '/Users/herb/Downloads/morningly/android/app/build.gradle' line: 30

* What went wrong:
A problem occurred evaluating project ':app'.
> Could not find method android() for arguments [build_4k00465lacv9h9hnlvfrbb5oa$_run_closure2@7532b849] on project ':app' of type org.gradle.api.Project.

* 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.

다음은 내 build.gradle 파일입니다:

android build.gradle

buildscript {
    repositories {
        google()
        jcenter()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.1'
        classpath 'com.google.gms:google-services:3.2.1'
    } 
}

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

rootProject.buildDir = '../build'
subprojects {
    project.buildDir = "${rootProject.buildDir}/${project.name}"
}

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

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

android/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 GradleException("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))
   }

   android {
    compileSdkVersion 29
    buildToolsVersion "29.0.1"
    lintOptions {
        disable 'InvalidPackage'
    }

    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "com.example.morningly"
        minSdkVersion 16
        targetSdkVersion 29
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }

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

flutter {
    source '../..'
}

dependencies {
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}

apply plugin: 'com.google.gms.google-services'

자, 저는 이 과정을 돕기 위해 이 기사()를 따라갔습니다. 올바른 Gradle 파일을 편집했는지 확인하고 답변을 확인했지만 소용이 없었습니다. 의견이 있으면 알려주세요. 나는 내 앱을 꼭 올리고 싶다.




누락:

 apply plugin: 'com.android.application'

파일 바로 위에 있습니다. 이것 없이는 이해할 수 없다. :

 apply plugin: 'com.google.gms.google-services' 

또한, 그것을 가지고 있고, 나중에 그것에 물건이 있을 수 있다.




새 GradleException("Flutter SDK를 찾을 수 없습니다. local.properties 파일에서 flot.sdk로 위치를 정의합니다.")

Android/apps/build.gradle/errroe를 열어 문제를 해결하는 오류가 있습니다. Gradel Expection에서 "new"를 제거합니다. GradleException("Flutter SDK를 찾을 수 없습니다. local.properties 파일에서 flot.sdk로 위치를 정의합니다.")


반응형