호환 문제가 생겨서 문의드립니다

e: C:/src/flutterwork/moneymoaflutter/build/kakao_flutter_sdk_common/.transforms/cab7c3b4b5190a1c6364305f8f51f4e5/transformed/out/jars/classes.jar!/META-INF/kakao_flutter_sdk_common_release.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.9.0, ex
pected version is 1.6.0.

이런 호환 에러가 생깁니다.

그래서 릴리스 버전을 다운 받으면 카카오톡 로그인이 안 되어요.

Android Manifest는

<manifest xmlns:android="http://schemas.android.com/apk/res/android">
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

    <application
        android:label="moneymoaflutter"
        android:name="${applicationName}"
        android:icon="@mipmap/ic_launcher">
        <activity
            android:name=".MainActivity"
            android:exported="true"
            android:launchMode="singleTop"
            android:theme="@style/LaunchTheme"
            android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
            android:hardwareAccelerated="true"
            android:windowSoftInputMode="adjustResize"
            android:screenOrientation="portrait">
            <!-- Specifies an Android theme to apply to this Activity as soon as
                 the Android process has started. This theme is visible to the user
                 while the Flutter UI initializes. After that, this theme continues
                 to determine the Window background behind the Flutter UI. -->
            <meta-data
              android:name="io.flutter.embedding.android.NormalTheme"
              android:resource="@style/NormalTheme"
              />
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>

            <intent-filter>
                <action android:name="android.intent.action.VIEW"/>
                <category android:name="android.intent.category.DEFAULT"/>
                <category android:name="android.intent.category.BROWSABLE"/>
                <data android:scheme="kakao610a6471c56dd6a5a1fa71ccc4718c18" android:host="oauth"/>
            </intent-filter>
        </activity>
        <!-- Don't delete the meta-data below.
             This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
        <meta-data
            android:name="flutterEmbedding"
            android:value="2" />
    </application>
</manifest>

이렇게 되어있구요.

프로젝트 단위의 빌드 그래들은

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

    dependencies {
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

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

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

tasks.register("clean", Delete) {
    delete rootProject.buildDir
}

이렇게 되어있습니다.

그리고 gradle-wrapper.properties는

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-all.zip

이렇게 되어있습니다.

그리고 앱 단위의 빌드 그래들은

plugins {
    id "com.android.application"
    id "kotlin-android"
    id "dev.flutter.flutter-gradle-plugin"
}

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

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
    flutterVersionCode = '1'
}

def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
    flutterVersionName = '1.0'
}

android {
    namespace "com.example.moneymoaflutter"
    compileSdkVersion flutter.compileSdkVersion
    ndkVersion flutter.ndkVersion

    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.example.moneymoaflutter"
        // You can update the following values to match your application needs.
        // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
        minSdkVersion 21
        targetSdkVersion flutter.targetSdkVersion
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
    }

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

이렇게 되어있습니다. 혹시 원인을 아시나요?

어떻게 해결해야 될지 궁금합니다.

안녕하세요.

flutter.compileSdkVersion
flutter.targetSdkVersion 이 어떻게 될까요?

defaultConfig {
    // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
    applicationId "com.example.moneymoaflutter"
    // You can update the following values to match your application needs.
    // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
    minSdkVersion 21
    targetSdkVersion flutter.targetSdkVersion
    versionCode flutterVersionCode.toInteger()
    versionName flutterVersionName
} targetSdk는 flutter 내부적으로 자동으로 등록됩니다. 만약 정확한 targetSdk가 필요하다면 정해주시는 sdk 버전으로 정해보겠습니다.컴파일도 같이 정해보겠습니다. 보통 local.properties에 정보가 있다고 하는데 이 파일에 가도 버전 내용이 없습니다.

우선 33으로 지정하여 테스트 부탁드립니다.
본건의 경우 프로젝트 및 IDE 설정에 의해 발생하는 케이스라 gradle 설정 또는 android studio 의 kotlin 버전에 의해 영향 받을 수 있습니다.

33으로 해도 같은 에러가 뜹니다.

e: C:/src/flutterwork/moneymoaflutter/build/kakao_flutter_sdk_common/.transforms/cab7c3b4b5190a1c6364305f8f51f4e5/transformed/out/jars/classes.jar!/META-INF/kakao_flutter_sdk_common_release.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.9.0, ex
pected version is 1.6.0.

제공되는 샘플 프로젝트로 테스트 부탁드리며, 설정 내용 비교 부탁드립니다.

https://github.com/kakao/kakao_flutter_sdk

샘플프로젝트는 ext.kotlin_version = '1.6.10' 로 되어 있으나 1.9.0으로 변경 하신 뒤 빌드해도 정상 동작합니다.

샘플프로젝트 또한 동작하지 않는다면 IDE와 kotlin이 최신 버전인지 확인 부탁드립니다.

두 개 전부 최신 버전이고 그대로 에러가 뜹니다.
ext.kotlin_version = '1.9.0’이면 거의 최신 안정화 버전입니다.
2023.1.1. Hedgehog 최신 안정화 안드로이드 스튜디오입니다.

그래도

e: C:/src/flutterwork/moneymoaflutter/build/kakao_flutter_sdk_common/.transforms/cab7c3b4b5190a1c6364305f8f51f4e5/transformed/out/jars/classes.jar!/META-INF/kakao_flutter_sdk_common_release.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.9.0, ex
pected version is 1.6.0.

똑같은 이슈가 생깁니다.

샘플 프로젝트에서도 오류 발생하신다는건가요?

네네 맞아요 위의 에러는 제 원래 프로젝트 에러이고

주신 예시 프로젝트에서는

e: C:/src/flutterwork/test1/build/kakao_flutter_sdk_common/.transforms/89c54e49300266e705d674fa1542e992/transformed/out/jars/classes.jar!/META-INF/kakao_flutter_sdk_common_release.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.9.0, expected ver
sion is 1.5.1.

이런 에러가 뜹니다.

물론 1.9.0을 적용했습니다.

buildscript {
ext.kotlin_version = ‘1.9.0’
repositories {
google()
mavenCentral()
}

dependencies {
    classpath 'com.android.tools.build:gradle:7.1.3'
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}

}

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

rootProject.buildDir = ‘…/build’
subprojects {
project.buildDir = “${rootProject.buildDir}/${project.name}”
}
subprojects {
project.evaluationDependsOn(‘:app’)
}

tasks.register(“clean”, Delete) {
delete rootProject.buildDir
}

일반적인 flutter create '프로젝트이름’으로 프로젝트를 생성했을 때 호환 에러가 없어야 될 것 같습니다. 이렇게 특정 예시로 된다고 해도 새로 업그레이드 되는 것에 적용이 어려워지기 때문에. 일단 예시도 에러가 떠서. 혹시 새로 생성한 프로젝트로 호환 에러를 없앤 예시 프로젝트는 없나요?

Hedgehog AGP 8 사용하고 계셨군요
제공된 샘플 코드는 7 기준이라 바로 사용하실수 없습니다.
classpath 'com.android.tools.build:gradle:8.2.0' 이상 설정하시면 빌드 되실것 같은데요.

Hedgehog 설치해보고 말씀 드리겠습니다.
그리고, 샘플코드는 보강하도록 하겠습니다.

넵 감사합니다. 다 되면 연락주시면 제가 테스트 해볼게요. 행복하고 좋은 하루 되세요

혹시 답변까지 기간을 알 수 있을까요?

안녕하세요.

Hedgehog, flutter 기본 프로젝트에서 ext.kotlin_version = ‘1.9.0’ 지정하여 정상 빌드 확인하였습니다.

따라서, 다른 문제로 보이며 빌드 가능한 전체 프로젝트 파일을 공유해 주시면 추가 확인해 보도록 하겠습니다.


다른이야기지만, Android Studio와 flutter sdk를 모두 최신버전으로 새로 설치 하였을 때,
flutter 기본 프로젝트 생성하면, kotlin은 1.7.10’, gradle은 7.5 로 생성됩니다.
8.x가 default로 잡히신게 맞는지도 확인 부탁드립니다.

1개의 좋아요

ext.kotlin_version = ‘1.7.10’
distributionUrl=https://services.gradle.org/distributions/gradle-7.5-all.zip

새로 생성하니까 이렇게 나오네요.

agp가 8.x인지 물어보신 것 같아서

build.gradle을 보면

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

    dependencies {
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

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

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

tasks.register("clean", Delete) {
    delete rootProject.buildDir
}

이렇게 나와서 agp에 대한 내용이 없어요. 저는 새로 프로젝트를 생성하고 적용해서 빌드하면 똑같은 에러가 뜨네요

e: C:/src/flutterwork/moneymoaapp/build/kakao_flutter_sdk_common/.transforms/0fea24868524edbfd1567665a4fe8bae/transformed/out/jars/classes.jar!/META-INF/kakao_flutter_sdk_common_release.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.9.0, expect
ed version is 1.6.0.

라이브러리 영향이 대부분 일 것이라고 생각해서

name: moneymoaflutter
description: "A new Flutter project."
# The following line prevents the package from being accidentally published to
# pub.dev using `flutter pub publish`. This is preferred for private packages.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev

# The following defines the version and build number for your application.
# A version number is three numbers separated by dots, like 1.2.43
# followed by an optional build number separated by a +.
# Both the version and the builder number may be overridden in flutter
# build by specifying --build-name and --build-number, respectively.
# In Android, build-name is used as versionName while build-number used as versionCode.
# Read more about Android versioning at https://developer.android.com/studio/publish/versioning
# In iOS, build-name is used as CFBundleShortVersionString while build-number is used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
# In Windows, build-name is used as the major, minor, and patch parts
# of the product and file versions while build-number is used as the build suffix.
version: 1.0.0+1

environment:
  sdk: '>=2.18.2 <4.0.0'

# Dependencies specify other packages that your package needs in order to work.
# To automatically upgrade your package dependencies to the latest versions
# consider running `flutter pub upgrade --major-versions`. Alternatively,
# dependencies can be manually updated by changing the version numbers below to
# the latest version available on pub.dev. To see which dependencies have newer
# versions available, run `flutter pub outdated`.
dependencies:
  flutter:
    sdk: flutter
  get: ^4.6.6
  flutter_native_splash: ^2.3.8
  shared_preferences: ^2.2.2
  geolocator: ^10.1.0
  url_launcher: ^6.2.2
  # The following adds the Cupertino Icons font to your application.
  # Use with the CupertinoIcons class for iOS style icons.
  cupertino_icons: ^1.0.2
  app_settings: ^5.1.1
  kakao_flutter_sdk: ^1.7.0
  intl: ^0.19.0
  share_plus: ^7.2.1

dev_dependencies:
  flutter_test:
    sdk: flutter

  # The "flutter_lints" package below contains a set of recommended lints to
  # encourage good coding practices. The lint set provided by the package is
  # activated in the `analysis_options.yaml` file located at the root of your
  # package. See that file for information about deactivating specific lint
  # rules and activating additional ones.
  flutter_lints: ^3.0.1

# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec

# The following section is specific to Flutter packages.
flutter:

  # The following line ensures that the Material Icons font is
  # included with your application, so that you can use the icons in
  # the material Icons class.
  uses-material-design: true

  assets:
    - assets/images/
    - assets/images/logo/
    - assets/images/splash/
    - assets/images/btn/
    - assets/images/icon/

  # An image asset can refer to one or more resolution-specific "variants", see
  # https://flutter.dev/assets-and-images/#resolution-aware

  # For details regarding adding assets from package dependencies, see
  # https://flutter.dev/assets-and-images/#from-packages

  # To add custom fonts to your application, add a fonts section here,
  # in this "flutter" section. Each entry in this list should have a
  # "family" key with the font family name, and a "fonts" key with a
  # list giving the asset and other descriptors for the font. For
  # example:
  # fonts:
  #   - family: Schyler
  #     fonts:
  #       - asset: fonts/Schyler-Regular.ttf
  #       - asset: fonts/Schyler-Italic.ttf
  #         style: italic
  #   - family: Trajan Pro
  #     fonts:
  #       - asset: fonts/TrajanPro.ttf
  #       - asset: fonts/TrajanPro_Bold.ttf
  #         weight: 700
  #
  # For details regarding fonts from package dependencies,
  # see https://flutter.dev/custom-fonts/#from-packages

pubspec.yaml 파일이에요

flutter가 최신 버전이고 안드로이드도 Hedgehog라서 문제가 뭔지 잘 모르겠네요. 전체 프로젝트 파일은 공유가 어려울 수도 있는데 안드로이드 설정 파일은 드릴 수 있을 것 같아요.
android.zip (8.4 MB)

제공해 주신 파일로도 이상 없이 빌드 가능합니다.
개발환경 문제로 보이는데요 저희쪽 설정과 비교 한번 해보시겠어요?

image
올려주신 버전은 플러터 최신 업데이트 버전이 아니라서요. 나머지 모든 라이브러리를 교체해야 해서.
저의 이 개발환경으로 셋팅은 어려운 것인가요?

그리고 3.10.5로 변경하면 android studio의 jdk나 java 버전을 사용할 수 없다고 떠서요. 저는 지금 jdk-21을 쓰고 있습니다.