본문 바로가기

Flutter

플러터 앱 실제 안드로이드폰 에서 디버깅시 에러 발생 [shared_preferences_android:compileDebugJavaWithJavac]

반응형

플러터(Flutter) 앱을 안드로이드, 아이폰 용으로 프로젝트 셋팅후 시작하였음.

크롬으로 디버깅시는 에러없이 잘 동작함

실제 안드로이드 폰으로 디버깅시 에러 발생하고 동작안함.

 

스마트폰 장치 선택

 

안드로이드 스튜디오 에러 내용

 

 

클로드에게 질문하고 여러번 테스트 해봤는데 해결안됨.

ChatGTP o1에게 질문하고 실해하여 해결됨. 이때  o1 캔버스로 질문 하였음.

 

안드로이드 스튜디오를 최신버젼으로 설치하고 실행했는데 에러 내용은 대충 AGP를 최소 8.2.1 이상으로 하거나 자바JDK를 17로 낮추라는것임.

 

결론적으로 AGP에 관계된 모든 버젼을  8.2.1로 맞추니 에러 없어 성공함.

 

 

반응형

 

개발환경

JAVA_HOME : C:\Program Files\Java\jdk-11

테스트 안드로이드 폰 : SM G996N (mobile) • R3CR10ZPPCL • android-arm64  • Android 14 (API 34)

flutter doctor --verbose
[√] Flutter (Channel stable, 3.27.2, on Microsoft Windows [Version 10.0.22631.4751], locale ko-KR)
    • Flutter version 3.27.2 on channel stable at C:\flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 68415ad1d9 (3 weeks ago), 2025-01-13 10:22:03 -0800
    • Engine revision e672b006cb
    • Dart version 3.6.1
    • DevTools version 2.40.2
[√] Windows Version (Installed version of Windows is version 10 or higher)
[√] Android toolchain - develop for Android devices (Android SDK version 35.0.0)
    • Android SDK at C:\Users\jjj\AppData\Local\Android\sdk
    • Platform android-35, build-tools 35.0.0
    • Java binary at: C:\Program Files\Android\Android Studio\jbr\bin\java
    • Java version OpenJDK Runtime Environment (build 21.0.4+-12508038-b607.1)
    • All Android licenses accepted.
[√] Chrome - develop for the web
    • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe
[√] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.12.4)
    • Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community
    • Visual Studio Community 2022 version 17.12.35707.178
    • Windows 10 SDK version 10.0.22621.0
[√] Android Studio (version 2024.2)
    • Android Studio at C:\Program Files\Android\Android Studio
    • Flutter plugin can be installed from:
       https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
       https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 21.0.4+-12508038-b607.1)
[√] VS Code (version 1.96.4)
    • VS Code at C:\Users\jjj\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension can be installed from:
       https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter
[√] Connected device (4 available)
    • SM G996N (mobile) • R3CR10ZPPCL • android-arm64  • Android 14 (API 34)
    • Windows (desktop) • windows     • windows-x64    • Microsoft Windows [Version 10.0.22631.4751]
    • Chrome (web)      • chrome      • web-javascript • Google Chrome 132.0.6834.160
    • Edge (web)        • edge        • web-javascript • Microsoft Edge 132.0.2957.127
[√] Network resources
    • All expected network resources are available.
• No issues found!

 

 

에러 내용

Launching lib\main.dart on SM G996N in debug mode...
Running Gradle task 'assembleDebug'...
Warning: SDK processing. This version only understands SDK XML versions up to 3 but an SDK XML file of version 4 was encountered. This can happen if you use versions of Android Studio and the command-line tools that were released at different times.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':shared_preferences_android:compileDebugJavaWithJavac'.
> Could not resolve all files for configuration ':shared_preferences_android:androidJdkImage'.
   > Failed to transform core-for-system-modules.jar to match attributes {artifactType=_internal_android_jdk_image, org.gradle.libraryelements=jar, org.gradle.usage=java-runtime}.
      > Execution failed for JdkImageTransform: C:\Users\jjj\AppData\Local\Android\sdk\platforms\android-34\core-for-system-modules.jar.
         > Error while executing process C:\Program Files\Android\Android Studio\jbr\bin\jlink.exe with arguments {--module-path C:\Users\jjj\.gradle\caches\transforms-3\c7f5d563e1877cd5931fe99b4d6b075f\transformed\output\temp\jmod --add-modules java.base --output C:\Users\jjj\.gradle\caches\transforms-3\c7f5d563e1877cd5931fe99b4d6b075f\transformed\output\jdkImage --disable-plugin system-modules}
* 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 26s
┌─ Flutter Fix ────────────────────────────────────────────────────────────────────────────────────┐
│ [!] This is likely due to a known bug in Android Gradle Plugin (AGP) versions less than 8.2.1,   │
│ when                                                                                             │
│   1. setting a value for SourceCompatibility and                                                 │
│   2. using Java 21 or above.                                                                     │
│ To fix this error, please upgrade your AGP version to at least 8.2.1. The version of AGP that    │
│ your project uses is likely defined in:                                                          │
│ E:\work\Flutter\ibalance\android\settings.gradle,                                                │
│ in the 'plugins' closure (by the number following "com.android.application").                    │
│  Alternatively, if your project was created with an older version of the templates, it is likely │
│ in the buildscript.dependencies closure of the top-level build.gradle:                           │
│ E:\work\Flutter\ibalance\android\build.gradle,                                                   │
│ as the number following "com.android.tools.build:gradle:".                                       │
│                                                                                                  │
│ For more information, see:                                                                       │
│ https://issuetracker.google.com/issues/294137077                                                 │
│ https://github.com/flutter/flutter/issues/156304                                                 │
└──────────────────────────────────────────────────────────────────────────────────────────────────┘
Error: Gradle task assembleDebug failed with exit code 1

 

 

 

해결법 : 4개 파일 설정 변경

 

파일1 :  android/build.gradle

 - javaVersion = JavaVersion.VERSION_17
 - classpath 'cohttp://m.android.tools.build:gradle:8.2.1' // 7.3.1에서 8.2.1로 업그레이드
 - classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.22'  // Kotlin 버전도 업그레이드

buildscript {
    ext {
        //javaVersion = JavaVersion.VERSION_21
        javaVersion = JavaVersion.VERSION_17
    }
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        //classpath 'com.android.tools.build:gradle:7.3.1'
        //classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.10'

        classpath 'com.android.tools.build:gradle:8.2.1'  // 7.3.1에서 8.2.1로 업그레이드
        classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.22'  // Kotlin 버전도 업그레이드
    }
}

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
}

 

 

파일2 :  android/settings.gradle

 - id "com.android.application" version "8.2.1" apply false

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
    }()

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

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

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

include ":app"

 

 

파일3 :  android/gradle/wrapper/gradle-wrapper.properties

 - distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-all.zip

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

 

 

파일4 : android/app/build.gradle

 - sourceCompatibility = JavaVersion.VERSION_17
 - targetCompatibility = JavaVersion.VERSION_17

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

android {
    namespace = "com.sample.id"
    compileSdk = flutter.compileSdkVersion
    ndkVersion = flutter.ndkVersion

    compileOptions {
        //sourceCompatibility = JavaVersion.VERSION_21
        //targetCompatibility = JavaVersion.VERSION_21

        sourceCompatibility = JavaVersion.VERSION_17
        targetCompatibility = JavaVersion.VERSION_17
    }

    kotlinOptions {
        jvmTarget = '17'
    }

    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId = "com.daegupre.ibalance.ibalance"
        // You can update the following values to match your application needs.
        // For more information, see: https://flutter.dev/to/review-gradle-config.
        minSdk = flutter.minSdkVersion
        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 = "../.."
}

 

 

 

실제 안드로이드폰 디버깅시 로그

안드로드폰 디버깅

Launching lib\main.dart on SM G996N in debug mode...
Running Gradle task 'assembleDebug'...
√ Built build\app\outputs\flutter-apk\app-debug.apk
I/flutter (27077): [IMPORTANT:flutter/shell/platform/android/android_context_vk_impeller.cc(60)] Using the Impeller rendering backend (Vulkan).
Debug service listening on ws://127.0.0.1:10724/aZnRddBgI2M=/ws
Syncing files to device SM G996N...
I/ViewRootImpl@3f4d4fa[MainActivity](27077): onDisplayChanged oldDisplayState=2 newDisplayState=2
I/BLASTBufferQueue(27077): [SurfaceView[com.sample.id.id/com.sample.id.id.MainActivity]@0#1](f:0,a:0,s:0) onFrameAvailable the first frame is available
D/SurfaceView@db6a6ec(27077): 230074092 setAlpha: alpha=1.0
I/SurfaceView(27077): 230074092 Changes: creating=false format=false size=false visible=false alpha=true hint=false visible=false left=false top=false z=false attached=true lifecycleStrategy=false
I/SurfaceView@db6a6ec(27077): 230074092 Cur surface: Surface(name=null)/@0x61a585a
I/SurfaceView@db6a6ec(27077): updateSurface: mVisible = true mSurface.isValid() = true
I/SurfaceView@db6a6ec(27077): updateSurface: mSurfaceCreated = true surfaceChanged = false visibleChanged = false
I/SurfaceView(27077): 230074092 surfaceRedrawNeeded
I/SurfaceView(27077): 230074092 finishedDrawing
V/SurfaceView@db6a6ec(27077): Layout: x=0 y=0 w=1080 h=2265, frame=Rect(0, 0 - 1080, 2265)
I/ViewRootImpl@3f4d4fa[MainActivity](27077): Setup new sync=wmsSync-ViewRootImpl@3f4d4fa[MainActivity]#2
I/ViewRootImpl@3f4d4fa[MainActivity](27077): Creating new active sync group ViewRootImpl@3f4d4fa[MainActivity]#3
I/ViewRootImpl@3f4d4fa[MainActivity](27077): registerCallbacksForSync syncBuffer=false
D/SurfaceView(27077): 230074092 updateSurfacePosition RenderWorker, frameNr = 1, position = [0, 0, 1080, 2265] surfaceSize = 1080x2265
I/SurfaceView@db6a6ec(27077): uSP: rtp = Rect(0, 0 - 1080, 2265) rtsw = 1080 rtsh = 2265
I/SurfaceView@db6a6ec(27077): onSSPAndSRT: pl = 0 pt = 0 sx = 1.0 sy = 1.0
I/SurfaceView@db6a6ec(27077): aOrMT: ViewRootImpl@3f4d4fa[MainActivity] t = android.view.SurfaceControl$Transaction@964f467 fN = 1 android.view.SurfaceView.-$$Nest$mapplyOrMergeTransaction:0 android.view.SurfaceView$SurfaceViewPositionUpdateListener.positionChanged:1666 android.graphics.RenderNode$CompositePositionUpdateListener.positionChanged:369 
I/ViewRootImpl@3f4d4fa[MainActivity](27077): mWNT: t=0xb400007c32449f50 mBlastBufferQueue=0xb400007b92452610 fn= 1 mRenderHdrSdrRatio=1.0 caller= android.view.SurfaceView.applyOrMergeTransaction:1598 android.view.SurfaceView.-$$Nest$mapplyOrMergeTransaction:0 android.view.SurfaceView$SurfaceViewPositionUpdateListener.positionChanged:1666 
I/ViewRootImpl@3f4d4fa[MainActivity](27077): Received frameDrawingCallback syncResult=0 frameNum=1.
I/ViewRootImpl@3f4d4fa[MainActivity](27077): mWNT: t=0xb400007c3244cb50 mBlastBufferQueue=0xb400007b92452610 fn= 1 mRenderHdrSdrRatio=1.0 caller= android.view.ViewRootImpl$8.onFrameDraw:13841 android.view.ThreadedRenderer$1.onFrameDraw:792 <bottom of call stack> 
I/ViewRootImpl@3f4d4fa[MainActivity](27077): Setting up sync and frameCommitCallback
I/BLASTBufferQueue(27077): [ViewRootImpl@3f4d4fa[MainActivity]#0](f:0,a:0,s:0) onFrameAvailable the first frame is available
I/ViewRootImpl@3f4d4fa[MainActivity](27077): Received frameCommittedCallback lastAttemptedDrawFrameNum=1 didProduceBuffer=true
D/OpenGLRenderer(27077): CFMS:: SetUp Pid : 27077    Tid : 27111
I/ViewRootImpl@3f4d4fa[MainActivity](27077): reportDrawFinished seqId=0
I/ViewRootImpl@3f4d4fa[MainActivity](27077): handleWindowFocusChanged: 1 0 call from android.view.ViewRootImpl.-$$Nest$mhandleWindowFocusChanged:0
D/ViewRootImpl@3f4d4fa[MainActivity](27077): mThreadedRenderer.initializeIfNeeded()#2 mSurface={isValid=true 0xb400007be24d49b0}
D/InputMethodManagerUtils(27077): startInputInner - Id : 0
I/InputMethodManager(27077): startInputInner - IInputMethodManagerGlobalInvoker.startInputOrWindowGainedFocus
D/InputMethodManagerUtils(27077): startInputInner - Id : 0
I/InsetsController(27077): onStateChanged: host=com.sample.id.id/com.sample.id.id.MainActivity, from=android.view.ViewRootImpl$ViewRootHandler.handleMessageImpl:7209, state=InsetsState: {mDisplayFrame=Rect(0, 0 - 1080, 2400), mDisplayCutout=DisplayCutout{insets=Rect(0, 75 - 0, 0) waterfall=Insets{left=0, top=0, right=0, bottom=0} boundingRect={Bounds=[Rect(0, 0 - 0, 0), Rect(512, 0 - 569, 75), Rect(0, 0 - 0, 0), Rect(0, 0 - 0, 0)]} cutoutPathParserInfo={CutoutPathParserInfo{displayWidth=1080 displayHeight=2400 physicalDisplayWidth=1080 physicalDisplayHeight=2400 density={2.8125} cutoutSpec={M 0, 0 H -10.13333333333333 V 26.66666666666667 H 10.13333333333333 V 0 H 0 Z @dp} rotation={0} scale={1.0} physicalPixelDisplaySizeRatio={1.0}}}}, mRoundedCorners=RoundedCorners{[RoundedCorner{position=TopLeft, radius=90, center=Point(90, 90)}, RoundedCorner{position=TopRight, radius=90, center=Point(990, 90)}, RoundedCorner{position=BottomRight, radius=90, center=Point(990, 2310)}, RoundedCorner{position=BottomLeft, radius=90, center=Point(90, 2310)}]}  mRoundedCornerFrame=Rect(0, 0 - 1080, 2400), mPrivacyIndicatorBounds=PrivacyIndicatorBounds {static bounds=Rect(956, 0 - 1080, 75) rotation=0}, mDisplayShape=DisplayShape{ spec=-311912193 displayWidth=1080 displayHeight=2400 physicalPixelDisplaySizeRatio=1.0 rotation=0 offsetX=0 offsetY=0 scale=1.0}, mSources= { InsetsSource: {fdac0001 mType=navigationBars mFrame=[0,2265][1080,2400] mVisible=true mFlags=[]}, InsetsSource: {fdac0004 mType=systemGestures mFrame=[0,0][0,0] mVisible=true mFlags=[]}, InsetsSource: {fdac0005 mType=mandatorySystemGestures mFrame=[0,2265][1080,2400] mVisible=true mFlags=[]}, InsetsSource: {fdac0006 mType=tappableElement mFrame=[0,2265][1080,2400] mVisible=true mFlags=[]}, InsetsSource: {fdac0024 mType=systemGestures mFrame=[0,0][0,0] mVisible=true mFlags=[]}, InsetsSource: {3 mType=ime mFrame=[0,0][0,0] mVisible=false mFlags=[]}, InsetsSource: {27 mType=displayCutout mFrame=[0,0][1080,75] mVisible=true mFlags=[]}, InsetsSource: {37230000 mType=statusBars mFrame=[0,0][1080,75] mVisible=true mFlags=[]}, InsetsSource: {37230005 mType=mandatorySystemGestures mFrame=[0,0][1080,109] mVisible=true mFlags=[]}, InsetsSource: {37230006 mType=tappableElement mFrame=[0,0][1080,75] mVisible=true mFlags=[]} }
I/InsetsSourceConsumer(27077): applyRequestedVisibilityToControl: visible=false, type=ime, host=com.sample.id.id/com.sample.id.id.MainActivity
I/ViewRootImpl@3f4d4fa[MainActivity](27077): onDisplayChanged oldDisplayState=2 newDisplayState=2
D/ProfileInstaller(27077): Installing profile for com.sample.id.id
I/ViewRootImpl@3f4d4fa[MainActivity](27077): onDisplayChanged oldDisplayState=2 newDisplayState=2

 

 

 

다른글들:

 

[Flutter] 플러터 설치 방법

플러터(Flutter) 설치 방법 정리 입니다.(강의 보고 설치 방법 정리)    1. 플러터(Flutter) 설치Flutter 다운로드 : https://flutter-ko.dev/get-started/install/windows자신의 OS에 맞는 Flutter를 다운로드후 적당한

dtbb.tistory.com

 

데이터 품질관리 GPTs

데이터 품질관리 진단 및 평가를 위한 ChatGPT GPTs 또는 Claude Projects  답변은 2개다 잘 하는데 약간 클로드가 더 잘하는 느낌이다. 특이사항Claude Projects에 177페이지 pdf 파일을 첨부하였더니 knowledg

dtbb.tistory.com

 

반응형