0

I am running into issues for getting my react native app on Android Studio Emulator

Before I post the problem statement, here is what I have

  • Java SE Development Kit 8

  • JAVA_HOME path variable is set

  • npm install -g expo-cli

  • expo init AwesomeProject (Sample app works fine in EXPO app using QR code scan)

  • yarn eject AwesoneProject

  • Opened Android Project in Android Studio

  • Created Virtual Device in AVD Manager

  • Installed Android SDK Platforms (7.0 - 8.1). For running Virtual device on 7.0 and my android device which is on 8.1

  • Settings on my build.gradle file. Please note the google() dependency in All dependency section, this was to get rid of one error. I don't remember what it was, solution was over web

  • build.gradle file

buildscript {

repositories {
    jcenter()
    google()
}
dependencies {
    classpath 'com.android.tools.build:gradle:3.2.1'
} }

allprojects { repositories {

    mavenLocal()
    jcenter()
    google()
    maven {
        url "$rootDir/../node_modules/react-native/android"
    }
} }

========Errors I see===========

WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.

I don't know how to solve this so I ignored this warning

  • npm run android Gives following errors

Some discussions suggests the Expo cli leaves behind following dependency causing it - "react-native": "https://github.com/expo/react-native/archive/sdk-30.0.0.tar.gz". Also it doesn't gives index.js file, can this be linked?

Any suggestions how to get it running? Any help is much appreciated.

Android Studio Erros

Raj
  • 227
  • 5
  • 13

2 Answers2

0

With gradle 3 'compile' is now obsolete. It has been replaced with 'implementation'. Go to your android/app/build.gradle and inside of the dependencies object change compile to implementation then build again.

A more detailed breakdown has been answered here What's the difference between implementation and compile in Gradle?

Chris
  • 106
  • 2
  • 4
  • Hi @Chris - This takes away the warning. Thank You for that solution. Any suggestion on the errors? – Raj Oct 21 '18 at 18:03
  • @Raj, can you provide your package.json and android/app/build.gradle file? You might want to clear out node_module and any caches. Try this: Delete ./node_modules, npm cache clean --force, cd android & ./gradlew clean, yarn install. Then try to build again. Make sure to kill your Metro builder process. I always have some issue with something sticking around during a larger changes – Chris Oct 22 '18 at 09:46
0

Update your build.gradle like this

buildscript {
    repositories {
        jcenter()
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.1'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files

    }
}

allprojects {
    repositories {
        mavenLocal()
        jcenter()
        maven {
            url "https://maven.google.com"
        }
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url "$rootDir/../node_modules/react-native/android"
        }
    }
}
Mahdi Bashirpour
  • 17,147
  • 12
  • 117
  • 144
  • Hi Mahdi- I am not sure which problem this would solve, can you please provide more details? – Raj Oct 21 '18 at 18:04