When I am creating react native project there is no android file in my project then how do I create apk file.enter image description here
CodePudding user response:
You must generate a private key by running
$ keytool -genkey -v -keystore servento.keystore -alias servento-alias -keyalg RSA -keysize 2048 -validity 10000
Then you have to set the generated file my-release-key.keystore
under android/app in your project.
Edit the file ~/.gradle/gradle.properties
as following
MYAPP_RELEASE_STORE_FILE=.keystore
MYAPP_RELEASE_KEY_ALIAS=-alias
MYAPP_RELEASE_STORE_PASSWORD=[YOUR PASSWORD]
MYAPP_RELEASE_KEY_PASSWORD=[YOUR PASSWORD]
Now edit android/app/build.gradle as following:
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
}
}
And in your terminal run cd android
&& ./gradlew app:assembleRelease
Your APK will be generated inside this directory android/app/build/outputs/apk/ as app-release.apk
CodePudding user response:
you are using expo cli for this project. to make an apk, you can use the old expo build:android
or the new eas build. Here's the documentation for expo build:android
method: https://docs.expo.dev/classic/building-standalone-apps/
here's the docs for the eas build: https://docs.expo.dev/build/setup/
you can choose between either of the builds, but personally i prefer the older expo build:android