skip to Main Content

I want to release my react native app to Google play store after upgrading it to new SDK but I am facing a problem in releasing it in AAB format. I am able to run my app in the emulator but not when i ran npx react-native build-android --mode=release as stated in the documentation.

Error

Starting Metro Bundler
warning: Bundler cache is empty, rebuilding (this may take a minute)
Error: Unable to resolve module .index.js from C:UsersuserDocumentsmadeeasyfinalMadeEasyLearningAppView/.: .index.js could not be found within the project or in these directories:       

> Task :app:createBundleReleaseJsAndAssets FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:createBundleReleaseJsAndAssets'.
> Process 'command 'cmd'' finished with non-zero exit value 1
   
error Failed to build the app.
Error: Command failed with exit code 1: gradlew.bat app:bundleRelease
    at makeError (C:UsersuserDocumentsmadeeasyfinalMadeEasyLearningAppViewnode_modules@react-native-communitycli-platform-androidnode_modulesexecaliberror.js:60:11)
    at module.exports.sync (C:UsersuserDocumentsmadeeasyfinalMadeEasyLearningAppViewnode_modules@react-native-communitycli-platform-androidnode_modulesexecaindex.js:194:17)
    at build (C:UsersuserDocumentsmadeeasyfinalMadeEasyLearningAppViewnode_modules@react-native-communitycli-platform-androidbuildcommandsbuildAndroidindex.js:68:22)
    at Object.buildAndroid [as func] (C:UsersuserDocumentsmadeeasyfinalMadeEasyLearningAppViewnode_modules@react-native-communitycli-platform-androidbuildcommandsbuildAndroidindex.js:60:10)
    at Command.handleAction ...

I do have my index.js file in the directory C:UsersuserDocumentsmadeeasyfinalMadeEasyLearningAppViewindex.js so not sure what went wrong

What i have done

  1. react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res then ./gradlew assembleRelease -x bundleReleaseJsAndAssets but I am getting Task 'bundleReleaseJsAndAssets' not found in root project

  2. Disabled the enabledHermes but it still doesnt work as well

I would appreciate any help with this matter. Thank you in advance

Edit:

This is my index.js

import { registerRootComponent } from 'expo';
import App from './src/App';
import {name as appName} from './app.json';
import 'react-native-gesture-handler';

// registerRootComponent calls AppRegistry.registerComponent('main', () => App);
// It also ensures that whether you load the app in Expo Go or in a native build,
// the environment is set up appropriately
registerRootComponent(App);

and this is my app.json

{
  "expo": {
    "name": "mydoctor",
    "slug": "mydoctor",
    "version": "1.0.0",
    "sdkVersion": "43.0.0",
    "platforms": ["ios", "android"],
    "entryPoint": "index.js",
    "updates": {
      "fallbackToCacheTimeout": 0
    },
    "assetBundlePatterns": ["**/*"],
    "ios": {
      "supportsTablet": true
    },
    "android": {
      "adaptiveIcon": {
        "foregroundImage": "./assets/adaptive-icon.png",
        "backgroundColor": "#FFFFFF"
      }
    },
    "web": {
      "favicon": "./assets/favicon.png"
    }
  }
}

2

Answers


  1. Chosen as BEST ANSWER

    I just changed from Expo to React Native and it worked, not sure why it didnt work for expo


  2. Try specifying the index.js file path explicitly.
    In the react-native bundle command, try specifying the index.js file path explicitly, like this :

    react-native bundle --platform android --dev false --entry-file./index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res
    

    Reset Metro Bundler Cache

    npx react-native start --reset-cache
    

    Try This steps

    cd android  
    ./gradlew clean 
    ./gradlew assembleRelease -x bundleReleaseJsAndAssets
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search