React Native: Generate .apk and .ipa using Expo - react-native

I'm trying to generate a .ipa and a .apk file for my React Native app using Expo & Create React Native App. I successfully built the app and was able to get it to run on both an iOS & an Android device thanks to the docs: https://docs.expo.io/versions/v16.0.0/guides/building-standalone-apps.html
When the build is over, my console shows something like
Your URL is
https://exp.host/#myname/myapp
I then open exp.host/#myname/myapp on my device and the app shows up via the Expo client.
But at point 4 of the docs, it is said that
When it’s done, you’ll see the url of a .apk (Android) or .ipa (iOS) file — this is your app.
I'm a bit confused. No where in the process do I see any ipa or apk file generated anywhere on my pc. Am I missing something ? How do I actually generate the files ?

make sure in app.json
{
"expo": {
"name": "your app name",
"description": "your app desc",
....,
"ios": {
"supportsTablet": true
},
"android": {
"package": "com.yourcompany.yourappname"
}
}
}
then run expo build:android or expo ba
after that
run expo build:status
you'll find, something like this, the Apk's is hosted on amazon aws
[exp] Android:
[exp] APK: https://HOST/yourapp.apk

You will need to run expo build:status. When building process is complete you will see link to download apk (Android) or ipa(IOS) file.

use `expo build:android` for android
use `expo build:ios` for ios
it will ask to create new account if you don't have an expo account
expo build:status to know status of your app & the queued app may take around 30 mins to generate apk file .you can find it in expo website
how to generate apk/ios file from expo

Update For the Latest Version of expo:
Expo will soon deprecate expo build and has encouraged using eas build, which builds to app bundle by default. To build to apk, modify the eas.json file accordingly as given here in expo docs. You will ofcourse have to install eas separately as it doesn't come bundled with expo-cli.
For apk add eas.json as:
{
"build": {
"preview": {
"android": {
"buildType": "apk"
}
},
"preview2": {
"android": {
"gradleCommand": ":app:assembleRelease"
}
},
"preview3": {
"developmentClient": true
},
"production": {}
}
}
and then run eas build -p android --profile preview

If you execute build status:
expo build:status
you will get the status update of the build either for ios or android. It will show one of these possible states:
Build in progress...
There was an error with this build
URL of the ipa or apk file
The URL would be something like:
https://expo.io/builds/{buildId}
where {buildId} is a UUID
When you click on the link, it will show the current status, logs being generated, a "Download" button where you can download the ipa or apk file (which will only be available if the build was successful) and a "Cancel" button to cancel the current build (which will only be available if the build is running).
Alternatively you can view your previous and current builds statuses by following this link:
https://expo.io/{#user}/{app}/builds
Replace {#user} with your expo username (including the # character) and {app} with your app name. Here you can view specific build statuses like Completed or Failed, view logs of your builds, and download current and previous successful builds.
This URL is also shown when you go to your current build, below the "Build logs" title:
This is a build from {#user}/{app}

As per https://docs.expo.dev/classic/building-standalone-apps/: "The Classic Build service (expo build:{android,ios}) is in maintenance mode and has been superseded by EAS Build. SDK 46 will be the last SDK supported by Classic Builds and the Classic Build service will stop running for all SDK versions after January 4, 2023.", the new commands are:
eas build --platform android for Android
eas build --platform ios for iOS
eas build --platform all for both
More information: https://docs.expo.dev/build/setup/.

This command will work
eas build -p android --profile preview

At first, Run this command -> expo build:android then
login your expo account
Choose the build type you would like:
apk:normal apk file
apk-bundle: for play store and app store
then generate a keystore file and wait minimum 10 minutes then your get a build link
https://expo.dev/accounts/your_account_name/projects/project_name/builds/6ab79fef-72fe-4f50-88e2
goto thik link and download your build.

Related

How to get the .dSYM file from expo EAS build?

I have successfully built an app using Expo EAS build and now I want to retrieve the .dSYM file generated.
Anyone know if it's possible? I couldn't find anything related to that in the Expo AES build docs.
Add the following to eas.json:
"ios": {
"buildArtifactPaths": "ios/build/*"
}
https://github.com/expo/eas-cli/issues/968#issuecomment-1172794557

Switch from Expo to bare React native

After giving the command expo build:android to generate .apk file for my project. The size of the app was too big (60MB). So, I went through certian websites, Most of them are showing that I need to eject expo and generate an apk in bare react-native-cli. Is there any method to reduce the size of an expo app? or should I go with bare react-native-cli. If it is a yes, can you provide steps to achieve this?
Cross answering from here. In your app.json make the following changes
"expo": {
...
"android": {
"enableDangerousExperimentalLeanBuilds": true
}
}
And you can use
expo build:android -t app-bundle
This will create an Android Application Bundle which is a publishing format.

Why I have this problem with the appbundle?

I published this app on the playstore (https://play.google.com/store/apps/details?id=com.brawlcalculator) and I want to reduce the dimension of the app using an app bundle. I created the app with React Native and I used in the same project this command to create the apk(./gradlew clean && ./gradlew assembleRelease) and I successfull published it into the playstore, then I created the app bundle with this command (./gradlew bundleDebug) and when I tried to upload the appbundle it gives me an error: "The appbundle have the wrong key". Does I have to upload the apk and the appbundle together?
assembleRelease signs the APK with your release key, while bundleDebug signs the Bundle with your debug key.
Instead, you should upload the Bundle built with your release key, which you can do using the bundleRelease task.

React Native: Android Studio doesn't automatically bundle when building

I am building a react native application and we're doing the production release.
I noticed that everything works in my iOS app (there's a build phase that generates the offline bundle) but when I run the release build in Android Studio, my app builds but it crashes because it can't find the bundle.
I was able to resolve my own question:
We changed our build types/flavors to match our desired configuration.
The react.gradle file that comes with React Native has a configuration for Debug and Release, these are the common build tasks in a native application. BUT once you change things up you need to tell the react library in android whether or not you want it to bundle for you.
You can find this in your app's build.gradle (under
./android/app/build.gradle). There's an entire block of guidelines commented out that explain you what to do.
In my case I had to add the following code before apply from: "../../node_modules/react-native/react.gradle"
ext.react = [
bundleInNameDebug: false,
bundleInNameBeta: true,
bundleInNameRelease: true
]
NameDebug, NameBeta, NameRelease are all custom BuildTypes/BuildFlavors I have configured.
If you have the signing configuration, it should build a apk for testing when you run react-native run-android --variant=release with the offline bundle. If you want to make a release build for Playstore, run ./gradlew assembleRelease inside the android folder.
You can find more info here

Created an app with create-react-native-app, how to publish it to the Google Play Store?

I have created an app with create-react-native-app, but I am not sure how to publish it to google play store.
Error 1
After reading this doc.
; exp build:android
[exp] Making sure project is set up correctly...
/[exp] Warning: Not using the Expo fork of react-native. See https://docs.expo.io/.
\[exp] Warning: 'react-native' peer depencency missing. Run `npm ls` in /var/www/html/test/testme/osmosis-seek-android to see full warning.
[exp]
[exp] If there is an issue running your project, please run `npm install` in /var/www/html/test/testme/osmosis-seek-android and restart.
[exp] Your project looks good!
[exp] Checking if current build exists...
[exp] No currently active or previous builds for this project.
? Would you like to upload a keystore or have us generate one for you?
If you don't know what this means, let us handle it! :)
false
[exp] Starting build process...
[exp] Publishing...
[exp] Published
[exp] Your URL is
https://exp.host/#kenpeter/osmosis-seek-android
[exp] Building...
[exp] Must specify a java package in order to build this experience for Android. Please specify one in app.json at "expo.android.package"
With projects created using create-react-native-app you have two paths to the Google Play Store.
Use the Expo exp build command
One path is to use the Expo (a project I work on) exp command-line tool to build the APK. The exp command-line tool (and XDE GUI program) can load projects created with CRNA. After getting set up, you can run exp build:android and receive an APK in a few minutes.
The first time you do this, you'll have to add some information to expo.json or app.json (whichever you have) that's required for the APK. Specifically you need to specify the Java package name like this (it's important it's a valid Java package name!):
{
android: {
package: "com.example.myapp"
}
}
These are the docs that talk about building an APK (and IPA for iOS): https://docs.expo.io/versions/latest/guides/building-standalone-apps.html
Eject and build an APK manually
Another path is to use CRNA's eject command, which creates Xcode and Android project files for you. Then you'd create an APK and submit it to the Play Store like any other React Native Android app. One of the downsides of this approach is that after you've ejected from CRNA, you don't get to use CRNA's tools and it won't take care of upgrades for you in the future.
{
"expo": {
"sdkVersion": "26.0.0",
"name": "TongPos",
"description": "your app desc",
"android": {
"package": "com.sohagfaruque.xxxx"
}
}
}
Please edit your app.json like above mentioned. That worked for me.