Error npm exited with non-zero code: 1 expo React Native - android

I'm doing a CRUD on firebase, I'm using expo for react native.
I run the command: eas build -p android --profile preview, and in the Prebuild part it gives me the error: npm exited with non-zero code: 1 so I made more errors.
These are all the errors that give me the errors:
- Creating native project directories (./ios and ./android) and updating .gitignore
✔ Created native project | gitignore skipped
- Adding Metro bundler config
✔ Added Metro config
- Updating your package.json scripts, dependencies, and main file
✔ Updated package.json and added index.js entry point for iOS and Android
› Removed "main": "node_modules/expo/AppEntry.js" from package.json because we recommend using index.js as main instead
- Config syncing
[stderr] Using node to generate images. This is much slower than using native packages.
[stderr] › Optionally you can stop the process and try again after successfully running `npm install -g sharp-cli`.
- Config syncing
[stderr] » android: userInterfaceStyle: Install expo-system-ui in your project to enable this feature.
- Config syncing
✔ Config synced
Running "npm install" in the root dir of your repository
[stderr] npm ERR! code ERESOLVE
[stderr] npm ERR! ERESOLVE could not resolve
[stderr] npm ERR!
[stderr] npm ERR! While resolving: styled-components#5.3.6
[stderr] npm ERR! Found: react#18.1.0
[stderr] npm ERR! node_modules/react
[stderr] npm ERR! react#"18.1.0" from the root project
[stderr] npm ERR! peer react#">=16.3.0" from #callstack/react-theme-provider#3.0.8
[stderr] npm ERR! node_modules/#callstack/react-theme-provider
[stderr] npm ERR! #callstack/react-theme-provider#"^3.0.7" from react-native-paper#4.12.5
[stderr] npm ERR! node_modules/react-native-paper
[stderr] npm ERR! react-native-paper#"^4.12.5" from the root project
[stderr] npm ERR! 1 more (#react-navigation/material-bottom-tabs)
[stderr] npm ERR! 20 more (#react-native-community/masked-view, ...)
[stderr] npm ERR!
[stderr] npm ERR! Could not resolve dependency:
[stderr] npm
[stderr] ERR! peer react-dom#">= 16.8.0" from styled-components#5.3.6
[stderr] npm ERR! node_modules/styled-components
[stderr] npm ERR! styled-components#"^5.3.6" from the root project
[stderr] npm ERR! peer styled-components#">= 2" from babel-plugin-styled-components#2.0.7
[stderr] npm ERR! node_modules/babel-plugin-styled-components
[stderr] npm ERR! babel-plugin-styled-components#">= 1.12.0" from styled-components#5.3.6
[stderr] npm ERR!
[stderr] npm ERR! Conflicting peer dependency: react#18.2.0
[stderr] npm ERR! node_modules/react
[stderr] npm ERR! peer react#"^18.2.0" from react-dom#18.2.0
[stderr] npm ERR! node_modules/react-dom
[stderr] npm ERR! peer react-dom#">= 16.8.0" from styled-components#5.3.6
[stderr] npm ERR! node_modules/styled-components
[stderr] npm ERR! styled-components#"^5.3.6" from the root project
[stderr] npm ERR! 1 more (babel-plugin-styled-components)
[stderr] npm ERR!
[stderr] npm ERR! Fix the upstream dependency conflict, or retry
[stderr] npm ERR! this command with --force, or --legacy-peer-deps
[stderr] npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
[stderr] npm ERR!
[stderr] npm ERR! See /home/expo/.npm/eresolve-report.txt for a full report.
[stderr] npm ERR! A complete log of this run can be found in:
[stderr] npm ERR! /home/expo/.npm/_logs/2022-11-29T23_23_53_860Z-debug-0.log
npm exited with non-zero code: 1
This is my package.json:
{
"name": "crud---",
"version": "1.0.0",
"main": "node_modules/expo/AppEntry.js",
"scripts": {
"start": "expo start",
"android": "expo start --android",
"ios": "expo start --ios",
"web": "expo start --web",
"build": "expo build"
},
"dependencies": {
"#react-native-async-storage/async-storage": "~1.17.3",
"#react-native-community/masked-view": "^0.1.11",
"#react-navigation/material-bottom-tabs": "^6.2.5",
"#react-navigation/native": "^6.0.14",
"#react-navigation/native-stack": "^6.9.2",
"dotenv": "^16.0.3",
"expo": "~47.0.8",
"expo-constants": "^14.0.2",
"expo-image-picker": "~14.0.2",
"expo-screen-orientation": "~5.0.1",
"expo-status-bar": "~1.4.2",
"firebase": "^9.6.7",
"formik": "^2.2.9",
"js-base64": "^3.7.3",
"lottie-react-native": "^5.1.4",
"react": "18.1.0",
"react-native": "0.70.5",
"react-native-gesture-handler": "^2.8.0",
"react-native-image-picker": "^4.7.0",
"react-native-masked-view": "^0.2.0",
"react-native-paper": "^4.12.5",
"react-native-progress": "^5.0.0",
"react-native-safe-area-context": "^4.4.1",
"react-native-screens": "^3.18.2",
"react-native-vector-icons": "^9.2.0",
"react-native-web": "^0.18.10",
"rn-emoji-keyboard": "^1.1.0",
"styled-components": "^5.3.6",
"yup": "^0.32.11"
},
"devDependencies": {
"#babel/core": "^7.12.9"
},
"private": true
}
How do I solve it?

I already fixed it, just remove the package-lock.json and run the command again eas build -p android --profile preview

Related

React Native (Android) - Failed to transform hermes-debug.aar

I am working on an old React Native app and want to upgrade RN version from version ^0.64.2 to 0.70.1. After using command npx react-native upgrade, there are changes in number version of dependencies. I also edit build.gradle in andriod\app folder as instructed in this document:
project.ext.react = [
enableHermes: true // clean and rebuild if changing
]
...
dependencies {
...
if (enableHermes) {
def hermesPath = "../../node_modules/hermes-engine/android/";
debugImplementation files(hermesPath + "hermes-debug.aar")
releaseImplementation files(hermesPath + "hermes-release.aar")
} else {
implementation jscFlavor
}
...
}
After that, I run command ./gradlew clean in android folder and run npx react-native run-android. Then this error shows up:
BUILD FAILED in 9s
error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:checkDebugAarMetadata'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
> Failed to transform hermes-debug.aar to match attributes {artifactType=android-aar-metadata}.
> Execution failed for JetifyTransform: D:\{ProjectFolder}\node_modules\hermes-engine\android\hermes-debug.aar.
> Transform's input file does not exist: D:\{ProjectFolder}\node_modules\hermes-engine\android\hermes-debug.aar. (See https://issuetracker.google.com/issues/158753935)
After taking a while, I also found out that there is no hermes-engine folder inside node_modules folder but still have no clue what to do.
Here is my package.json:
{
"name": "MyApp",
"version": "1.0.0",
"private": true,
"scripts": {
"android": "react-native run-android",
"ios": "react-native run-ios",
"start": "react-native start",
"test": "jest",
"lint": "eslint ."
},
"dependencies": {
"#notifee/react-native": "^3.0.4",
"#react-native-async-storage/async-storage": "^1.17.10",
"#react-native-community/art": "^1.2.0",
"#react-native-community/datetimepicker": "^3.5.2",
"#react-native-firebase/app": "^12.9.0",
"#react-native-firebase/messaging": "^12.9.0",
"#react-navigation/material-top-tabs": "^6.2.1",
"#react-navigation/native": "^6.0.1",
"#react-navigation/stack": "^6.2.1",
"axios": "^0.24.0",
"fbjs": "^3.0.4",
"jest": "^26.6.3",
"jwt-decode": "^3.1.2",
"moment": "^2.29.3",
"moment-timezone": "^0.5.34",
"prop-types": "^15.8.1",
"react": "18.1.0",
"react-native": "0.70.1",
"react-native-biometrics": "^2.1.4",
"react-native-camera": "^3.35.0",
"react-native-chart-kit": "^6.12.0",
"react-native-elements": "^2.0.4",
"react-native-file-viewer": "^2.1.1",
"react-native-fs": "^2.20.0",
"react-native-gesture-handler": "^1.10.3",
"react-native-image-crop-picker": "^0.32.2",
"react-native-modal": "^11.5.6",
"react-native-pager-view": "^5.4.24",
"react-native-pdf": "^6.2.0",
"react-native-picker-select": "^8.0.0",
"react-native-pie-chart": "^2.0.2",
"react-native-render-html": "^6.3.4",
"react-native-safe-area-context": "^3.0.2",
"react-native-screens": "^3.13.1",
"react-native-simple-toast": "^1.1.2",
"react-native-svg": "^12.1.1",
"react-native-swipe-list-view": "^3.2.9",
"react-native-tab-view": "^3.1.1",
"react-native-vector-icons": "^7.0.0",
"react-navigation": "^4.4.0",
"react-query": "^3.34.2",
"react-redux": "^7.2.0",
"redux": "^4.0.5",
"redux-devtools-extension": "^2.13.8",
"redux-thunk": "^2.3.0",
"toggle-switch-react-native": "^3.3.0"
},
"devDependencies": {
"#react-native-community/eslint-config": "^2.0.0",
"babel-plugin-root-import": "^6.5.0",
"eslint": "^7.14.0",
"react-test-renderer": "^17.0.1"
},
"jest": {
"preset": "react-native"
}
}
Update: The error still occur after I edited package.json and use npm install to add hermes-engine. Here are the errors:
npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR!
npm ERR! While resolving: react-query#3.34.2
npm ERR! Found: react#18.1.0
npm ERR! node_modules/react
npm ERR! react#"18.1.0" from the root project
npm ERR! peer react#"*" from #jsamr/react-native-li#2.3.1
npm ERR! node_modules/#jsamr/react-native-li
npm ERR! #jsamr/react-native-li#"^2.3.0" from react-native-render-html#6.3.4
npm ERR! node_modules/react-native-render-html
npm ERR! react-native-render-html#"^6.3.4" from the root project
npm ERR! 27 more (#react-native-community/art, ...)
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react#"^16.8.0 || ^17.0.0" from react-query#3.34.2
npm ERR! node_modules/react-query
npm ERR! react-query#"^3.34.2" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: react#17.0.2
npm ERR! node_modules/react
npm ERR! peer react#"^16.8.0 || ^17.0.0" from react-query#3.34.2
npm ERR! node_modules/react-query
npm ERR! react-query#"^3.34.2" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
I'm also upgrading RN version to 0.70.1, from 0.69.x you have some changes to do in app/build.gradle about hermes.
...
if (enableHermes) {
implementation("com.facebook.react:hermes-engine:+") {
exclude group: 'com.facebook.fbjni'
}
} else {
implementation jscFlavor
}
...
Source: Bundled Hermes Documentation
Try to add this to your package.json and npm install again with --legacy-peer-deps option:
"dependencies": {
"hermes-engine": "^0.11.0",
},
I went through the same error and followed the solution suggested by #fernando-garcía, but to my case it was not enough.
Indeed, I was getting the error:
TypeError: Cannot read property 'isBatchingLegacy' of undefined, js engine: hermes
The problem is definitely due to hermes, but I had to tune some other things to properly update my react-native application and let it work with react-native 0.70.0.
Here the steps I had to do to properly update my React-Native application in order to solve the problem:
Add the following snippets in android/app/build.gradle:
dependencies {
...
if (enableHermes) {
//noinspection GradleDynamicVersion
implementation("com.facebook.react:hermes-engine:+") {
exclude group:'com.facebook.fbjni'
}
}
}
if (isNewArchitectureEnabled()) {
// If new architecture is enabled, we let you build RN from source
// Otherwise we fallback to a prebuilt .aar bundled in the NPM package.
// This will be applied to all the imported transtitive dependency.
configurations.all {
resolutionStrategy.dependencySubstitution {
substitute(module("com.facebook.react:react-native"))
.using(project(":ReactAndroid"))
.because("On New Architecture we're building React Native from source")
substitute(module("com.facebook.react:hermes-engine"))
.using(project(":ReactAndroid:hermes-engine"))
.because("On New Architecture we're building Hermes from source")
}
}
}
add the following inside android/settings.gradle:
if (settings.hasProperty("newArchEnabled") && settings.newArchEnabled == "true") {
include(":ReactAndroid")
project(":ReactAndroid").projectDir = file('../node_modules/react-native/ReactAndroid')
include(":ReactAndroid:hermes-engine")
project(":ReactAndroid:hermes-engine").projectDir = file('../node_modules/react-native/ReactAndroid/hermes-engine')
}
update the react dependency inside your package.json (I had 17.0.2 and I had to update to 18.1.10):
dependencies {
...
"react": "18.1.0"
}
I am also interested about this issue, the same thing is happening for me, I already checked the Upgrade Helper, and I am upgrading from 0.68.5 to 0.70.1.
I still haven't turned on the NEW_ARCHITECTURE flag.
Installing hermes-engine package seems like not a good solution, since the upgrade steps doesn't mention that it should be done.

Difficulties enabling Kotlin in React Native Expo with Bare Workflow

Saying that I've spent around 32 hours would be an understatement. I've been trying to enable Kotlin in a React Native project powered by Expo SDK 44.
I've been trying everything that I could find over the Internet, but it always ends up with an error in the Gradle Phase in EAS (Running it with eas build --profile development --platform android) .
Here are my configurations:
I'm omitting code for brevity. If you need more context, let me know
app\android\build.gradle:
buildscript {
ext {
buildToolsVersion = "30.0.2"
minSdkVersion = 21
compileSdkVersion = 31
targetSdkVersion = 31
kotlinVersion = "1.4.11"
}
repositories {
google()
mavenCentral()
jcenter()
}
dependencies {
classpath("com.android.tools.build:gradle:4.1.0")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion")
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
apply plugin: "kotlin-android"
apply plugin: "kotlin-android-extensions"
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
//noinspection GradleDynamicVersion
implementation "com.facebook.react:react-native:+" // From node_modules
implementation project(':react-native-plaid-link-sdk')
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.3'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.3'
implementation 'androidx.core:core-ktx:1.1.0'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlinVersion"
// Other comed omitted
}
Here's my package.json
{
"name": "#pana/app",
"version": "22.0220",
"private": true,
"scripts": {
"start": "expo start --dev-client",
"android": "expo run:android",
"ios": "expo run:ios",
"eject": "expo eject",
"extract": "lingui extract",
"compile": "lingui compile",
"lint": "eslint src/** --ext .ts,.tsx",
"lint:fix": "yarn lint --fix",
"test": "jest",
"graphql:generate": "graphql-codegen --config codegen.yml",
"build": ""
},
"dependencies": {
"#apollo/client": "^3.5.10",
"#apollo/link-context": "^2.0.0-beta.3",
"#expo/react-native-action-sheet": "^3.13.0",
"#intercom/intercom-react-native": "^3.0.0",
"#lingui/react": "^3.13.2",
"#onfido/react-native-sdk": "^5.1.0",
"#react-native-async-storage/async-storage": "~1.15.0",
"#react-native-community/datetimepicker": "4.0.0",
"#react-navigation/bottom-tabs": "^6.3.1",
"#react-navigation/native": "^6.0.8",
"#react-navigation/stack": "^6.1.1",
"#reduxjs/toolkit": "^1.8.0",
"#segment/analytics-react-native": "^2.1.12",
"#segment/sovran-react-native": "^0.2.6",
"#sentry/react-native": "^3.2.13",
"axios": "^0.25.0",
"dayjs": "^1.10.8",
"expo": "~44.0.0",
"expo-application": "~4.0.1",
"expo-auth-session": "~3.5.0",
"expo-cellular": "~4.1.0",
"expo-clipboard": "~2.1.0",
"expo-constants": "~13.0.1",
"expo-crypto": "~10.1.1",
"expo-dev-client": "~0.8.5",
"expo-device": "~4.1.0",
"expo-document-picker": "~10.1.3",
"expo-image-loader": "~3.1.0",
"expo-image-picker": "~12.0.2",
"expo-linear-gradient": "~11.0.3",
"expo-local-authentication": "~12.1.0",
"expo-random": "~12.1.1",
"expo-secure-store": "~11.1.0",
"expo-splash-screen": "~0.14.1",
"expo-status-bar": "~1.2.0",
"expo-updates": "~0.11.7",
"make-plural": "^7.1.0",
"react": "17.0.1",
"react-dom": "17.0.1",
"react-native": "0.64.3",
"react-native-animated-progress": "^1.0.2",
"react-native-country-picker-modal": "^2.0.0",
"react-native-dotenv": "^3.3.1",
"react-native-gesture-handler": "~2.1.0",
"react-native-keyboard-aware-scroll-view": "^0.9.5",
"react-native-phone-number-input": "^2.1.0",
"react-native-plaid-link-sdk": "^7.4.0",
"react-native-safe-area-context": "3.3.2",
"react-native-screens": "~3.10.1",
"react-native-shimmer-placeholder": "^2.0.8",
"react-native-svg": "12.1.1",
"react-native-uuid": "^2.0.1",
"react-native-web": "0.17.1",
"react-native-webview": "11.15.0",
"react-redux": "^7.2.6",
"semver-compare": "^1.0.0",
"sentry-expo": "^4.0.0",
"styled-components": "5.2.0",
"styled-system": "^5.1.5",
"validate.js": "^0.13.1"
},
"devDependencies": {
"#babel/core": "^7.12.9",
"#graphql-codegen/cli": "2.6.2",
"#graphql-codegen/typescript": "2.4.8",
"#graphql-codegen/typescript-operations": "2.3.5",
"#graphql-codegen/typescript-react-apollo": "3.2.11",
"#lingui/cli": "^3.13.2",
"#lingui/macro": "^3.13.2",
"#react-native-community/eslint-config": "^3.0.1",
"#types/jest": "^27.4.0",
"#types/react": "~17.0.21",
"#types/react-native": "~0.64.12",
"#types/react-native-animated-progress": "^1.0.0",
"#types/react-native-dotenv": "^0.2.0",
"#types/react-redux": "^7.1.23",
"#types/semver-compare": "^1.0.1",
"#types/styled-components": "^5.1.24",
"#types/styled-components-react-native": "5.1.0",
"#types/styled-system": "^5.1.15",
"#typescript-eslint/eslint-plugin": "^5.10.2",
"#typescript-eslint/parser": "^5.10.2",
"eslint": "^8.8.0",
"eslint-config-airbnb": "^19.0.4",
"eslint-config-prettier": "^8.3.0",
"eslint-import-resolver-typescript": "^2.5.0",
"eslint-plugin-flowtype": "^8.0.3",
"eslint-plugin-import": "^2.25.4",
"eslint-plugin-jest": "^26.1.0",
"eslint-plugin-jsx-a11y": "^6.5.1",
"eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-react": "^7.28.0",
"eslint-plugin-react-hooks": "^4.3.0",
"graphql": "^16.3.0",
"install-peers": "^1.0.3",
"jest": "^27.5.0",
"prettier": "^2.5.1",
"react-native-config": "^1.4.5",
"react-native-svg-transformer": "^1.0.0",
"remote-redux-devtools": "^0.5.16",
"ts-jest": "^27.1.3",
"typescript": "~4.3.5"
},
"jest": {
"preset": "react-native",
"moduleFileExtensions": [
"ts",
"tsx",
"js",
"jsx",
"json",
"node"
]
},
"resolutions": {
"react-devtools-core": "4.14.0",
"#types/react": "17.0.21",
"#types/react-dom": "17.0.01"
}
}
Here's my folder structure:
Here's MyAppPackage.kt (android\app\src\main\java\com\pana\MyAppPackage.kt)
package com.pana // replace your-app-name with your app’s name
import android.view.View
import com.facebook.react.ReactPackage
import com.facebook.react.bridge.NativeModule
import com.facebook.react.bridge.ReactApplicationContext
import com.facebook.react.uimanager.ReactShadowNode
import com.facebook.react.uimanager.ViewManager
class MyAppPackage : ReactPackage {
override fun createViewManagers(
reactContext: ReactApplicationContext
): MutableList<ViewManager<View, ReactShadowNode<*>>> = mutableListOf()
override fun createNativeModules(
reactContext: ReactApplicationContext
): MutableList<NativeModule> = listOf(CalendarModule(reactContext)).toMutableList()
}
Here are some of the SO resources that I've resarched:
ERROR ----> Task :expo-permissions:compileDebugKotlin FAILED
React native android build is failing after configured kotlin-gradle-plugin, kotlin-android and kotlin-android-extensions
Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.15
warning: Kotlin runtime JAR files in the classpath should have the same version
Android Studio shows Kotlin Dependency Warning after Second Build
Why do I have different versions of Kotlin JARs in the classpath?
flutter build Runtime JAR files in the classpath should have the same version. These files were found in the classpath
warning: Kotlin runtime JAR files in the classpath should have the same version
Installing Kotlin-Jupyter: e: java.lang.NoClassDefFoundError: Could not initialize class org.jetbrains.kotlin.com.intellij.pom.java.LanguageLevel
Here are some othe resources that I've looked into:
https://www.youtube.com/watch?v=wk_cR66AVXQ&t=114s
https://www.youtube.com/watch?v=GWcEVk7SgOg&t=44s
https://github.com/circleci/circleci-docs/issues/2945#issuecomment-471637158
https://developer.android.com/kotlin/add-kotlin
Here are some of the errors and fixes that I've tried:
1 - Minimal Incrementing the project to barebones Kotlin
I've tried minimally incrementing my current project (Note that I had to set the compileSdkVersion and targetSdkVersion to 31 for an Intercom package, and that is building successfully). I've followed this video,the official React Native Docs, and the Add Kotlin to an existing app with Android Studio (Manual Approach).
a. (android/build.gradle) Added (Inside buildscript.ext) kotlin_version = '1.4.10'
b. (android/build.gradle) Added (Inside dependencies) classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
c. (android/app/build.gradle) Added (at the top of the file) apply plugin: "kotlin-android"
Tried to compile:
[stderr] Note: Recompile with -Xlint:deprecation for details.
> Task :app:compileDebugKotlin FAILED w: Runtime JAR files in the classpath should have the same version. These files were found in the classpath:
/home/expo/.gradle/caches/transforms-3/f47aaec93b5ce8275ab670559bc858c7/transformed/jetified-kotlin-stdlib-jdk8-1.5.31.jar (version 1.5)
/home/expo/.gradle/caches/transforms-3/e30ac7ea6364b484c3bc3c923afeabd2/transformed/jetified-kotlin-stdlib-jdk7-1.5.31.jar (version 1.5)
/home/expo/.gradle/caches/transforms-3/d9723caca13068e43e601371da49b5b2/transformed/jetified-kotlin-stdlib-1.6.10.jar (version 1.6)
/home/expo/.gradle/caches/transforms-3/c5966235c8aa66a583bf2afcd9edd1b7/transformed/jetified-kotlin-stdlib-common-1.6.10.jar (version 1.6) w: Some runtime JAR files in the classpath have an incompatible version. Consider removing them from the classpath [stderr] e: /home/expo/.gradle/caches/transforms-3/c5966235c8aa66a583bf2afcd9edd1b7/transformed/jetified-kotlin-stdlib-common-1.6.10.jar!/META-INF/kotlin-stdlib-common.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.4.0.
2 - Pushing Kotlin to Version 1.6.10
Seeing this, led me to some research and suggested to push the Kotlin version to 1.6.10:
Task :expo-dev-launcher:compileDebugKotlin
[stderr] Compilation with Kotlin compile daemon was not successful
[stderr] java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
[stderr] java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
[stderr] java.io.InvalidClassException: org.jetbrains.kotlin.incremental.IncrementalModuleInfo; local class incompatible: stream classdesc serialVersionUID = 1, local class serialVersionUID = 0
[stderr] at java.rmi/sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:391)
[stderr] at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:200)
[stderr] at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:197)
[stderr] at java.base/java.security.AccessController.doPrivileged(Native Method)
[stderr] at java.rmi/sun.rmi.transport.Transport.serviceCall(Transport.java:196)
[stderr] at java.rmi/sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:562)
[stderr] at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:796)
[stderr] at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:677)
[stderr] at java.base/java.security.AccessController.doPrivileged(Native Method)
[stderr] at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:676)
[stderr] at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
[stderr] at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
[stderr] at java.base/java.lang.Thread.run(Thread.java:829)
[stderr] at java.rmi/sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:303)
[stderr] at java.rmi/sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:279)
[stderr] at java.rmi/sun.rmi.server.UnicastRef.invoke(UnicastRef.java:164)
This lead me to update to run expo upgrade and expo doctor to see if any of the updates would work. This opened Pandora's box. Upgrading to expo SDK 45 came with its own issues (apparently I have some conflicting packages that throw the following errors):
[stderr] Note: /home/expo/workingdir/build/app/node_modules/#sentry/react-native/android/src/main/java/io/sentry/react/RNSentryModule.java uses or overrides a deprecated API.
[stderr] Note: Recompile with -Xlint:deprecation for details.
> Task :app:compileDebugJavaWithJavac FAILED
[stderr] /home/expo/workingdir/build/app/android/app/src/main/java/app/pana/MainApplication.java:6: error: package android.app does not exist
[stderr] import android.app.Application;
[stderr] ^
[stderr] /home/expo/workingdir/build/app/android/app/src/main/java/app/pana/MainApplication.java:7: error: package android.content does not exist
[stderr] import android.content.Context;
[stderr] ^
[stderr] /home/expo/workingdir/build/app/android/app/src/main/java/app/pana/MainApplication.java:8: error: package android.content.res does not exist
[stderr] import android.content.res.Configuration;
[stderr] ^
[stderr] /home/expo/workingdir/build/app/android/app/src/main/java/app/pana/MainApplication.java:10: error: package android.webkit does not exist
[stderr] import android.webkit.WebView;
There were other builds that failed with the expo-dev-client. I'm also aware of a bug in the SDK 45 that you will have problems with Hermes enabled. We're using JSC.
3 - A bunch of other things
Just to prevent this question from becoming longer, here are other things that I've tried:
a. Changing the distributionUrl in the gradle-wrapper.properties to a more recent gradle version.
b. Updating, and mathcing the org.jetbrains.kotlin:kotlin-gradle-plugin (in android/build.gradle), org.jetbrains.kotlin:kotlin-stdlib-jdk7 (changed it to jdk8 and nothing), org.jetbrains.kotlinx:kotlinx-coroutines-core, org.jetbrains.kotlinx:kotlinx-coroutines-android, androidx.core:core-ktx with the corresponding kotlin versions.
c. Added these implementations inside a debugImplementation statement.
d. Researched React Native versions corresponding with Kotlin (Don't know if Version 0.64 which is Expo's SDK 44 supports Kotlin 1.6.10).
e. Checked for syntax errors using Android Studio.
f. Ran gradlew clean.
g. And other things...
Does anyone know anything? There doesn't seem to be anything reported in the Expo GitHub.
The following packagingOptions seems to help mitigate some of the issues
// android/app/build.gradle
android {
// This fixes a bug when
// https://github.com/facebook/react-native/issues/33120
packagingOptions {
jniLibs.useLegacyPackaging = true
}

React native(android) assembleRelease gets bundle assembling error

{
"version": "0.0.1",
"private": true,
"scripts": {
"android": "react-native run-android",
"start": "node node_modules/react-native/local-cli/cli.js start",
"load-script": "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",
"test": "jest"
},
"dependencies": {
"#react-native-community/async-storage": "1.7.1",
"axios": "^0.18.0",
"native-base": "^2.12.1",
"prop-types": "^15.7.2",
"react": "16.8.3",
"react-native": "0.59.5",
"react-native-extended-stylesheet": "^0.11.1",
"react-native-gesture-handler": "1.4.0",
"react-native-image-slider": "^2.0.3",
"react-native-linear-gradient": "^2.5.6",
"react-native-snap-carousel": "^3.8.4",
"react-navigation": "^3.11.1",
"react-redux": "^7.1.3",
"redux": "^4.0.1",
"redux-logger": "^3.0.6",
"redux-persist": "^5.10.0",
"redux-thunk": "^2.3.0"
},
"devDependencies": {
"#babel/core": "7.4.4",
"#babel/runtime": "7.4.4",
"babel-jest": "24.7.1",
"eslint-config-rallycoding": "^3.2.0",
"jest": "24.7.1",
"jetifier": "^1.6.5",
"metro-react-native-babel-preset": "0.54.0",
"react-test-renderer": "16.8.3",
"redux-devtools": "^3.5.0",
"remote-redux-devtools": "^0.5.0"
},
"jest": {
"preset": "react-native"
}
}
//build.gradle android
buildscript {
ext {
buildToolsVersion = "28.0.3"
minSdkVersion = 16
compileSdkVersion = 28
targetSdkVersion = 28
supportLibVersion = "28.0.0"
}
}
i ran .\gradlew assembleRelease and it crashed after that i ran the same command with --info and this is what it's showing me
i've tried upgrading and down grading and removing some of unused libs but nothing changed.
> Task :app:bundleReleaseJsAndAssets
Caching disabled for task ':app:bundleReleaseJsAndAssets' because:
Build cache is disabled
Task ':app:bundleReleaseJsAndAssets' is not up-to-date because:
Task has failed previously.
Starting process 'command 'cmd''. Working directory: C:\Users\MOBILE1\Desktop\Gitlab-Devloper-Branch\dev-branch\build-apk-error-last\mbz-mobile-app Command: cmd /c node node_modules/react-native/cli.js bundle --platform android --dev false --reset-cache --entry-file index.android.js --bundle-output C:\Users\MOBILE1\Desktop\Gitlab-Devloper-Branch\dev-branch\build-apk-error-last\mbz-mobile-app\android\app\build\generated\assets\react\release\index.android.bundle --assets-dest C:\Users\MOBILE1\Desktop\Gitlab-Devloper-Branch\dev-branch\build-apk-error-last\mbz-mobile-app\android\app\build\generated\res\react\release
Successfully started process 'command 'cmd''
warning: the transform cache was reset.
error The resource `C:\Users\MOBILE1\Desktop\Gitlab-Devloper-Branch\dev-branch\build-apk-error-last\mbz-mobile-app\index.android.js` was not found.. Run CLI with --verbose flag for more details.
> Task :app:bundleReleaseJsAndAssets FAILED
:app:bundleReleaseJsAndAssets (Thread[Execution worker for ':' Thread 6,5,main]) completed. Took 3.955 secs.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:bundleReleaseJsAndAssets'.
i also get uses or overrides a deprecated API and Deprecated Gradle features were used, making it incompatible with Gradle 6.0 for react-native-gesture-handler in android studio. i get
Try this once , ./gradlew assembleRelease -x bundleReleaseJsAndAssets please check once.
UPDATE:
gradlew assembleRelease will only build/bundle your application for production. You need to sign the APK file yourself.
These are the steps which I take when I want to run my application in production mode:
1.keytool -genkey -v -keystore key.keystore -alias app-alias -keyalg RSA -keysize 2048 -validity 10000
2.cd android && gradlew assembleRelease && cd ..
3.jarsigner -verbose -keystore \path_to_key\key.keystore \path_to_apk\app-release-unsigned.apk app-alias
4.zipalign -f -v 4 \path_to_apk\app-release-unsigned.apk appName.apk
Follow these steps and your app should be installed successfully.
Do revert in case of any concerns.
Please use the same compileSdkVersion, buildToolsVersion and support library projects as in the main application project.

React-Native - react-native-update-gradle - Error

i had an error with my React-Native Project for Android.
My first error was the following:
I added the "react-native-location" Library. After i run the Command "react-native link", the error "compileOnly" was thrown.
So my first try was, upadate NPM and Node.JS.
But it wasn´t the right solution for my Problem.
After that, i had google the Error and i want to update grandle with "react-native-update-gradle". My main Problem now is, when i run the "react-native link" command, i get the following error:
C:\Computer\Apps\Projects\XXX>react-native link
Scanning folders for symlinks in C:\Computer\Apps\Projects\XXX\node_modules (70ms)
rnpm-install info Platform 'ios' module react-native-orientation is already linked
rnpm-install info Platform 'android' module react-native-orientation is already linked
internal/validators.js:125
throw new ERR_INVALID_ARG_TYPE(name, 'string', value);
^
TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type undefined
at validateString (internal/validators.js:125:11)
at Object.join (path.js:427:7)
at getSDKPath (C:\Computer\Apps\Projects\XXX\node_modules\react-native-update-gradle\index.js:13:12)
at getPTPath (C:\Computer\Apps\Projects\XXX\node_modules\react-native-update-gradle\index.js:17:20)
at Object.activateADB (C:\Computer\Apps\Projects\XXX\node_modules\react-native-update-gradle\index.js:5:42)
at Object.<anonymous> (C:\Computer\Apps\Projects\XXX\node_modules\react-native-update-gradle\cli.js:101:6)
at Module._compile (internal/modules/cjs/loader.js:734:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:745:10)
at Module.load (internal/modules/cjs/loader.js:626:32)
at tryModuleLoad (internal/modules/cjs/loader.js:566:12)
C:\Computer\Apps\Projects\XXX\node_modules\react-native\local-cli\core\makeCommand.js:27
throw new Error(`Error occurred during executing "${command}" command`);
^
Error: Error occurred during executing "node ./node_modules/react-native-update-gradle/cli.js" command
at ChildProcess.prelink (C:/Computer/Apps/Projects/XXX/node_modules/react-native/local-cli/core/makeCommand.js:27:15)
at ChildProcess.emit (events.js:197:13)
at maybeClose (internal/child_process.js:978:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:265:5)
I tried to fix the Error, but the error is still there.
I had the following Environments
Window 10
React-Native 0.55.4
React-Native-Cli 2.0.1
NodeJS v11.9.0
npm 4.6.0
android/build.gradle
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
}
}
allprojects {
repositories {
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://maven.google.com'
}
}
}
ext {
compileSdkVersion = 28
targetSdkVersion = 28
buildToolsVersion = "28.0.3"
supportLibVersion = "28.1.1"
playServicesVersion = "15.0.1"
}
package.json
{
"name": "XXX",
"version": "1.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest",
"run-android": "react-native run-android"
},
"dependencies": {
"react": "16.3.1",
"react-native": "0.55.4",
"react-native-image-slider": "^2.0.3",
"react-native-image-zoom-viewer": "^2.2.25",
"react-native-orientation": "^3.1.3",
"react-native-pinch-zoom-view": "^0.1.6",
"react-native-responsive-image": "^2.3.1",
"react-native-router-flux": "^4.0.0-beta.28",
"react-native-scrolltotop": "0.0.6",
"react-native-slideshow": "^1.0.1",
"react-native-swipe-gestures": "^1.0.2",
"react-native-update-gradle": "^1.1.0",
"react-native-vector-icons": "^4.6.0",
"react-native-zoom-view": "^1.0.2"
},
"devDependencies": {
"babel-jest": "22.4.3",
"babel-preset-react-native": "4.0.0",
"jest": "22.4.3",
"react-test-renderer": "16.3.1"
},
"jest": {
"preset": "react-native"
}
}
If you need more information to help me, please tell me that.
Thanks for your help.
Best Regards
Hi Sebastian ! After you run the command react-native link, you have to run the command react-native run-android or react-native run-ios. So that the library you have installed adjusts to your react native settings. This is work for me, after I installed the library or package. hope this helps.

How to enable stacktrace react-native run-android command?

I'm running a react native project via the react-native run-android. But during the build it fails stating that :react-native-device-info:processReleaseResources FAILED. Which doesn't give much info, so I tried running with react-native run-android --stacktrace as suggested but that isn't a recognized command.
How can you enable stacktrace / verbose logging with react-native run-android command?
This is the detail of the error which is too short to figure out at build:
:react-native-device-info:processReleaseResources FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':react-native-device-info:processReleaseResources'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Users\Brian\AppData\Local\Android\sdk\build-tools\23.0.1\aapt.exe'' finished with non-zero exit value 1
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: -12.542 secs
Package.json for reference:
{
"name": "StarterKit",
"version": "1.0.0",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest"
},
"jest": {
"preset": "react-native",
"setupFiles": [
"<rootDir>/jest.setup.js"
],
"transformIgnorePatterns": [
"node_modules/(?!react-native|tcomb-form-native|apsl-react-native-button,react-native-device-info|react-clone-referenced-element)"
],
"collectCoverage": true,
"verbose": true
},
"dependencies": {
"html-entities": "^1.2.0",
"jwt-decode": "^2.1.0",
"qs": "^6.3.0",
"react": "15.4.2",
"react-addons-shallow-compare": "^15.4.2",
"react-native": "^0.40.0",
"react-native-device-info": "^0.9.6",
"react-native-elements": "^0.9.2",
"react-native-google-analytics-bridge": "git+https://github.com/mcnamee/react-native-google-analytics-bridge.git",
"react-native-router-flux": "^3.37.0",
"react-native-side-menu": "^0.20.1",
"react-native-tab-view": "0.0.48",
"react-native-vector-icons": "^4.0.0",
"react-redux": "^5.0.1",
"redux": "^3.6.0",
"redux-logger": "^2.7.0",
"redux-thunk": "^2.1.0",
"striptags": "^2.1.1",
"tcomb-form-native": "^0.6.1"
},
"devDependencies": {
"babel-core": "^6.17.0",
"babel-eslint": "^7.1.0",
"babel-jest": "18.0.0",
"babel-preset-es2015": "^6.18.0",
"babel-preset-react-native": "1.9.1",
"babel-register": "^6.16.3",
"eslint": "^3.9.1",
"eslint-config-airbnb": "^14.0.0",
"eslint-plugin-import": "^2.2.0",
"eslint-plugin-jsx-a11y": "^3.0.2",
"eslint-plugin-react": "^6.4.1",
"invariant": "^2.2.2",
"jest": "18.1.0",
"jest-react-native": "^18.0.0",
"react-test-renderer": "15.4.2"
}
}
build.gradle file:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
mavenLocal()
jcenter()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
}
}
#EricHua23's answer is basically correct, except that instead of running ./gradlew assembleDebug --stacktrace, you should run ./gradlew.bat installDebug --stacktrace, as this is the command that's actually run by react-native run-android. (and some of the errors you'd want to get the stack-trace for only occur in the installing/late-build portion, rather than the assembly portion)
Also, make sure you run it in the android folder. (so run cd android in the console before running the gradlew command)
Try to build react-native-device-info separately with ./gradlew assembleDebug and make sure react-native-device-info is all right. I have the same problems because of my network which is blocked and can not reach jcenter.
By the way, --stacktrace should be add as gradle parameters, I doubt react-native does not pass it to gradle.
If running on Windows run following command in your project's root directory:
1. cd android
2. gradlew.bat installDebug --stacktrace
I use package.json file like this, for shortcut to shell commands, in my ViroMedia Sample App:
{
"name": "ViroSample",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"android": "react-native run-android --variant arrelease",
"and_bundle": "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",
"ios": "react-native run-ios",
"gradle_build": "cd android && ./gradlew --stacktrace --info assembleRelease -x bundleArReleaseJsAndAssets",
"gradle_install": "cd android && ./gradlew installArDebug --stacktrace --info",
"test": "jest"
},
"dependencies": {
"axios": "^0.19.0",
"expo": "^35.0.0",
"react": "16.8.3",
"react-native": "^0.61.5",
"react-viro": "2.15.0"
},
"devDependencies": {
"#babel/core": "^7.5.5",
"#babel/runtime": "^7.5.5",
"babel-jest": "^24.8.0",
"jest": "^24.8.0",
"metro-react-native-babel-preset": "^0.55.0",
"react-test-renderer": "16.8.3"
},
"jest": {
"preset": "react-native"
}
}
I issue the following command from my project root directory (iMac bash shell):
yarn gradle_install
Please see the script block above for other shell commands.
Note: in windows this is gradlew.bat.
Happy Coding :-)
From mac this will work
1. cd android
2. ./gradlew installDebug --stacktrace
Give a try to react-native start
This shows errors verbosely.

Categories

Resources