今天學習window下將React Native 打包成Android Apk 的時候遇到一個坑,先將解決方法記錄一下;
問題:
按照RN官網一步步操做:
官網地址:https://reactnative.cn/docs/0...
覺得能一次成功,結果悲劇了,報錯以下html
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裏面添加react
MYAPP_RELEASE_STORE_FILE=my-release-key.keystore MYAPP_RELEASE_KEY_ALIAS=my-key-alias MYAPP_RELEASE_STORE_PASSWORD=***** MYAPP_RELEASE_KEY_PASSWORD=*****
搞定android