I am new to react native and installed react native navigation 2, however, the app builds successfully but it shows me below error on an emulator.
The development server returned response error code: 500
URL: http://10.0.2.2:8081/index.delta?platform=android&dev=true&minify=false
Body:
{
"type": "TransformError",
"lineNumber": 0,
"errors": [
{
"description": "/Users/ankitsharma/Documents/Work/FITAAS/MAIN/FittassApp2/FittasApp/index.js: [BABEL] /Users/ankitsharma/Documents/Work/FITAAS/MAIN/FittassApp2/FittasApp/index.js: .overrides is not allowed in preset options",
"lineNumber": 0
}
],
"name": "SyntaxError",
"message": "/Users/ankitsharma/Documents/Work/FITAAS/MAIN/FittassApp2/FittasApp/index.js: [BABEL] /Users/ankitsharma/Documents/Work/FITAAS/MAIN/FittassApp2/FittasApp/index.js: .overrides is not allowed in preset options",
"stack": "Error: [BABEL] /Users/ankitsharma/Documents/Work/FITAAS/MAIN/FittassApp2/FittasApp/index.js: .overrides is not allowed in preset options\n at Object.keys.forEach.key (/Users/ankitsharma/Documents/Work/FITAAS/MAIN/FittassApp2/FittasApp/node_modules/@babel/core/lib/config/validation/options.js:71:13)\n at Array.forEach (<anonymous>)\n at validate (/Users/ankitsharma/Documents/Work/FITAAS/MAIN/FittassApp2/FittasApp/node_modules/@babel/core/lib/config/validation/options.js:69:21)\n at instantiatePreset (/Users/ankitsharma/Documents/Work/FITAAS/MAIN/FittassApp2/FittasApp/node_modules/@babel/core/lib/config/full.js:242:36)\n at cachedFunction (/Users/ankitsharma/Documents/Work/FITAAS/MAIN/FittassApp2/FittasApp/node_modules/@babel/core/lib/config/caching.js:42:19)\n at loadPresetDescriptor (/Users/ankitsharma/Documents/Work/FITAAS/MAIN/FittassApp2/FittasApp/node_modules/@babel/core/lib/config/full.js:233:45)\n at config.presets.map.descriptor (/Users/ankitsharma/Documents/Work/FITAAS/MAIN/FittassApp2/FittasApp/node_modules/@babel/core/lib/config/full.js:68:19)\n at Array.map (<anonymous>)\n at recurseDescriptors (/Users/ankitsharma/Documents/Work/FITAAS/MAIN/FittassApp2/FittasApp/node_modules/@babel/core/lib/config/full.js:66:38)"
}
processBundleResult
BundleDownloader.java:285
access$200
BundleDownloader.java:37
onResponse
BundleDownloader.java:163
execute
RealCall.java:153
run
NamedRunnable.java:32
runWorker
ThreadPoolExecutor.java:1162
run
ThreadPoolExecutor.java:636
run
Thread.java:764
My android/app/build.gradle
apply plugin: "com.android.application"
import com.android.build.OutputFile
project.ext.react = [
entryFile: "index.js"
]
apply from: "../../node_modules/react-native/react.gradle"
/**
* Set this to true to create two separate APKs instead of one:
* - An APK that only works on ARM devices
* - An APK that only works on x86 devices
* The advantage is the size of the APK is reduced by about 4MB.
* Upload all the APKs to the Play Store and people will download
* the correct one based on the CPU architecture of their device.
*/
def enableSeparateBuildPerCPUArchitecture = false
/**
* Run Proguard to shrink the Java bytecode in release builds.
*/
def enableProguardInReleaseBuilds = false
android {
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
defaultConfig {
applicationId "com.fittasapp"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
missingDimensionStrategy "RNN.reactNativeVersion", "reactNative56"
versionCode 1
versionName "1.0"
ndk {
abiFilters "armeabi-v7a", "x86"
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
configurations.all {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
def requested = details.requested
if (requested.group == 'com.android.support' && requested.name != 'multidex') {
details.useVersion "${rootProject.ext.supportLibVersion}"
}
}
}
splits {
abi {
reset()
enable enableSeparateBuildPerCPUArchitecture
universalApk false // If true, also generate a universal APK
include "armeabi-v7a", "x86"
}
}
buildTypes {
release {
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
}
}
// applicationVariants are e.g. debug, release
applicationVariants.all { variant ->
variant.outputs.each { output ->
// For each separate APK per architecture, set a unique version code as described here:
// http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
def versionCodes = ["armeabi-v7a":1, "x86":2]
def abi = output.getFilter(OutputFile.ABI)
if (abi != null) { // null for the universal-debug, universal-release variants
output.versionCodeOverride =
versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
}
}
}
}
dependencies {
compile project(':react-native-navigation')
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
implementation "com.facebook.react:react-native:+" // From node_modules
implementation project(':react-native-navigation')
implementation 'com.android.support:design:25.4.0'
implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
}
// Run this once to be able to run the application with BUCK
// puts all compile dependencies into folder libs for BUCK to use
task copyDownloadableDepsToLibs(type: Copy) {
from configurations.compile
into 'libs'
}
and android/build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext {
buildToolsVersion = "27.0.3"
minSdkVersion = 19
compileSdkVersion = 26
targetSdkVersion = 26
supportLibVersion = "26.1.0"
}
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 {
google()
mavenCentral()
mavenLocal()
jcenter()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
maven { url 'https://jitpack.io' }
}
}
task wrapper(type: Wrapper) {
gradleVersion = '4.4'
distributionUrl = distributionUrl.replace("bin", "all")
}
subprojects { subproject ->
afterEvaluate {
if ((subproject.plugins.hasPlugin('android') || subproject.plugins.hasPlugin('android-library'))) {
android {
variantFilter { variant ->
def names = variant.flavors*.name
if (names.contains("reactNative51") || names.contains("reactNative55")) {
setIgnore(true)
}
}
}
}
}
}
package.json
{
"name": "FittasApp",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest",
"android": "cd ./android && ./gradlew app:assembleDebug && ./gradlew installDebug"
},
"dependencies": {
"@babel/runtime": "^7.1.2",
"react": "^16.4.1",
"react-native": "^0.56.1",
"react-native-navigation": "^2.0.2575",
"react-navigation": "git+https://github.com/react-community/react-navigation.git"
},
"devDependencies": {
"babel-jest": "23.6.0",
"babel-preset-react-native": "^2.1.0",
"jest": "23.6.0",
"metro-react-native-babel-preset": "^0.47.0",
"react-test-renderer": "16.5.0"
},
"jest": {
"preset": "react-native"
}
}
Index.js
import { Navigation } from "react-native-navigation";
import App from './App';
Navigation.registerComponent("navigation.playground.WelcomeScreen", () => App);
Navigation.events().registerAppLaunchedListener(() => {
Navigation.setRoot({
root: {
component: {
name: "navigation.playground.WelcomeScreen"
}
}
});
});
I have tried many things but failed.