Windows 下React Native 打包APK 错误解决

今天学习window下将React Native 打包成Android Apk 的时候遇到一个坑,先将解决方法记录一下;
问题:
按照RN官网一步步操作:
官网地址:https://reactnative.cn/docs/0...
以为能一次成功,结果悲剧了,报错如下

FAILURE: Build failed with an exception.

* Where:
Build file 'F:\ReactAppProject\RNSimpleApp\android\app\build.gradle' line: 109

* What went wrong:
A problem occurred evaluating project ':app'.
> Could not get unknown property 'MYAPP_RELEASE_STORE_FILE' for SigningConfig_Decorated{name=release, storeFile=null, storePassword=null, keyAlias=null, keyPassword=null, storeType=null, v1SigningEnabled=true, v2SigningEnabled=true} of type com.android.build.gradle.internal.dsl.SigningConfig.

原因:
按照官网指示
编辑~/.gradle/gradle.properties(没有这个文件你就创建一个),添加如下的代码(注意把其中的替换为相应密码)
解决方法:
gradle.properties文件应该使用RNProject/android/下面的gradle.properties
也就是说在gradle.properties里面添加

MYAPP_RELEASE_STORE_FILE=my-release-key.keystore
MYAPP_RELEASE_KEY_ALIAS=my-key-alias
MYAPP_RELEASE_STORE_PASSWORD=*****
MYAPP_RELEASE_KEY_PASSWORD=*****

搞定

你可能感兴趣的:(Windows 下React Native 打包APK 错误解决)