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.
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).
I have created a React Native Project and I was trying to open that project in Expo XDE. It throws the following error:
Cannot find module ...\node_modules\expo\tools\LogReporter
Firstly I created a React Native project by cloning a KitchenSink Project.
Link:
NativeBase-KitchenSink
When I started the project by issuing series of commands inside the project root directory:
npm install and then expo start
I saw that the app.json was also not proper, which was the following:
{
"name": "NativebaseKitchenSink",
"displayName": "NativebaseKitchenSink"
}
After issuing expo start react-native reported that the app.json is not to be found in the current directory.
[17:05:08] Starting project at
D:\Projects\ReactNativeProjects\AwesomeProject [17:05:10] Error:
Missing app.json. See https://docs.expo.io/ [17:05:10] Couldn't start
project. Please fix the errors and restart the project. [17:05:10]
Error: Couldn't start project. Please fix the errors and restart the
project.
at C:\xdl#51.4.0\src\Project.js:1565:11
at Generator.next ()
at step (C:\Users\hp\AppData\Roaming\npm\node_modules\expo-cli\node_modules\xdl\build\Project.js:2033:191)
at C:\Users\hp\AppData\Roaming\npm\node_modules\expo-cli\node_modules\xdl\build\Project.js:2033:361
at process._tickCallback (internal/process/next_tick.js:68:7)
I changed app.json to:
{
"expo": {
"name": "AwesomeProject",
"description": "A Kitchen Sink project.",
"slug": "AwesomeProject",
"privacy": "public",
"sdkVersion": "30.0.0",
"platforms": [
"ios",
"android"
],
"ios": {
"supportsTablet": true
},
"android": {
"package": "com.abhsax.first"
},
"version": "1.0.0",
"orientation": "portrait",
"icon": "./assets/logo.png",
"splash": {
"image": "./assets/splashscreen.png",
"resizeMode": "contain",
"backgroundColor": "#ffffff"
},
"updates": {
"fallbackToCacheTimeout": 0
},
"assetBundlePatterns": [
"**/*"
]
}
}
There were some updates in the project when I issued npm install again. Then I issued:
expo start
This error came:
(node:2044) UnhandledPromiseRejectionWarning: Error: Cannot find
module
'D:\Projects\ReactNativeProjects\AwesomeProject\node_modules\expo\tools\LogReporter'
Why am I getting this error, and how can I fix it?
check your package.json if it contains all needed dependencies and run npm install in the home directory of the project
if a package is missing you can add it with
npm install <package_name> --save
if you are using yarn run:
yarn add expo
I did:
yarn add expo
and it worked for me =)
See docs:
introducing-button-yarn-and-a-public-roadmap
and
npm-vs-yarn-in-react-native
These documents say that since the project configured using Yarn, you have to follow Yarn way. [Note: There is a file yarn.lock inside the root directory of the project, you have posted]
Therefore such projects are dealt by following the instructions in the documentation.
Please see How do I create a React Native project using Yarn? to actually create a react-native project using Yarn.
And please be sure to remove node_modules folder and issue command npm install before adding react native CLI using yarn. You have to remove package-lock.json from your project root. This will be to prevent mixing different package managers : npm and yarn.
Instead, it will be a good idea not to use npm, and in order to generate node_modules, just issue command:
yarn
Last link recommends to install every package you need using yarn, and not to use any other package manager:
yarn global add react-native-cli
to add react-native:
yarn add react-native
to add missing packages:
yarn add react-base --save
and to install expo using yarn:
yarn add expo
install expo-cli
yarn add expo-cli
It is possible that you can do without Expo. Just focus on react-native and yarn.
Generate android and ios folders:
react-native eject
Start yarn:
yarn start
run build of your choice, and make sure the SDKs are installed.
react-native run-android
Please also see: Uncaught TypeError: Cannot read property 'forEach' of undefined, on a KitchenSink demo
Happy Coding :-)
Install the Expo modules
npm install --save
i.e.
npm install expo --save
rollback with npm install -g expo-cli#2.4.3
I had an issue in my React-Native project which was working fine earlier but suddenly it stopped working. Whenever I used the command:
react-native run-android
I was getting an error:
Android project not found. Maybe run react-native android first?
I tried running:
react-native android
But it said:
Unrecognized command 'android' Run react-native --help to see list of
all available commands
After trying:
D:\ProjectRoot\ReactNativeProjects\AwesomeProject>react-native eject
The error returned was:
Scanning folders for symlinks in
D:\ProjectRoot\ReactNativeProjects\AwesomeProject\node_modules (48ms)
App name must be defined in the app.json config file to define the
project name. It must not contain any spaces or dashes.
This is the app.json file:
{
"expo": {
"name": "AwesomeProject",
"description": "A very interesting project.",
"slug": "AwesomeProject",
"privacy": "public",
"sdkVersion": "30.0.0",
"platforms": ["ios", "android"],
"ios": {
"supportsTablet": true
},
"android": {
"package": "com.project.first"
},
"version": "1.0.0",
"orientation": "portrait",
"icon": "./assets/images/icon.png",
"splash": {
"image": "./assets/images/splash.png",
"resizeMode": "contain",
"backgroundColor": "#ffffff"
},
"updates": {
"fallbackToCacheTimeout": 0
},
"assetBundlePatterns": [
"**/*"
]
}
}
I raised this question and answered myself as I thought it will help others who are facing similar issue. I struggled a lot to find out the real reason behind it as the error shown in terminal was not precise.
To resolve the issue please upgrade the react-native package.
Go to the Project root.
Upgrade the React native package in the Command Prompt by typing :
react-native upgrade.
Then Accept to update all the Files by typing y (Yes) in the Command Prompt.
Reference: https://github.com/facebook/react-native/issues/9312
Open your React Native Project Root Directory and locate android -> app -> build -> intermediates -> signing_config -> debug -> out -> signing-config.json .
delete signing-config.json this file
try again
Or
1)Sometimes if we have older version of react native and some of newly installed packages dose not support older version. Then you have to update the react native project using react-native upgrade command.
After done updating current project to new version this error should resolved.
I know it is an old question but any of those solutions did not work for me and maybe there are others like me. I solved my problem running this command before run-android
react-native eject
Make sure to start the project using command (non-expo):
react-native init <your-project-name>
If existing folder, then follow:
react-native eject
In the latest version of react-native this suggestion comes when you try to issue the command:
react-native eject
Scanning folders for symlinks in
D:\ProjectRoot\ReactNativeProjects\AwesomeProject\node_modules (48ms)
App name must be defined in the app.json config file to define the
project name. It must not contain any spaces or dashes.
Now when you issue the following command:
D:\ProjectRoot\ReactNativeProjects\AwesomeProject>react-native upgrade
The following shows up:
Scanning folders for symlinks in
D:\ProjectRoot\ReactNativeProjects\AwesomeProject\node_modules (56ms)
You should consider using the new upgrade tool based on Git. It makes
upgrades easier by resolving most conflicts automatically. To use it:
- Go back to the old version of React Native
- Run "npm install -g react-native-git-upgrade"
- Run "react-native-git-upgrade" See https://facebook.github.io/react-native/docs/upgrading.html
react-native version in "package.json" doesn't match the installed
version in "node_modules". Try running "npm install" to fix this.
Aborting.
In the Facebook react-native commands suggestions, there is a clear solution.
These commands check the current version and whether there is update needed or not.
One more solution:
react-native: Command run-android unrecognized. Maybe caused by npm install
Please also see:
Solution to "Expo : cannot find a module LogReporter"
Open Command Prompt as Administrator and goto the project folder, run android(npx react-native run-android)
I did like this... Worked !!
In the CMD Project root run react-native upgrade.
if you are still getting issues, make sure you have react-native
in dependencies json in package.json, add it if not
if you are still getting issues, get the version of react native in cmd using react-native -v and check if the value returned in cmd and package.json are same. update the package.json with the value returned in cmd
Here my problem solved.
I had to restyle my AndroidManifest.xml because I had a syntax error somewhere (I had an extra "/" somewhere). Now it's fixed. Be very careful with your syntax...
Remove the file: React Native Project Root Directory and locate android -> app -> build -> intermediates -> signing_config -> debug -> out -> signing-config.json .
Running Terminal as Administrator in Windows did the trick for me... Other solutions did not work.
Open your React Native Project Root Directory and locate android -> app -> build -> intermediates -> signing_config -> debug -> out -> signing-config.json
Delete the file and try again.
I faced this problem today, and none of the solutions worked for me, so I found another one.
Badly Formatted AndroidManifest.xml will cause this problem, perhaps you set the splash screen like me today, and didn't formatted AndroidManifest in the correct way
We had this issue because files from android folder gradlew and gradlew.bat (Gradle startup script for the UN*X, Windows respectively) somehow got into the global .gitignore file, and so were not presented on local environments.
Actually running react-native upgrade command restore those files, thus fixing the problem.
As a complement, in the case react-native command is not found, you should install react-native CLI:
npm install -g react-native-cli
Then you can follow the steps people said above.
More details: react-native: command not found
Delete signing-config.json next try again react-native run-android
signing-config.json file Path : android -> app -> build -> intermediates -> signing_config -> debug -> out -> signing-config.json
If you started your project by following
npm install -g create-react-native-app
create-react-native-app MyReactNative
npm install -g react-native-cli
npm start
after this, you can face problem mention above in question So the solution is :
npm run eject
I'm using Android Studio (non-expo) and this works for me
react-native init <your-project-name>
I think one more simple thing you could have checked, is if previously you ran the project as different role of a user, like in windows if you ran previously the react-native run-android with an administrator role.
This error simply means you don't have 'android' and 'ios' folders in your root directory of the project. Their location is important.
SOLUTION:-
Open your project folder search for 'android' and iso 'folder', move these folders in your root folder of the project and then start the project with react-native run-android
For me, "rm -rf android/app/build/" worked
Run your command with "--verbose". I got the error that it couldn't read a file (in android/app/build/generated/not_namespaced_r_class_sources/). I deleted this folder, and it worked
My working solution is below, none of the above worked for me:
CD into your project folder and type expo start --android.
Or the long way:
Open AVD manager in Android Studio and run a virtual device (you can
close AS afterwards)
CMD into your project folder and type 'expo start'
Once Expo has started choose option 2 which is "Press a for Android
emulator"
It will install expo on the virtual device and you can test from there
Here, app.json does not have name, but it has expo related config.
So just add name and display name fields in app.json.
app.json (first two lines) :
{
"name": "AwesomeProject",
"displayName": "Awesome Project",
"expo": {
"name": "AwesomeProject",
"description": "A very interesting project.",
"slug": "AwesomeProject",
"privacy": "public",
"sdkVersion": "30.0.0",
"platforms": ["ios", "android"],
"ios": {
"supportsTablet": true
},
"android": {
"package": "com.project.first"
},
"version": "1.0.0",
"orientation": "portrait",
"icon": "./assets/images/icon.png",
"splash": {
"image": "./assets/images/splash.png",
"resizeMode": "contain",
"backgroundColor": "#ffffff"
},
"updates": {
"fallbackToCacheTimeout": 0
},
"assetBundlePatterns": [
"**/*"
]
}
}
After this, just run :
$ react-native eject
info Generating the iOS folder.
info Generating the Android folder.
No need to do react-native upgrade.
You have to run your cmd with admin priviliges. That solved the same issue for me.
Didnt do "eject" or anything else.
In my case, I've forgotten to add Sudo. Fixed as follows,
sudo npx react-native run-android
Delete react native android build folder and then retry command npx react-native run-android
In my case i didn't had the right permissions for my project folder.
If this is your case just click with the right button on the folder > Properties > Security > Advanced and then change the ownership of the folder to your user, including the subfolders. That should do it
So if there is anyone having this issue here what worked for me,
{
"name": "ZedMusic",
"displayName": "zedmusic",
"expo": {}
}
the project name must be outside expo, then run npx react-native eject
When I ran react-native eject, I got this error:
Both the iOS and Android folders already exist! Please delete `ios` and/or `android` before ejecting.
Delete the MyProject/android folder.
Run react-native eject This generated the android folder
Then run react-native run-android to build android
You should consider using the new upgrade tool based on Git. It makes upgrades easier by resolving most conflicts automatically.
To use it:
- Go back to the old version of React Native
- Run "npm install -g react-native-git-upgrade"
- Run "react-native-git-upgrade"
See https://facebook.github.io/react-native/docs/upgrading.html
If you have created your project with the expo command, like expo init projectname, then afterwards you have to eject your project:
expo eject
If you have created you project by react-native init projectName then you have to use
react-native eject
May be it's too late, I replaced the Android folder from a backup file. It worked for me.