현재 Android Studio 3.5.2를 사용하고 있다.

간단한 Java 파일을 만들어 컴파일을 하려고 하는데, Error가 발생한다. 그 회피 방법을 구글링 끝에 찾아내어 이렇게 글을 써 본다.

우선, 내가 했던 작업은 다음과 같다.

Project를 하나 생성하고, app→java→com.example.myapplication 내부에 VariableAndType이라는 Java class를 만들었다.

그 다음 다음과 같이 간단한 코드를 입력하고 나서, 오른쪽 버튼 클릭 후 Run을 실행한다.

그랬더니 Error가 다음과 같이 발생한다.

오후 12:14:00: Executing task 'VariableAndType.main()'...

Executing tasks: [VariableAndType.main()] in project D:\01_MS_Work\99_Personal\01_Study\FastCampus\Java\Chapt4


FAILURE: Build failed with an exception.

* Where:
Initialization script 'C:\Users\MSKIM~1\AppData\Local\Temp\VariableAndType_main__.gradle' line: 20

* What went wrong:
A problem occurred configuring project ':app'.
> Could not create task ':app:VariableAndType.main()'.
   > SourceSet with name 'main' not found.

* 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

Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/5.4.1/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 0s
오후 12:14:01: Task execution finished 'VariableAndType.main()'.

"SourceSet with name 'main' not found." 라는 키워드로 구글링을 하다 보니 다음 글을 찾을 수 있었다. 물론 번역을 해서 봐야한다. 유럽 국가 언어인거 같은데 자세히는 모르겠음...

http://kodlis.com/sourceset-with-name-main-not-found-hatasi-ve-cozumu/

 

"SourceSet with name 'main' not found." Hatası ve Çözümü | KodLis

Android Studio’nun son sürümünde herhangi bir sınıfı çalıştırdığınızda muhtemelen aşağıdaki hatayla karşılaşacaksınız. What went wrong: A problem occurred configuring project ':app'. Could not create task [...]

kodlis.com

여기에 나온 내용은 다음과 같다.

새로 업데이트된 Android Sutdio에서 앱을 실행하다 보면 내가 본 것과 동일한 Error를 접할 수 있고, 이에 대한 해결책을 알려준다는 것이다.

그 해결책은 먼저, Gradle Scriptsd에서 build.gradle (Module: app)을 열고서, dependencies 부분의 가장 끝에 하기의 문구를 넣으라는 것이다.

androidTestImplementation 'androidx.test.ext:junit:1.1.1'

그래서, 다음과 같이 위의 문장을 다음과 같이 적용해 보았다.

그리고 나서 왼쪽 상단에 "Sync Now'를 클릭.

그 다음 다시 Run을 실행하여 컴파일 진행.

그러나 이전과 동일한 Error가 발생한다.

그 다음 방법으로는 Android Sutdio를 종료 후 해당 프로젝트가 저장된 폴더로 가서 Gradle 폴더만 지우는 것이다.

그 다음 다시 Android Studio를 실행하면 해당 프로젝트가 로딩되면서 Gradle은 자동으로 업데이트 된다.

다시 Run을 실행하여 컴파일을 진행 한다. 그랬던니 Error 없이 결과 값을 정상적으로 출력한다.

- 끝

+ Recent posts