반응형
Notice
Recent Posts
Link
«   2024/12   »
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31
Archives
Today
Total
관리 메뉴

500error

Execution failed for task ':flutter_sms:compileReleaseKotlin' 해결 본문

안드로이드/플러터

Execution failed for task ':flutter_sms:compileReleaseKotlin' 해결

Internal Server Error 2024. 12. 19. 15:53
반응형

디버깅 해봤더니

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':flutter_sms:compileReleaseKotlin'.
> 'compileReleaseJavaWithJavac' task (current target is 1.8) and 'compileReleaseKotlin' task (current target is 17) jvm target compatibility should be set to the same Java version.
  Consider using JVM toolchain: https://kotl.in/gradle/jvm/toolchain


* 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.
> Get more help at https://help.gradle.org.

BUILD FAILED in 33s
Running Gradle task 'assembleRelease'...                           34.6s
Gradle task assembleRelease failed with exit code 1

이런식으로 떴다

 

 

 

보고 gradle.build파일을 확인해봤더니

 

plugins {
    id "com.android.application"
    // START: FlutterFire Configuration
    id 'com.google.gms.google-services'
    // END: FlutterFire Configuration
    id "kotlin-android"
    // The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins.
    id "dev.flutter.flutter-gradle-plugin"
}

kotlin {
    jvmToolchain(17) // Kotlin JVM 타겟을 17로 설정
}

android {
    namespace = "com.example.practice"
    compileSdk = 34
    ndkVersion "26.1.10909125"

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_17
        targetCompatibility JavaVersion.VERSION_17
        coreLibraryDesugaringEnabled true
    }

    kotlinOptions {
//        jvmTarget = "17"
        jvmTarget = JavaVersion.VERSION_17.toString()
    }

    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId = "com.telalarm.wakeupcall"
        // 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.debug
        }
    }
}


flutter {
    source = "../.."
}


dependencies {
    coreLibraryDesugaring "com.android.tools:desugar_jdk_libs:2.1.3"
    implementation 'com.google.firebase:firebase-analytics'
    implementation platform('com.google.firebase:firebase-bom:33.7.0')
}
apply plugin: 'com.google.gms.google-services'

 

 

제대로 설정이 되어있었다.


해결방법은 android studio 기준

 

파란색으로 클릭해놓은 곳 아래에 보면

 

여기에 들어가서 Flutter Plugins에 들어간다.

 

flutter_sms폴더를 찾아서
android/build.gradle파일에 들어가서

 

group 'com.example.flutter_sms'
version '1.0-SNAPSHOT'

buildscript {
    ext.kotlin_version = '1.5.20'
    repositories {
        google()
        jcenter()
    }

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

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

apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'

android {
    compileSdkVersion 34  // 최신 compileSdkVersion으로 설정

    sourceSets {
        main.java.srcDirs += 'src/main/kotlin'
    }

    defaultConfig {
        minSdkVersion 16
        targetSdkVersion 34  // targetSdkVersion을 최신으로 설정
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    lintOptions {
        disable 'InvalidPackage'
    }
    
    //-----------------------------------------------------

    // Java 및 Kotlin 호환성 설정
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_17
        targetCompatibility JavaVersion.VERSION_17
    }

    kotlinOptions {
        jvmTarget = "17"  // Kotlin을 Java 17에 맞게 설정
    }
}

//---------------------------------------------------------

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}

 

 

저렇게 추가해주면 된다

반응형
Comments