본문 바로가기
개발일지/개발일지! error out🙅

[RN]모듈 중복생성 오류 Native module RNDatePicker tried to overrideRNDatePicker.

by -제이리 2023. 4. 7.
728x90
320x100

[문제상황]

Native module RNDatePicker tried to override RNDatePicker. Check the getPackages0 method in MainApplication java, it might be that module is being created twice. If this was your intention, set canOverrideExistingModule=true. This error may also be present if the package is present only once in getPackages but is also automatically added later during build time by autolinking. Try removing the existing entry and rebuild

갑자기 위와 같은 에러가 떴다. 잘 사용하고 있던 라이브러린데 갑자기 왜 이런 오류가 생겼는지 알 수가 없다.

위 오류는 두 모듈이 동일한 네이티브 모듈을 덮어쓰려고 할 때 발생한다고 한다.

 

[해결방법]

"MainApplication.java" 파일로 (android\app\src\main\java\com\projectName\) 이동 한뒤

"getPackages()" 메서드에서 "RNDatePicker" 모듈이 두 번 추가되었다면 중복 항목을 제거하면된다고 한다. 

 

하지만 나의 경우에는 라이브러리는 모두 자동링크가 되있기 때문에 중복모듈이 발견되지 않았고  

 

해당 라이브러리의 DatePickerModule.java로 들어가 맨 아래에 코드를 추가해주었더니 해결이 됐다.

(node_modules/프로젝트이름/android/src/main/java/com/reactnativecommunity/프로젝트이름/프로젝트이름Module.java)

 

@Override

public boolean canOverrideExistingModule() {
	return true;
}
728x90
320x100

댓글