Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React Native Expo create apk

I have created some apps with React Native using Expo but this is my first time trying to build the app to update it to Play Store and App Store, first of all, I would like to make an apk to try with my devices on android which I think will be easier than iOS.

This is my package.json

{
  "name": "todolist",
  "version": "1.0.0",
  "main": "node_modules/expo/AppEntry.js",
  "scripts": {
    "start": "expo start",
    "android": "expo run:android",
    "ios": "expo run:ios",
    "web": "expo start --web",
    "eject": "expo eject"
   },
  "dependencies": {
    "@react-native-async-storage/async-storage": "1.18.2",
    "expo": "^49.0.0",
    "expo-status-bar": "~1.6.0",
    "expo-updates": "~0.18.19",
    "react": "18.2.0",
    "react-dom": "18.2.0",
    "react-native": "0.72.6",
    "react-native-web": "~0.19.6",
    "expo-splash-screen": "~0.20.5"
  },
  "devDependencies": {
    "@babel/core": "^7.20.0",
    "expo-cli": "^6.3.10"
  },
  "private": true
}

I have watched a lot of videos, read tons of webs and tutorials, but I CAN NOT create an apk, I tryed this command: npx react-native bundle --platform android --dev false --entry-file App.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res And it works, but when I try ./gradlew assembleDebug it doesn't, giving to me all of this. (I know pictures of code is not a good idea, but this is too big)

enter image description here

I created an eas.json file with the next code:

{
"build": {
    "preview": {
        "android": {
            "buildType": "apk"
        }
    },
    "preview2": {
        "android": {
            "gradleCommand": ":app:assembleRelease"
        }
    },
    "preview3": {
        "developmentClient": true
    },
    "production": {}
}
}

I logged in to my expo account and when I run the next code: eas build -p android --profile preview it gives me the next error: ✖ Build failed 🤖 Android build failed: Gradle build failed with unknown error. See logs for the "Run gradlew" phase for more information.

If I'm honest, I do not know what to do next, I am completely block, could anyone please help?

PD: If you need to see more code, just let me know what file do you need.

like image 991
Tomas Avatar asked Oct 22 '25 05:10

Tomas


1 Answers

use npx expo prebuild to generate android folder go inside that folder and run:

  • ./gradlew assembleRelease: to create .apk.
  • ./gradlew bundleRelease: to create .aab.
like image 147
Younes Ammari Avatar answered Oct 24 '25 20:10

Younes Ammari



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!