Someone can explain to me the process of generating an apk in React Native

Asked

Viewed 19,086 times

9

I can not generate an apk, I follow the steps of the documentation but right away I can not generate the keytool. Can someone explain to me how it is generated?

  • Can you give a printscreen to the error you have? (I don’t have a reputation for just commenting)

  • if you have the error helps enough.

  • Oops, I created my apk following the tutorial of the answer to your question. However the generated apk does not work when I upload the same pro google play. You were able to generate, uproot and perform well?

1 answer

12

To generate an apk ~Signed~ you must first generate the . Keystore.

This step is very simple. Just go to where you put your jdk (C:\Program Files\Java\jdkx.x.x_x\bin - in this case I did with version jdk1.8.0_92)

And execute, as is here:

$ keytool -genkey -v -keystore my-release-key.keystore -alias my-key-alias -keyalg RSA -keysize 2048 -validity 10000

So, keep typing the information you are asking for. The information you will need is: name da keytool (will generate how my-release-key probably) and password.

NOTE: I needed admin permission to generate.

Done this, take the newly generated keytool and put in android/app in your React Native project directory.

Then add in android/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=*****

After that, it modifies the android/app/build.grade as it says in the React Native tutorial:

...
android {
    ...
    defaultConfig { ... }
    signingConfigs {
        release {
            if (project.hasProperty('MYAPP_RELEASE_STORE_FILE')) {
                storeFile file(MYAPP_RELEASE_STORE_FILE)
                storePassword MYAPP_RELEASE_STORE_PASSWORD
                keyAlias MYAPP_RELEASE_KEY_ALIAS
                keyPassword MYAPP_RELEASE_KEY_PASSWORD
            }
        }
    }
    buildTypes {
        release {
            ...
            signingConfig signingConfigs.release
        }
    }
}
...

Then just execute:

$ cd MyAPP/android $ gradlew assembleRelease

Obs: I had to put the gradlew in PATH to run the last command.

Your apk will appear on android/app/build/outputs/apk/ after the build.

  • Hi, I generated my apk using the explanation you left above. Upei o apk para o google play, However, when I download from there, the same does not run, just stops working. Any tips?

  • tested on your device?

Browser other questions tagged

You are not signed in. Login or sign up in order to post.