진짜 미친 이슈다 이걸로 이틀을 날려먹었다.
이슈
android 에서 실행하려고 기기 연결하고 flutter run을 하니까 아래와 같은 에러가 떴다.
참고로 android/gradlew를 실행해도 같은 에러가 나온다.
뭔가 밑에서 꼬였나봄
debug로그를 봐도 JAVA_HOME에서 17 잘 찾아져 있고 잘 들어가 있는데 왜 지랄인지 모르겠다.
```
> flutter run
The supplied javaHome seems to be invalid. I cannot find the java executable. Tried location: C:\Program Files\Java\jdk-11.0.16.1\bin\java.exe
```
flutter doctor를 해도 다 멀쩡하게 잘 나왔다.
내가 해본 것
1. jdk 다 지우고 17만 재설치 , android studio 재설치 및 sdk 업데이트
- https://docs.flutter.dev/get-started/install/windows/mobile#configure-android-development
2. JAVA_HOME 환경변수, Path 환경변수 설정
- Path에 %JAVA_HOME%\bin 설정하고
- 그 외에 java들어간 oracle path는 지우기
3. java -version 확인
JAVA_HOME에 설정한 버전으로 잘나옴
4. jdk 설정, 원래 Android studio > File> Settings > Build, Execution, Deployment > Build Tools > Gradle 들어가면 나와야하는데
flutter project는 안나온다고 한다 그래서 Android Studio > File> Project Structure > SDKs에서 Android Studio JDK 버전을 맞춰줘야한다.
https://stackoverflow.com/questions/75671906/android-studio-no-option-to-change-gradle-jdk-path
Android Studio no option to change Gradle JDK path
I have been trying to install Flutter and everything went smoothly until I launched the debugger and got an error stating, you need java 11 or higher to build your app with this version of gradle. ...
stackoverflow.com
Flutter application not working due to Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8
I am trying to make a flutter application but I constantly get this error : * What went wrong: A problem occurred evaluating project ':app'. > Failed to apply plugin 'com.android.internal.applic...
stackoverflow.com
관련된 stackoverflow
5. Flutter config 설정
혹시 몰라서 이것도 설정해줌
```
PS C:\flutter_project\ddeugaelog\android> flutter config --list
All Settings:
enable-web: (Not set)
enable-linux-desktop: (Not set)
enable-macos-desktop: (Not set)
enable-windows-desktop: (Not set)
enable-android: (Not set)
enable-ios: (Not set)
enable-fuchsia: (Not set) (Unavailable)
enable-custom-devices: (Not set)
cli-animations: (Not set)
enable-native-assets: (Not set) (Unavailable)
enable-flutter-preview: (Not set) (Unavailable)
enable-swift-package-manager: (Not set) (Unavailable)
android-studio-dir: C:\Program Files\Android\Android Studio
jdk-dir: C:\Program Files\Java\jdk-17
```
샅샅이 뒤져서 나오는 건 다 하고 재부팅과 재설치를 몇 번이나 헀는데도 안되길래
` Tried location: C:\Program Files\Java\jdk-11.0.16.1\bin\java.exe`
그래 니 tried location 거기로 하고싶냐? 해줄게 하고
jdk-17 폴더 밑에 있는 걸 싸그리 jdk-11.0.16.1로 카피해줬더니 행복하다고 잘 된단다.
진짜 컴퓨터 포맷할 뻔 했다 자바짜증나
이게 해결책은 안될 건데 일단 이틀을 이걸로 소비해서 더 이상 파고들고 싶지 않다.
누가 해결책을 알면 알려줘요 제발..ㅠ