question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot run application after eject

See original GitHub issue

Description

After running npm run eject de android project cannot resolve ReactApplication and ReactNativeHost and it does not compile.

Expected Behavior

I can compile the android project generated by npm run eject and execute it in the androi emulator

Observed Behavior

The project has some errors in the imports, like ReactApplication or ReactNativeHost. The MainActivity does not implement the method getUseDeveloperSupport() that is required as it extends ReactActivity

Environment

Please run these commands in the project folder and fill in their results:

  • npm ls react-native-scripts: empty
  • npm ls react-native: react-native@0.55.4
  • npm ls expo: empty
  • node -v: v8.11.3
  • npm -v: 5.6.0
  • yarn --version: 1.9.4
  • watchman version: The term ‘watchman’ is not recognized as the name of a cmdlet

Also specify:

  1. Operating system: Microsoft Windows 10 Enterprise
  2. Phone/emulator/simulator & version: Android emulator, API 27, Android 8.1 (Google APIs)

Reproducible Demo

$ npm install -g expo-cli
$ expo init my-app
$ cd my-app/
$ npm run eject

Then open Android Studio and try to compile the Android project generated after npm eject

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:8
  • Comments:5

github_iconTop GitHub Comments

5reactions
caseychoinierecommented, Sep 26, 2018

I ran into this problem as well. It took a few days of searching to realize that there are several issues after ejecting. Here’s the things that worked for me.

One issue can be with react-native 0.56.* in the project after ejecting. It looks like you have 0.54.0 which works fine but if you don’t then consider downgrading for now. See this issue here https://github.com/react-community/create-react-native-app/issues/401

After ejecting in package.json react-native is listed as this "react-native": "https://github.com/expo/react-native/archive/sdk-30.0.0.tar.gz" which doesn’t seem to work.

To downgrade to react-native@0.55.4

You can do this by removing your node_modules, changing your package.json to use react-native@0.55.4

"dependencies": {
    "react": "16.3.1",
    "react-native": "0.55.4"
}

and then reinstalling node_modules with npm install or yarn install if using yarn.

The second issue is that you’ll need to check in your android/build.gradle and make sure that Google’s Maven repository google() is included in both buildscript {} and allprojects{}. By default it’s missing after eject. This is only the case if using a Gradle version > 4.1 though.

Something like this (although yours might look slightly different)

buildscript {
    repositories {
        google()
        jcenter()
    }
    dependencies {
       ...
    }
}

allprojects {
    repositories {
        google()
        mavenLocal()
        jcenter()
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url "$rootDir/../node_modules/react-native/android"
        }
    }
}

In addition it seems that index.js, index.android.js and index.ios.js are not created when ejecting anymore. So check for those and if they aren’t there at least create index.js in the project root and add the following to it to get started.

import { AppRegistry } from 'react-native';
import App from './App';
AppRegistry.registerComponent('the_name_of_your_ejected_app', () => App);

I’ve just gone through these steps again on a new app and confirmed that they fix the issues.

0reactions
iamchathucommented, Oct 1, 2018

This issue still exists!

Read more comments on GitHub >

github_iconTop Results From Across the Web

If you can't eject a disk on Mac because an app is using it
Quit the apps that are using the disk, then try to eject it again. If you can't quit an app, close the documents...
Read more >
Cannot run React Native app after ejecting Expo
I had a similar problem after ejecting but mine was 'Chalk was missing'. So I solved it by running the following commands:
Read more >
Cannot run ios after ejecting a bare expo project
Hi,. I created a bare expo project and ejected immediately after that. Then I run npm run ios but I get this error...
Read more >
Cannot Eject External Drive After Installing Microsoft Store App
Close any programs or windows that might be using the device and then try again.' If I remove the external drive without ejecting...
Read more >
((SOLVED)) "app is damaged and can't be opened ... - YouTube
" App is damaged and can't be opened. you should eject the disk image",, ... Cannot open application please do not forget to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found