본문 바로가기
  • A space that records me :)
기술/오류 해결 기록

[Android Build failed] Keystore file ... not found for signing config 'debug'. (MAC)

by yjkim_97 2023. 9. 7.
더보기

환경

  • mac
  • react native
  • android
  • yarn build

🚫 에러 발생 상황

React-native Android 빌드 Failed

 

Keystore file '.../파일명.keystore' not found for signing config 'debug'.

BUILD FAILED in 22s

error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup.
Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081
Note: /Users/yjkim/innerwave_source/git/watis-app/node_modules/@react-native-firebase/dynamic-links/android/src/main/java/io/invertase/firebase/dynamiclinks/ReactNativeFirebaseDynamicLinksModule.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.

FAILURE: Build completed with 2 failures.

1: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':app:validateSigningDebug'.
> Keystore file '/Users/yjkim/innerwave_source/git/watis-app/android/watis.keystore' not found for signing config 'debug'.

* 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.
==============================================================================

2: Task failed with an exception.
-----------
* What went wrong:
java.lang.StackOverflowError (no error message)

* 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.
==============================================================================

 

 

React native 환경에서 안드로이드 빌드를 시도하던 도중 만난 에러이며

안드로이드 서명 키가 해당 경로에 존재하지 않아 발생한 것이다.

 

 

🛠️ 조치 방법

1. 해당 프로젝트에 설정된 keystore 경로로 이동

( default : 프로젝트폴더/android/app/ )

 

# cd android/app

 

2. Android 서명키 (Signing Key) 발급

(파일명, alias명, 비밀번호값 기억해두어야함 -> gradle 서명키 설정 필요)

 

# keytool -genkey -v -keystore {파일명}.keystore -alias {alias명} -keyalg RSA -keysize 2048 -validity 10000


Enter keystore password:  
Re-enter new password: 
What is your first and last name?
  [Unknown]:  ***
What is the name of your organizational unit?
  [Unknown]:  ***
What is the name of your organization?
  [Unknown]:  ***
What is the name of your City or Locality?
  [Unknown]:  ***
What is the name of your State or Province?
  [Unknown]:  ***
What is the two-letter country code for this unit?
  [Unknown]:  **
Is CN=yjkim, OU=innerwave, O=innerwave, L=Seoul, ST=Seoul, C=kr correct?
  [no]:  y

Generating 2,048 bit RSA key pair and self-signed certificate (SHA256withRSA) with a validity of 10,000 days
        for: CN=***, OU=***, O=***, L=***, ST=***, C=**
[Storing watis.keystore]

 

현재 경로에 서명키가 발급된다.

 

3. gradle 서명키 설정

프로젝트폴더/android/gradle.properties 파일에 아래 코드를 추가한다.

 

MYAPP_RELEASE_STORE_FILE={파일명}.keystore
MYAPP_RELEASE_KEY_ALIAS={Alias명}
MYAPP_RELEASE_STORE_PASSWORD={비밀번호}
MYAPP_RELEASE_KEY_PASSWORD={비밀번호}

 

프로젝트폴더/android/app/build.gradle 파일에 아래 코드를 추가한다.

 

android {
	...
    signingConfigs {
        debug {
            storeFile file('{상대경로}/{파일명}.keystore')
            storePassword '{비밀번호}'
            keyAlias '{alias명}'
            keyPassword '{비밀번호}'
        }
        release {
            storeFile file('{상대경로}/{파일명}.keystore')
            storePassword '{비밀번호}'
            keyAlias '{alias명}'
            keyPassword '{비밀번호}'
        }
    }
    
    
    buildTypes {
        debug {
        	...
            signingConfig signingConfigs.debug
        }
        release {
        	...
            signingConfig signingConfigs.release
        }
    }
    ...
}

 

4. 빌드

서명키 설정이 정상적으로 이루어졌다면, 해당 에러는 해소된다.

추가로 개인 서명키인 경우 git에 올라가지 않도록 주의하도록 하자.

 


Reference

https://dev-yakuza.posstree.com/ko/react-native/android-running-on-device/#%EC%95%88%EB%93%9C%EB%A1%9C%EC%9D%B4%EB%93%9C-%EC%84%9C%EB%AA%85-%ED%82%A4-%EC%83%9D%EC%84%B1