최근 구글 플레이 스토어의 정책 변화로 오랜만에 예전에 만들었던 프로젝트 소스 코드를 수정하고 업데이트 하게 됐다!
현생을 살아가느라 바빠서 업데이트도 못하고 거의 방치하가다 오랜만에 나의 작고 소중한 프로젝트를 수정하게 되었다.
그런데 이전 그래들 버전에서 잘쓰던 스크립트가 아래와 같이 고장나버렸다.. ㅠ
fun getPropertiesValue(propertyKey: String): String {
return gradleLocalProperties(rootDir, providers).getProperty(propertyKey)
}
안드로이드 스튜디오 터미널에서 난리가 나서, 이걸 또 어찌 고치나 해서 부랴부랴 서칭을 해서 고쳤다!
현재 프로젝트에서 사용중인 gradle의 버전은 8.4+ 인 것으로 보이는데,
이 마저도 gradle 공식 사이트에서 릴리즈한 최신 버전과는 꽤나 버전 차이가 존재한다!
서론은 여기까지 하고, 8.4+ 이상 버전에서 gradle (Kotlin DSL) 에서는 아래와 같이 수정하여 사용할 수 있다.
(.. 다른 종속 라이브러리 ..)
import java.util.Properties
import java.io.File
fun getPropertiesValue(propertyKey: String): String {
val props = Properties()
val file = File(rootDir, "local.properties")
props.load(file.inputStream())
return props.getProperty(propertyKey)
?: error("Property $propertyKey not found in local.properties")
}
(... 생략 ..)
이번 패치의 목적은 기존 스크립트 코드의 NPE(Null Pointer Exception) 보안 문제를 해결하기 위해 강제된 것이라는데,
자주 쓰던 기능이 내부적으로는 보안 문제가 있었다니!
아래의 링크는 gradle 포럼에서 발췌해온 일부 사례 중 하나이다.
https://discuss.gradle.org/t/error-compilejava-java-lang-nullpointerexception-no-error-message/2220
Error : compileJava -> java.lang.NullPointerException (no error message)
Hello, I just installed Gradle and I’m trying to understand it but I encounter a problem when trying to build a project with the plugin ‘java’. Just to rule out somes things, I was able to : 1- Install Gradle and run the following script task hello {
discuss.gradle.org
실제로 예전부터 해당 기능에 대한 문제점이 지속적으로 보고되었던 모양이다!
'모바일(Mobile) > 안드로이드(Android)' 카테고리의 다른 글
| [Android] 파이프라인 디자인 설계와 고찰 (0) | 2025.09.23 |
|---|---|
| [Hilt] Hilt 적용 오류 : Unable to read Kotlin metadata due to unsupported metadata version (0) | 2025.02.22 |
| [Android] 안드로이드 기기와 USB 외부 장치 (0) | 2024.03.25 |
| [Android] 안드로이드와 스케줄링 알고리즘 (4) | 2024.03.14 |
| [Android] SQLite와 데이터 베이스 오버 플로우에 관하여 (1) | 2024.03.11 |