Skip to content

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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

lex111
Copy link
Member

@lex111 lex111 commented Aug 6, 2017

Based on https://facebook.github.io/react-native/docs/signed-apk-android.html

build:android:release - create a signed apk
android:release - install release version
android:signkey - generate signing key

P.S. It was cool to have a similar for iOS, but I do not have Mac, so it's done so far for Android.

Copy link
Member

@Antoine38660 Antoine38660 left a 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 -",
Copy link
Member

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 😃

Copy link
Member Author

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?

Copy link
Member

@Antoine38660 Antoine38660 Aug 11, 2017

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 :)

Copy link
Member Author

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.

Copy link
Member

@housseindjirdeh housseindjirdeh Aug 14, 2017

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?

Copy link
Member Author

@lex111 lex111 Aug 14, 2017

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?

Copy link
Member

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.

@andrewda andrewda changed the title Add support generating the release app for Android build: add support for generating Android release Aug 11, 2017
release {
if (project.hasProperty('MYAPP_RELEASE_STORE_FILE')) {
storeFile file(MYAPP_RELEASE_STORE_FILE)
storePassword MYAPP_RELEASE_STORE_PASSWORD
Copy link
Member

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 🤔

Copy link
Member Author

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).

Copy link
Member

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
Copy link
Member

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

Copy link
Member Author

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.

@lex111
Copy link
Member Author

lex111 commented Sep 25, 2017

@housseindjirdeh could we merge?

@coveralls
Copy link

Coverage Status

Coverage remained the same at 43.651% when pulling e5d4717 on lex111:release-android-app into e270f41 on gitpoint:master.

@machour
Copy link
Member

machour commented Jan 16, 2018

@housseindjirdeh could you give this a fresher look?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants