-
Notifications
You must be signed in to change notification settings - Fork 784
build: add support for generating Android release #209
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks very useful !
I'll take a look for an iOS equivalent :)
"link": "react-native link", | ||
"ios": "react-native run-ios", | ||
"android": "react-native run-android", | ||
"android:release": "react-native run-android --variant=release", | ||
"android:signkey": "cd android/app/ && keytool -genkey -v -keystore my-release-key.keystore -alias my-key-alias -keyalg RSA -keysize 2048 -validity 10000 && cd -", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe you should use an env var for the my-release-key.keystore
keystore file 😃
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Antoine38660 did not quite understand how? Can you please explain?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean, change the "android:signkey"
script by something like:
"cd android/app/ && keytool -genkey -v -keystore RELEASE_KEYSTORE_PATH -alias ..."
where RELEASE_KEYSTORE_PATH
is an environment variable that points to the keystore file.
But I checked the .gitignore
file and every *.keystore are ignored so @housseindjirdeh can put it here without problem. Actually I think it is already in the repo in the android/keystore
directory :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, I do not know, it's recommended to generate it in the app/android
folder, I can do it, but I do not see it necessary, because all the same, you need to manually specify the key in the android/gradle.properties
file, including the MYAPP_RELEASE_STORE_FILE
path, i.e. you can specify it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep so I generated the keystore file and it's currently living on my machine. It is being ignored in .gitignore
and that's a good thing since we shouldn't be committing it in
If I'm not mistaken , android:signkey
is for creating a new signing key correct? Not sure how or why we should pass in the keystore as a variable here 🤔 Or am I thinking wrong here @Antoine38660?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll explain, this can be useful if you need to create a own release version of the application. Yes, you need to create a signature key, this command does this.
According to the manual, the key data must be placed in the android/gradle.properties
.
@housseindjirdeh I really do not know how you release the new version on Google Play, this change does not hurt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope I probably wouldn't need to run the command since I have a key but it simplifies the process. Was curious about what @Antoine38660 meant by adding an env variable but it should be good.
release { | ||
if (project.hasProperty('MYAPP_RELEASE_STORE_FILE')) { | ||
storeFile file(MYAPP_RELEASE_STORE_FILE) | ||
storePassword MYAPP_RELEASE_STORE_PASSWORD |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually used this approach when setting up a password for release. Not sure how we can have that flow integrated into this PR or even if we should as it's quite user specific 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@housseindjirdeh that's the point, or something I do not understand. This is necessary to create its own release version (because for example it is not always enough for Android simulator, you need to check on a real device).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry you may have missed the link (click here). So I don't store my password inside the gradle file and use keychain access instead. However, there's no real way to include that logic into the placeholder I think so I'm okay with having this as a placeholder to be honest.
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects | ||
# org.gradle.parallel=true | ||
|
||
android.useDeprecatedNdk=true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason why we're removing this file? Isn't this file where we need to add the following details:
MYAPP_RELEASE_STORE_FILE=my-release-key.keystore
MYAPP_RELEASE_KEY_ALIAS=my-key-alias
MYAPP_RELEASE_STORE_PASSWORD=*****
MYAPP_RELEASE_KEY_PASSWORD=*****
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this is it, so it must be ignored.
@housseindjirdeh could we merge? |
@housseindjirdeh could you give this a fresher look? |
Based on https://facebook.github.io/react-native/docs/signed-apk-android.html
build:android:release
- create a signed apkandroid:release
- install release versionandroid:signkey
- generate signing keyP.S. It was cool to have a similar for iOS, but I do not have Mac, so it's done so far for Android.