I'm a new learner on this platform.
I code a simple react native app using expo. But I want to build a .apk file.
I tried this command:
expo build:android
Then I sign up an expo account. After completing the building process it shows the download button. Just like the following picture: But its not apk file. It is .aab file.
So, I want to build an actual apk file.
How can I do that?
By default Expo, CLI builds the app into a .aab file format. this format is better for Google Play Store as it will be optimized for every device CPU architecture which results in a smaller app size.
In case you want to test for your device or emulator, run:
expo build:android -t apk
Update for new users:
Run the following:
› npm install -g eas-cli
› eas build -p android https://docs.expo.dev/build/setup/
expo build:android will be discontinued on January 4, 2023
to build a apk out of the file first you need to do some changes to your eas.json file.
By default, EAS Build produces Android App Bundle, you can change it by:
setting buildType to apk
setting developmentClient to true
setting gradleCommand to :app:assembleRelease, :app:assembleDebug or any othergradle command that produces APK
after changing the config you can run eas build -p android --profile preview to build the application
you can read more about this in docs
https://docs.expo.dev/build-reference/apk/
and here's a sample config i used for a basic project to build ( also you can find on docs )
{
"cli": {
"version": ">= 0.52.0"
},
"build": {
"preview": {
"android": {
"buildType": "apk"
}
},
"preview2": {
"android": {
"gradleCommand": ":app:assembleRelease"
}
},
"preview3": {
"developmentClient": true
},
"production": {}
}
}
--
also alternatively another possible way would be to get the bundle ( .aab ) file and convert it to apk using a too like bundletool. and you can find the apk ( universal.apk ) inside app.apks
bundletool build-apks --bundle=bundle.aab --output=app.apks --mode=universal
https://github.com/google/bundletool
From expo documentation :
When building for android you can choose to build APK (expo build:android -t apk) or Android App Bundle (expo build:android -t app-bundle).
Related
I recently added an NPM package for camera which impacts the Native Modules, so it's not supported by Expo out of the box. Now I am sending a build to EAS and then running that IPA file on my Simulator locally. The issue is that the VideoCamera is not supported by the iOS simulator
I am creating a development build which is sent to EAS, as described in my eas.json:
"development": {
"extends": "staging",
"developmentClient": true,
"distribution": "internal", // tried with & without this line
"ios": {
"simulator": true
}
}
Then I run npx expo start --dev-client so that i can tap into the expo-dev-client can be hooked into my app. It runs fine on my simulator, but when needing to access the camera for video, we need to use a physical device due to limitation stated above.
How can I run the EAS image on my physical device? Or how can I run Expo locally, which can still manage the Native Modules impacted by the new NPM lib?
I have the following build profile in my eas.json:
"build": {
"production": {}
}
I have built my app using eas build without specifying the 'channel' under the 'production' profile:
eas build -p android --profile production
Build details in expo dev
As you can see in the image the 'Release Channel' is set to 'default'.
My problem is that I can't find a way to update the app bundle on the air (OTA update).
I have tried the following but with no luck:
Update the 'default' branch using:
eas update --branch default --message "first update"
Create a 'default' profile with "channel: 'default'":
"build": {
"default": {
"channel": "default",
}
}
expo.dev
Then link the channel to some other branch ('staging' in that case):
eas channel:edit default --branch staging
and then:
eas update --branch staging --message "first update"
Unfortunately, I couldn't find any solution online.
NOTE: I know I can create a new build with proper channel and continue from there but I need to update the build which is currently available at App Store and fix a bug ASAP (before the new version will be available in the store).
I was using expo build:android -t apk to get an apk file an try the application.
It was automatically available in expo.
Now I try to do the same with eas but it is not working.
I tried :
yarn eas build -p android -t apk
yarn eas build -p android --profile preview
yarn eas build -p android
All my build are of course created, but no one is available directly in expo like I was used to.
Any idea ?
enter image description here
enter image description here//i.stack.imgur.com/KpJkv.png
It looks like Expo EAS build use Gradle version 7.3.3 and some modules require Gradle version 7.4 at minimum.
EAS Build doesn't provide a direct way to change the Gradle version but it provides presets for building infrastructure images.
In the eas.json file, try to use latest image, which contains latest versions of build tools.
{
"cli": {
"version": ">= 0.38.2"
},
"build": {
"development": {
"developmentClient": true,
"distribution": "internal",
"ios": {
"simulator": true
}
},
"production": {
"android": {
"buildType": "app-bundle",
"image": "latest"
}
}
},
}
I found the error it was enough just to change gradle-7.3.3-all.zip by gradle-7.4-all.zip in yourappName\android\gradle\wrapper\gradle-wrapper.properties
ps : run npx expo prebuild --no-install --platform android before to have android folder
I had the same problem: an error in "Run gredlew" in Android build (no problem with iOS build) when I upgraded to Expo SDK 47.
The good thing was that I already had a successful build with Expo SDK 47, so I began to downgrade one by one the third-party packages I am using to the same versions of that successful build.
In the end, the culprit was #stripe/stripe-react-native. The build was successful again reverting back to version 0.13.1 from 0.19.0.
In your case, it might be any other third-party package, so I suggest going through the same process.
EDIT 26/01/2023: Instead of downgrading #stripe/stripe-react-native, I followed Kudo's advice here:
the #stripe/stripe-react-native#0.19.0 requires android compileSdkVersion 33. you could use expo-build-properties to change the compileSdkVersion to 33 in a managed project: https://docs.expo.dev/versions/latest/sdk/build-properties/#pluginconfigtypeandroid
i have a problem with eas build (expo), My app size is about ~60mb (using expo build:android), and that build is working just fine, (I'am using physically phone).
I've build the same app, no changes, with eas build, there is a crash.
How i run eas build: eas build -p android --profile preview
How i run expo build: expo build:android -t apk
I want to point, I'am not getting any errors when Grandle is runned, and build is just fine
There is my eas.json
{
"build": {
"preview": {
"android": {
"buildType": "apk"
}
},
"preview2": {
"android": {
"gradleCommand": ":app:assembleRelease"
}
},
"preview3": {
"developmentClient": true
},
"production": {}
},
"cli": {
"version": ">= 0.48.2"
}
}
How can i check the log of crash?
Does someone had something similar?
Maybe diffrent solution to make app smaller?
In my case, if an environment variable was missing on first screen the app would crash.
The problem was that I had my variables in an .env file, which will work for the classic build but doesn't in eas build.
If that's your case, you'll need to declare your environment variables in your eas.json file, or create a secret for your app through expo's website for sensitive values.
You can read more about it here: https://docs.expo.dev/build-reference/variables/
Maybe any logs?
I've had 1 problem regarding Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8. **EXPO.dev** and I'm working with Firebase, then the problem was about .gitignore having google-service.json and .env, which as per this comment are not uploaded in the EAS Build.
I'm having the same problem and working through debugging.
Here's a good place to start -- if you're on mac, connect an android device and run:
adb logcat '*:S' ReactNative:V ReactNativeJS:V
This will help you log relevant errors and debug the issue. Simply running adb logcat logs an unmanageably large amount of data.
The issue and the answer are actually in this post, but I'll outline it here briefly.
I had the same issue with undefined .env variables. The issue is that the files in your .gitignore file aren't uploaded to eas machine that assembles your build. But you can create .easignore file that would be a copy of your .gitignore file excluding your .env file.