[React-Native] CodePushHash: Resource and asset merger: Duplicate resources

gyulhana·2024년 4월 30일
* What went wrong:
Execution failed for task ':app:mergeDevelopStageAssets'.
> /Users/gyuran/Desktop/Projects/pickit-customer-rn-app/android/app/build/generated/assets/createBundleDevelopStageJsAndAssets/CodePushHash     /Users/gyuran/Desktop/Projects/pickit-customer-rn-app/android/app/build/generated/assets/createBundleDevelopStageJsAndAssets/CodePushHash: Error: Duplicate resources

문제
fastlane을 통해 안드로이드 배포를 진행하던 중 다음과 같은 오류를 만났다. codepushhash파일의 duplicate resource 문제였다.

문제 해결 방법
석연찮은 해결방법이긴 하나 ./gradlew clean을 하고 나서 번들링을 하면 발생하는 오류임을 파악했다. code-push issues에서 찾아보니 번들링을 두번째로 실행하면 해당 이슈가 없다는 것을 알아냈다. 기존에 사용하던 fastfile에서는

desc "Deploy a new version to the Google Play"
    lane :release do |options|
      updateVersion(options)

      gradle(task: "clean bundleProductRelease")
      gradle(task: 'bundle', build_type: 'ProductRelease')
      upload_to_play_store(
        skip_upload_metadata: true,
        skip_upload_changelogs: true,
        skip_upload_screenshots: true,
        skip_upload_images: true,
        skip_upload_apk: true,
        track: 'internal'
      )
    end

이렇게 실행되어 clean하고 바로 번들링하여 Playstore에 올리는 순서대로 되어있었는데 fastfile을 begin-resuce를 사용해서 수정하여 번들링이 실패하는 경우 바로 다시 번들링을 다시 실행하도록 했다. resuce를 사용하면 javascript에서 error를 catch하는 것과 마찬가지로 실패했을 때 바로 실행이 중단되지 않고 다음 실행으로 넘겨줄 수 있다. 다음은 수정한 Fastfile

desc "Deploy a new version to the Google Play"
    lane :release do |options|
      updateVersion(options)

      gradle(task: "clean bundleProductRelease")
      begin
        gradle(task: 'bundle', build_type: 'ProductRelease')
      rescue => exception
        UI.error("Failed to execute bundleProductRelease: #{exception}")
        gradle(task: 'bundle', build_type: 'ProductRelease')
      end
      upload_to_play_store(
        skip_upload_metadata: true,
        skip_upload_changelogs: true,
        skip_upload_screenshots: true,
        skip_upload_images: true,
        skip_upload_apk: true,
        track: 'internal'
      )
    end

관련 문서: Fix error: CodePushHash: Resource and asset merger: Duplicate resources #2574

누가 PR을 올리긴 했는데 해당 방법대로 patch를 해도 문제는 내 경우에는 해결되지 않았고 그래서인지 merge되지도 않았다.

profile
친절한 하루를 선물하고 싶은 사람

0개의 댓글