Flutter build 에러

Android
ID : 1108382

exception: c:\Users\user13\AppData\Local\Pub\Cache\hosted\pub.dev\kakao_flutter_sdk_common-1.9.5\android\src\main\kotlin\com\kakao\sdk\flutter\KakaoFlutterSdkPlugin.kt:40:40: error: unresolved reference: Utility
exception: result.success(Utility.getAppVer(it))
exception: ^
exception: c:\Users\user13\AppData\Local\Pub\Cache\hosted\pub.dev\kakao_flutter_sdk_common-1.9.5\android\src\main\kotlin\com\kakao\sdk\flutter\KakaoFlutterSdkPlugin.kt:50:36: error: unresolved reference: Utility
exception: result.success(Utility.getKeyHash(it))
exception: ^
exception: c:\Users\user13\AppData\Local\Pub\Cache\hosted\pub.dev\kakao_flutter_sdk_common-1.9.5\android\src\main\kotlin\com\kakao\sdk\flutter\KakaoFlutterSdkPlugin.kt:56:36: error: unresolved reference: Utility
exception: result.success(Utility.getKAHeader(it))
exception: ^
exception: c:\Users\user13\AppData\Local\Pub\Cache\hosted\pub.dev\kakao_flutter_sdk_common-1.9.5\android\src\main\kotlin\com\kakao\sdk\flutter\KakaoFlutterSdkPlugin.kt:96:26: error: unresolved reference: Utility
exception: if (!Utility.isKakaoTalkInstalled(activity, talkPackageName)) {
exception: ^
exception: c:\Users\user13\AppData\Local\Pub\Cache\hosted\pub.dev\kakao_flutter_sdk_common-1.9.5\android\src\main\kotlin\com\kakao\sdk\flutter\KakaoFlutterSdkPlugin.kt:117:36: error: unresolved reference: Utility
exception: result.success(Utility.isKakaoTalkInstalled(it, talkPackageName))
exception: ^
exception: c:\Users\user13\AppData\Local\Pub\Cache\hosted\pub.dev\kakao_flutter_sdk_common-1.9.5\android\src\main\kotlin\com\kakao\sdk\flutter\KakaoFlutterSdkPlugin.kt:126:36: error: unresolved reference: Utility
exception: result.success(Utility.isKakaoNaviInstalled(it, naviPackageName))
exception: ^
exception: c:\Users\user13\AppData\Local\Pub\Cache\hosted\pub.dev\kakao_flutter_sdk_common-1.9.5\android\src\main\kotlin\com\kakao\sdk\flutter\KakaoFlutterSdkPlugin.kt:140:22: error: unresolved reference: Utility
exception: if (!Utility.isKakaoTalkInstalled(activity, talkPackageName)) {
exception: ^
exception: c:\Users\user13\AppData\Local\Pub\Cache\hosted\pub.dev\kakao_flutter_sdk_common-1.9.5\android\src\main\kotlin\com\kakao\sdk\flutter\KakaoFlutterSdkPlugin.kt:250:21: error: unresolved reference: Utility
exception: Utility.naviBaseUriBuilder(scheme, authority, appKey, extras, params).build()
exception: ^
exception: c:\Users\user13\AppData\Local\Pub\Cache\hosted\pub.dev\kakao_flutter_sdk_common-1.9.5\android\src\main\kotlin\com\kakao\sdk\flutter\KakaoFlutterSdkPlugin.kt:271:21: error: unresolved reference: Utility
exception: Utility.naviBaseUriBuilder(scheme, authority, appKey, extras, params).build()
exception: ^
exception: c:\Users\user13\AppData\Local\Pub\Cache\hosted\pub.dev\kakao_flutter_sdk_common-1.9.5\android\src\main\kotlin\com\kakao\sdk\flutter\KakaoFlutterSdkPlugin.kt:287:40: error: unresolved reference: Utility
exception: result.success(Utility.platformId(it))
exception: ^
exception: c:\Users\user13\AppData\Local\Pub\Cache\hosted\pub.dev\kakao_flutter_sdk_common-1.9.5\android\src\main\kotlin\com\kakao\sdk\flutter\TalkAuthCodeActivity.kt:37:27: error: unresolved reference: Utility
exception: val loginIntent = Utility.talkLoginIntent(
exception: ^
exception: c:\Users\user13\AppData\Local\Pub\Cache\hosted\pub.dev\kakao_flutter_sdk_common-1.9.5\android\src\main\kotlin\com\kakao\sdk\flutter\TalkAuthCodeActivity.kt:40:28: error: unresolved reference: Utility
exception: “$sdkVersion ${Utility.getKAHeader(this)}”,
exception: ^
Font asset “MaterialIcons-Regular.otf” was tree-shaken, reducing it from 1645184 to 2532 bytes (99.8% reduction). Tree-shaking can be disabled by providing the --no-tree-shake-icons flag when building your app.

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ‘:kakao_flutter_sdk_common:compileReleaseKotlin’.

A failure occurred while executing org.jetbrains.kotlin.compilerRunner.GradleCompilerRunnerWithWorkers$GradleKotlinCompilerWorkAction
Compilation error. See log for more details

  • 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 FAILED in 1m 7s
Running Gradle task ‘assembleRelease’… 68.7s
Gradle task assembleRelease failed with exit code 1

빌드를 진행하는데 계속해서 이런 에러가 나네요

안녕하세요.

…/Pub/Cache 폴더 초기화 하신 뒤, pubspec.lock 지우시고 패키지 다시 받아보시겠어요?

그래도 안되네요 ㅎㅎ

pubspec.yaml, build.gradle, settings.gradle 파일내용 공유 부탁드립니다.

name: orda
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: '>=3.3.4 <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
  kakao_flutter_sdk_user: ^1.9.5 # 카카오 로그인 API 패키지
  kakao_flutter_sdk_share: ^1.9.5 # 카카오톡 공유 API 패키지
  card_swiper: ^3.0.1
  path_provider: ^2.1.3  # 최신 버전으로 업데이트할 수 있습니다.

  # The following adds the Cupertino Icons font to your application.
  # Use with the Cuper tinoIcons class for iOS style icons.
  cupertino_icons: ^1.0.6
  http: ^1.2.1
  provider: ^6.1.2
  flutter_svg: ^2.0.10+1
  connectivity_plus: ^6.0.3
  shared_preferences: ^2.2.3
  flutter_secure_storage: ^4.2.1
  google_sign_in: ^6.2.1
  crypto: ^3.0.3
  flutter_pannable_rating_bar: ^2.7.2+1
  flutter_naver_map: ^1.2.3+1
  geolocator: ^12.0.0
  permission_handler: ^11.3.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.0
# 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/App_Key.json


  # To add assets to your application, add an assets section, like this:

  #   - images/a_dot_burr.jpeg
  #   - images/a_dot_ham.jpeg

  # 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

  fonts:
    - family: Pretendard
      fonts:
        - asset: assets/fonts/Pretendard-Thin.ttf
          weight: 100
        - asset: assets/fonts/Pretendard-ExtraLight.ttf
          weight: 200
        - asset: assets/fonts/Pretendard-Light.ttf
          weight: 300
        - asset: assets/fonts/Pretendard-Regular.ttf
          weight: 400
        - asset: assets/fonts/Pretendard-Medium.ttf
          weight: 500
        - asset: assets/fonts/Pretendard-SemiBold.ttf
          weight: 600
        - asset: assets/fonts/Pretendard-Bold.ttf
          weight: 700
        - asset: assets/fonts/Pretendard-ExtraBold.ttf
          weight: 800
        - asset: assets/fonts/Pretendard-Black.ttf
          weight: 900

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.sinabro.orda"
    compileSdk 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.sinabro.orda"
        // 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 23
        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 {
    implementation 'com.google.android.gms:play-services-location:19.0.1' // geolocator가 사용하는 의존성 추가
    implementation "com.kakao.sdk:v2-user:2.8.6" // 카카오 로그인
    implementation "com.kakao.sdk:v2-talk:2.8.6" // 친구, 메시지(카카오톡)
    implementation "com.kakao.sdk:v2-story:2.8.6" // 카카오스토리
    implementation "com.kakao.sdk:v2-link:2.8.6" // 메시지(카카오링크)
}

pluginManagement {
    def flutterSdkPath = {
        def properties = new Properties()
        file("local.properties").withInputStream { properties.load(it) }
        def flutterSdkPath = properties.getProperty("flutter.sdk")
        assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
        return flutterSdkPath
    }
    settings.ext.flutterSdkPath = flutterSdkPath()

    includeBuild("${settings.ext.flutterSdkPath}/packages/flutter_tools/gradle")

    repositories {
        google()
        mavenCentral()
        gradlePluginPortal()
        maven { url 'https://devrepo.kakao.com/nexus/content/groups/public/' }
    }
}

plugins {
    id "dev.flutter.flutter-plugin-loader" version "1.0.0"
    id "com.android.application" version "7.3.0" apply false
    id "org.jetbrains.kotlin.android" version "1.9.25" apply false
}

include ":app"

allprojects {
    repositories {
        google()
        mavenCentral()
        maven { url 'https://devrepo.kakao.com/nexus/content/groups/public/' }
    }
}

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

tasks.register("clean", Delete) {
    delete rootProject.buildDir
}
여기있습니다.

java.lang.IllegalArgumentException: this and base files have different roots: C:\Users\user13\AppData\Local\Pub\Cache\hosted\pub.dev\kakao_flutter_sdk_common-1.9.5\android\src\main\kotlin\com\kakao\sdk\flutter\AppsHandlerActivity.kt and D:\project_\ORDA\android.
at kotlin.io.FilesKt__UtilsKt.toRelativeString(Utils.kt:117) 이런 에러가 나네요 ㅎㅎ

카카오 SDK 보다는 프로젝트 경로 때문으로 보이는데요
우선 프로젝트를 D에서 C 드라이브로 이동하신 뒤 pub clean 하시고 빌드해 보시겠어요?

제가 여러 환경에서 진행중인데 다른 피시에선 F에서 프로젝트를 진행하고있고
다른 PC에선 E하는데 두 pc에선 문제가 없는데 저 pc에서만 문제가 생깁니다.

깃으로 프로젝트를 관리하고있는데 프로젝트 경로가 문제 유발에 원인이 될 수 있을까요…?



정상 동작하는 PC의 local.properties 파일과 문제가 발생중인 곳의 파일 내용이 같을까요?

네 그렇습니다.

안녕하세요

빈 프로젝트에 카카오SDK만 추가했을 때도 동일한 에러가 발생하는지 확인이 가능할까요?

dependencies {
    implementation 'com.google.android.gms:play-services-location:19.0.1' // geolocator가 사용하는 의존성 추가
    implementation "com.kakao.sdk:v2-user:2.8.6" // 카카오 로그인
    implementation "com.kakao.sdk:v2-talk:2.8.6" // 친구, 메시지(카카오톡)
    implementation "com.kakao.sdk:v2-story:2.8.6" // 카카오스토리
    implementation "com.kakao.sdk:v2-link:2.8.6" // 메시지(카카오링크)
}

이슈와는 별개로 첨부해주신 내용을 확인했을 때 안드로이드용 카카오SDK의 의존성이 추가되어있는 것으로 보이는데요. 플러터용 카카오SDK를 사용할 때는 별도의 안드로이드 / iOS용 SDK의 의존성을 추가할 필요가 없어서 이 부분은 제거하시는게 좋을 것 같아요

없는 상태에서 빌드를하여도 같은에러가 나서 이 의존성을 추가했던겁니다…ㅜㅜ

첨부해주신 에러 메시지를 확인했을 때는 코틀린 버전이 호환되지 않아서 에러가 발생하는 것으로 보이고 그 원인이 맞다면 모든 개발 환경에서 동일하게 에러가 발생해야할 것 같은데요, 특정 PC 환경에서만 에러가 발생하고 있다고 해서 로컬 캐시의 영항을 받고 있는 것 같아요.

말씀주신 상황과 에러 메시지를 종합해봤을 때 에러 발생하고 있는 개발 환경의 gradle 캐시를 삭제해보는 방법과 kotlin 버전을 낮추는 방법이 있을 것 같아요.

조금 번거롭겠지만 확인 부탁드리겠습니다.

참고로 비슷한 에러 사례인 것 같아서 공유드립니다.

1개의 좋아요