9: only buildscript {}, pluginManagement {} and other plugins {} script blocks are allowed before plugins {} blocks, no other statements are allowed

처음에 flutter 프로젝트를 생성하면 plugin이 {}에 묶여있다.

 

plugins {
    id "com.android.application"
    id "kotlin-android"
    // The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins.
    id "dev.flutter.flutter-gradle-plugin"
}

 

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

근데 요렇게 하고 key.properties를 가져오는 코드를 넣고 build appbundle을 하면 오류가 발생한다.

해결법은 plugins {} 안의 내용물을 다 바깥으로 뺀 후에 최상단에 놓으면 된다는거다.

apply plugin: "com.android.application"
apply plugin: "kotlin-android"
apply plugin: "dev.flutter.flutter-gradle-plugin"

왜인지 누가 좀 알려줘,,,,

+ Recent posts