본문 바로가기
IT/안드로이드

android studio different debug vs release libraries version

by DOSGamer 2023. 4. 26.
반응형

아무리 구글링 해도 내용이 없다

삽질 끝에 원인과 해답은

 

원인

gradle 을 이용하여 여러 가지 버전의 라이브러리를 받아서 사용하면

업데이트는 쉽지만 google 과 maven 에서 제공하는 버전이 달라서

문제가 발생된다

external libraries 는 다운그레이드 가 안된다

 

증상

build 는 잘되는데 layout inspector 가 compose.ui 라이브러리의 엉뚱한 버전을 찾으면서 찾을 수 없다고 나타난다

debug 에서 다른 버전의 compose.ui 를 사용하고 있었다

 

해결방법

gradle cache 파일 삭제

app 레벨 build.gradle 에서 라이브러리 사용 전부 주석처리

 

 

 

3종의 캐쉬가 있다 전부 삭제

사용자 폴더 > .gradle > cache 삭제  (캐쉬 파일 잔뜩 있음)

프로젝트 폴더 > .idea > libraries 삭제 (여기에 xml 잔뜩 있음)

프로젝트 폴더 > .idea > modules > .xml 삭제   (이건 있을 수도 있고 없을 수도 있음. 옵션 설정)

 

 

이제 다시 시작이다. 캐쉬된 버전이 설치 되지 않기를 빌자

안드로이드 스튜디오를 다시 실행하고 

File > Repair IDE 실행 > reindex project 

안드로이드 스튜디오 다시 실행

File > Invalidate Caches 

그러면 자동으로 안드로이드 스튜디오 다시 시작되고 다시 build 한다

 

 

결과

깔끔하게 옛날 버전 설치 되었다

이제

app 레벨 build.gradle 에서 라이브러리 사용 전부 주석을 없애면서 다시 설치 하자

 

 

 

엄청난 구글링을 시도 했으나 결과가 없다가 

https://stackoverflow.com/questions/54521814/android-studio-removed-dependency-is-not-removed-from-external-libraries

 

Android Studio - Removed dependency is not removed from external libraries

In Android Studio, I'm implementing some libraries in the gradle file to be used in my app, these libraries got added to the external libraries section in the project, each with it's own version. ...

stackoverflow.com

여기 답글에서 힌트를 얻어서 성공~~

반응형