본문 바로가기

카테고리 없음

[Android] 버전 맞추기, 구현 가능했던 build 설정들

Kotlin releases | Kotlin Documentation

 

Kotlin releases | Kotlin

 

kotlinlang.org

kotlin의 버전이 너무 낮다는 오류가 떴다. android 쪽은 Firebase나 NaverMap 같이 외부 api를 쓸 경우 버전 때문에 생기는 에러가 꽤 많은 편이다. 계속 최신 문서 보면서 버전 업데이트 해줘야 한다.

 

The official repository for Dart and Flutter packages.

 

The official repository for Dart and Flutter packages.

Pub is the package manager for the Dart programming language, containing reusable libraries & packages for Flutter and general Dart programs.

pub.dev

flutter package를 다운 받아올 때 최신 버전을 확인할 수 있는 사이트.

 

android/app/src/build.gradle.kts

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

dependencies {
    implementation("com.google.firebase:firebase-analytics-ktx") // 예: Analytics
    implementation("com.google.firebase:firebase-auth-ktx") // 예: Auth
    implementation("com.google.firebase:firebase-firestore-ktx") // 예: Firestore
}

android {
    namespace = "com.jetty.ai_trip"
    compileSdk = flutter.compileSdkVersion
    ndkVersion = flutter.ndkVersion

    compileOptions {
        sourceCompatibility = JavaVersion.VERSION_11
        targetCompatibility = JavaVersion.VERSION_11
    }

    kotlinOptions {
        jvmTarget = "11"
    }

    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId = "com.jetty.ai_trip"
        // You can update the following values to match your application needs.
        // For more information, see: https://flutter.dev/to/review-gradle-config.
        minSdk = 23
        targetSdk = flutter.targetSdkVersion
        versionCode = flutter.versionCode
        versionName = flutter.versionName
    }

    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.getByName("debug")
        }
    }
}

flutter {
    source = "../.."
}
  • kotlin 부분 com.kotlin.android ... 이런식으로 되어 있는 부분 변경
  • jvm target 인식 못해서 숫자 "11" 넣어서 변경
  • minSdk 숫자로 변경 (23) 외부 api들과 충돌되었던 부분이다.

setting.gradle.kts

pluginManagement {
    val flutterSdkPath = run {
        val properties = java.util.Properties()
        file("local.properties").inputStream().use { properties.load(it) }
        val flutterSdkPath = properties.getProperty("flutter.sdk")
        require(flutterSdkPath != null) { "flutter.sdk not set in local.properties" }
        flutterSdkPath
    }

    includeBuild("$flutterSdkPath/packages/flutter_tools/gradle")

    repositories {
        google()
        mavenCentral()
        gradlePluginPortal()
    }
}

dependencyResolutionManagement {
    repositories {
        google()
        mavenCentral()
    }
}

plugins {
    id("dev.flutter.flutter-plugin-loader") version "1.0.0"
    id("com.android.application") version "8.7.0" apply false
    // START: FlutterFire Configuration
    id("com.google.gms.google-services") version("4.3.15") apply false
    // END: FlutterFire Configuration
    id("org.jetbrains.kotlin.android") version "2.1.20" apply false
}

include(":app")
  • plugins 쪽에서 kotlin 최신 버전 명시 (2.1.20)