Closed ablack34 closed 1 year ago
FYI this StackOverflow is very similar to my issue but it is nearly 4 years old so may vary slightly. I have tried following it but if anyone can help explain or point me to more possible solutions that would be great.
i'm experiencing the same issue since upgrading a dependency. I've also tried a clean install, downgrading the dependencies, further upgrading them but i can't the app running. (Can also confirm this on various apps)
When did this error start for you? I've tried rolling back to previous commits and re-cloning to an earlier version of the app I'm still facing the same error.
Could you talk me through you clean install process please?
It seems like this issue is related with the latest cli release which came with the release of react native 0.72 yesterday. Problems occurred since then for me. I did a gradlew clean, deleted node modules and deleted the android build folder.
I am also facing this issue with no solution
Im also facing the same issue... is there any fix yet for this ? Thanks
me to. Suddenly this error appeared.
Guys i have found a workaround, we changed 3 things
same issue here, it only works when I do delete node_modules and yarn install again but the error will appear again if I run the second build (yarn react-native run-android), which means I must delete node_modules and yarn install again every single time I want to develop/build the app. I found this issue when i add react-native-cameraroll
I've already tried it on my both device which is Windows 11 and MacOS Ventura 13.3.1 and the issue is still the same
Same. Impossible. Changed so many versions. It is everywhere, it does not depend on packages that you have at all.
same issue here, it only works when I do delete node_modules and yarn install again but the error will appear again if I run the second build (yarn react-native run-android), which means I must delete node_modules and yarn install again every single time I want to develop/build the app. I found this issue when i add react-native-cameraroll
I've already tried it on my both device which is Windows 11 and MacOS Ventura 13.3.1 and the issue is still the same
Already fixed here
I don't understand how or why, but I removed "react-native-image-picker": "^5.0.1" and it started to build again.
How got to removing this package:
I wasn't returning JSON.
And that revealedan error that there was something missing in the AndroidManifest.xml of the react-native-image-picker package. I wasn't using this package as it was an artifact from a previous phase so was just able to remove it.
I don't understand why this happened, it was done through ALOT of trial and error but it worked. Hope this helps someone
I don't understand how or why, but I removed "react-native-image-picker": "^5.0.1" and it started to build again.
How got to removing this package:
- I ran the command "npx.cmd --quiet react-native config" based on this StackOverflow
I wasn't returning JSON.
- I think I removed 2 lines in Gradle files from this StackOverflow
And that revealedan error that there was something missing in the AndroidManifest.xml of the react-native-image-picker package. I wasn't using this package as it was an artifact from a previous phase so was just able to remove it.
- Then delete node_modules and run npm install again.
I don't understand why this happened, it was done through ALOT of trial and error but it worked. Hope this helps someone
Yeah and then try to build again. It will fail
same issue here, it only works when I do delete node_modules and yarn install again but the error will appear again if I run the second build (yarn react-native run-android), which means I must delete node_modules and yarn install again every single time I want to develop/build the app. I found this issue when i add react-native-cameraroll I've already tried it on my both device which is Windows 11 and MacOS Ventura 13.3.1 and the issue is still the same
Already fixed here
So how it fixed ?
me too.
Hello 👋 This is probably not issue related to React Native CLI - but related to libraries, please try upgrading (such as react-native-image-picker or react-native-cameraroll or any other) - probably in these libraries were introduced breaking change that breaks your app. Please also try creating fresh React Native app with npx react-native@latest init
command and say is it working for you correctly.
yarn remove react-native-image-picker Be useful to me
After discussing this issue with @cortinico, the problem is with broken backward compatibility in libraries, right now for this we have two solutions:
0.71
or 0.72
,package
field in AndroidManfiest.xml
We'll upstream fixes for this to the older versions (0.69, 0.70) of RN soon.
After discussing this issue with @cortinico, the problem is with broken backward compatibility in libraries, right now for this we have two solutions:
- Use React Native
0.71
or0.72
,- Downgrade libraries to the version that contains
package
field inAndroidManfiest.xml
We'll upstream fixes for this to the older versions (0.69, 0.70) of RN soon.
I use react native 0.71.3
. Which package version I should use to resolve this issue?
Hey @fahmiabdulyakub, you must check in your package.json
what packages do you have, and then check release notes / changelog in these packages, and downgrade to version that have package
field in AndroidManifest.xml
.
Note: You should have fix for that as you're using 0.71
, mind upgrading to the latest version of 0.71
or 0.72
?
Hey @fahmiabdulyakub, you must check in your
package.json
what packages do you have, and then check release notes / changelog in these packages, and downgrade to version that havepackage
field inAndroidManifest.xml
.Note: You should have fix for that as you're using
0.71
, mind upgrading to the latest version of0.71
or0.72
?
I still confuse about that solution. This my package.json
and AndroidManifest.xml
. What I'm suppose to do ?
{
"name": "MyApp",
"version": "2.1.3",
"private": true,
"scripts": {
"android": "react-native run-android",
"ios": "react-native run-ios",
"start": "react-native start",
"test": "jest",
"lint": "eslint . --ext .js,.jsx,.ts,.tsx",
"gradleclear": "cd android && bash gradlew clean && cd ../",
"android:stage": "react-native run-android --variant=stagingDebug",
"android:stage-release": "react-native run-android --variant=stagingRelease",
"android:ip": "react-native run-android --variant=ipDebug",
"android:ip-release": "react-native run-android --variant=ipRelease",
"android:prod": "react-native run-android --variant=productionDebug",
"android:prod-release": "react-native run-android --variant=productionRelease",
"buildapk:stage": "cd android && bash gradlew clean && bash gradlew app:assembleStagingRelease && cd ../",
"buildapk:ip": "cd android && bash gradlew clean && bash gradlew app:assembleIpRelease && cd ../",
"buildapk:prod": "cd android && bash gradlew clean && bash gradlew app:assembleProductionRelease && cd ../",
"buildbundle:aab": "cd android && bash gradlew clean && bash gradlew bundleProductionRelease && cd ../"
},
"dependencies": {
"@apollo/client": "^3.7.10",
"@notifee/react-native": "^7.0.4",
"@myapp/react-native-calendar-picker": "^1.0.14",
"@myapp/uikit-mobile": "^0.0.95",
"@react-native-community/blur": "^4.3.2",
"@react-native-community/cli": "^10.1.3",
"@react-native-community/cli-platform-android": "^10.0.0",
"@react-native-community/clipboard": "^1.5.1",
"@react-native-community/datetimepicker": "^7.0.0",
"@react-native-community/netinfo": "^9.3.6",
"@react-native-firebase/analytics": "^17.4.2",
"@react-native-firebase/app": "^17.4.2",
"@react-native-firebase/crashlytics": "^17.4.2",
"@react-native-firebase/dynamic-links": "^17.4.2",
"@react-native-firebase/messaging": "^17.4.2",
"@react-native-picker/picker": "^2.4.8",
"@react-navigation/bottom-tabs": "^6.5.7",
"@react-navigation/native": "^6.1.6",
"@react-navigation/native-stack": "^6.8.0",
"@react-navigation/stack": "^6.3.16",
"@reduxjs/toolkit": "^1.8.5",
"apollo-link-rest": "^0.9.0",
"axios": "^0.27.2",
"babel-plugin-module-resolver": "^4.1.0",
"base-64": "^1.0.0",
"dayjs": "^1.11.5",
"deprecated-react-native-prop-types": "^4.0.0",
"hermes-engine": "^0.11.0",
"i": "^0.3.7",
"i18next": "^21.9.1",
"install": "^0.13.0",
"lodash": "^4.17.21",
"lottie-ios": "^3.2.3",
"moment": "^2.29.1",
"moment-timezone": "^0.5.40",
"native-base": "^3.4.20",
"npm": "^8.19.4",
"react": "18.2.0",
"react-i18next": "^11.18.5",
"react-native": "0.71.3",
"react-native-bluetooth-escpos-printer": "^0.0.5",
"react-native-calendar-picker": "^7.1.2",
"react-native-camera": "^4.2.1",
"react-native-cli": "^2.0.1",
"react-native-code-push": "^8.0.2",
"react-native-config": "^1.4.11",
"react-native-device-info": "^10.6.0",
"react-native-encrypted-storage": "^4.0.2",
"react-native-fbsdk-next": "^11.2.1",
"react-native-gesture-handler": "^2.9.0",
"react-native-get-random-values": "^1.8.0",
"react-native-html-to-pdf": "^0.12.0",
"react-native-image-crop-picker": "^0.39.0",
"react-native-image-picker": "^4.10.0",
"react-native-in-app-review": "^4.3.3",
"react-native-linear-gradient": "^2.6.2",
"react-native-mixpanel": "^1.2.5",
"react-native-pager-view": "^6.1.3",
"react-native-pdf-thumbnail": "^1.2.1",
"react-native-photo-manipulator": "^1.2.7",
"react-native-render-html": "^6.3.4",
"react-native-safe-area-context": "^4.4.0",
"react-native-screens": "^3.20.0",
"react-native-select-contact": "^1.6.3",
"react-native-share": "^8.0.1",
"react-native-snackbar": "^2.4.0",
"react-native-splash-screen": "^3.3.0",
"react-native-svg": "^13.6.0",
"react-native-swiper": "^1.6.0",
"react-native-tab-view": "^3.3.4",
"react-native-wait-navigation": "^0.2.2",
"react-native-webview": "^12.0.2",
"react-native-wheel-pick": "^1.2.0",
"react-number-format": "^5.0.1",
"react-redux": "^8.0.4",
"redux": "^4.2.0",
"rn-fetch-blob": "^0.12.0",
"yup": "^0.32.11"
},
"overrides": {
"react-native-qrcode-svg": {
"react-native-svg": "$react-native-svg"
}
},
"devDependencies": {
"@babel/core": "^7.20.0",
"@babel/preset-env": "^7.20.0",
"@babel/runtime": "^7.20.0",
"@react-native-community/eslint-config": "^3.2.0",
"@tsconfig/react-native": "^2.0.2",
"@types/jest": "^29.2.1",
"@types/moment-duration-format": "^2.2.3",
"@types/react": "^18.0.24",
"@types/react-test-renderer": "^18.0.0",
"@typescript-eslint/eslint-plugin": "^5.29.0",
"@typescript-eslint/parser": "^5.29.0",
"babel-jest": "^29.2.1",
"eslint": "^8.19.0",
"jest": "^29.2.1",
"metro-react-native-babel-preset": "^0.73.7",
"moment-duration-format": "^2.3.2",
"react-test-renderer": "18.2.0",
"typescript": "^4.8.4"
},
"jest": {
"preset": "react-native",
"moduleFileExtensions": [
"ts",
"tsx",
"js",
"jsx",
"json",
"node"
]
},
"eslintConfig": {
"root": true,
"extends": "@react-native-community/eslint-config",
"rules": {
"prettier/prettier": 0,
"object-curly-spacing": [
"error",
"always"
],
"array-bracket-spacing": [
"error",
"always"
]
}
}
}
AndroidManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.myapp.original" xmlns:tools="http://schemas.android.com/tools">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="com.google.android.gms.permission.AD_ID" tools:node="remove"/>
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
<uses-permission android:name="android.permission.BLUETOOTH"/>
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION " />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
<uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM" />
<application
android:name=".MainApplication"
android:label="@string/app_name"
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher"
android:allowBackup="false"
android:usesCleartextTraffic="true"
android:theme="@style/AppTheme">
<meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/facebook_app_id"/>
<meta-data android:name="com.facebook.sdk.ClientToken" android:value="@string/facebook_client_token"/>
<meta-data
android:name = "com.google.firebase.messaging.default_notification_icon"
android:resource="@mipmap/ic_notification"
tools:replace="android:resource"
/>
<meta-data
android:name = "com.google.firebase.messaging.default_notification_color"
android:resource="@color/myapp_color"
tools:replace="android:resource"
/>
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.provider"
android:grantUriPermissions="true"
android:exported="false">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/filepaths" />
</provider>
<activity android:name="com.facebook.FacebookActivity"
android:configChanges=
"keyboard|keyboardHidden|screenLayout|screenSize|orientation"
android:label="@string/app_name" />
<activity
android:name="com.facebook.CustomTabActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="@string/fb_login_protocol_scheme" />
</intent-filter>
</activity>
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|screenSize|smallestScreenSize|uiMode"
android:launchMode="singleTask"
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustResize"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<data
android:host="myapp.co.id"
android:scheme="https"/>
</intent-filter>
</activity>
</application>
<queries>
<package android:name="com.myapp.staging" />
<intent>
<action android:name="android.intent.action.PICK" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="vnd.android.cursor.dir/contact" />
</intent>
</queries>
</manifest>
You shouldn't have react-native-cli
in your in package.json
from latest few version the React Native CLI comes with React Native, so there's no need for installing it as separate package. Please remove and check if it is working for you.
Edit: also you shouldn't have npm
as separate, and
"@react-native-community/cli": "^10.1.3",
"@react-native-community/cli-platform-android": "^10.0.0",
You shouldn't have
react-native-cli
in your inpackage.json
@szymonrybczak something to add to #1983 ?
@szymonrybczak something to add to https://github.com/react-native-community/cli/pull/1983 ?
Good idea!
For me it was caused by react-native-image-picker
. Updating it fixed it
1.rm -fr node_modules 2.yarn install 3.yarn react-native run-android
npx react-native run-android --variant=devDebug info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag. Jetifier found 2993 file(s) to forward-jetify. Using 8 workers... info Starting JS server... info Launching emulator... error Failed to launch emulator. Reason: Emulator exited before boot.. warn Please launch an emulator manually or connect a device. Otherwise app may fail to launch. info Installing the app... :ReactNative:Running '[node, -e, try {console.log(require('@react-native-community/cli').bin);} catch (e) {console.log(require('react-native/cli').bin);}]' command failed.
FAILURE: Build failed with an exception.
Where: Script 'C:\Users\nhung\Desktop\soba\src\Soba-MobileApp\node_modules\@react-native-community\cli-platform-android\native_modules.gradle' line: 397
What went wrong: A problem occurred evaluating script.
Could not find method exec() for arguments [ReactNativeModules$_getCommandOutput_closure16@2eaa5049] on object of type org.gradle.api.internal.provider.DefaultProviderFactory_Decorated.
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
Get more help at https://help.gradle.org
BUILD FAILED in 2s
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:installDevDebug -PreactNativeDevServerPort=8081 :ReactNative:Running '[node, -e, try {console.log(require('@react-native-community/cli').bin);} catch (e) {console.log(require('react-native/cli').bin);}]' command failed.
FAILURE: Build failed with an exception.
Where: Script 'C:\Users\nhung\Desktop\soba\src\Soba-MobileApp\node_modules\@react-native-community\cli-platform-android\native_modules.gradle' line: 397
What went wrong: A problem occurred evaluating script.
Could not find method exec() for arguments [ReactNativeModules$_getCommandOutput_closure16@2eaa5049] on object of type org.gradle.api.internal.provider.DefaultProviderFactory_Decorated.
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
Get more help at https://help.gradle.org
BUILD FAILED in 2s
at makeError (C:\Users\nhung\Desktop\soba\src\Soba-MobileApp\node_modules\.pnpm\execa@1.0.0\node_modules\execa\index.js:174:9)
at C:\Users\nhung\Desktop\soba\src\Soba-MobileApp\node_modules\.pnpm\execa@1.0.0\node_modules\execa\index.js:278:16
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async runOnAllDevices (C:\Users\nhung\Desktop\soba\src\Soba-MobileApp\node_modules\.pnpm\@react-native-community+cli-platform-android@7.0.1\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\runOnAllDevices.js:109:5)
at async Command.handleAction (C:\Users\nhung\Desktop\soba\src\Soba-MobileApp\node_modules\.pnpm\@react-native-community+cli@7.0.4_@babel+core@7.24.4_react-native@0.68.7\node_modules\@react-native-community\cli\build\index.js:192:9)
info Run CLI with --verbose flag for more details.
C:\Users\nhung\Desktop\soba\src\Soba-MobileApp>./gradlew clean '.' is not recognized as an internal or external command, operable program or batch file.
C:\Users\nhung\Desktop\soba\src\Soba-MobileApp>cd android
C:\Users\nhung\Desktop\soba\src\Soba-MobileApp\android>./gradlew clean '.' is not recognized as an internal or external command, operable program or batch file.
C:\Users\nhung\Desktop\soba\src\Soba-MobileApp\android>gradlew clean
Starting a Gradle Daemon, 2 incompatible Daemons could not be reused, use --status for details
:ReactNative:Running '[node, -e, try {console.log(require('@react-native-community/cli').bin);} catch (e) {console.log(require('react-native/cli').bin);}]' command failed.
FAILURE: Build failed with an exception.
Where: Script 'C:\Users\nhung\Desktop\soba\src\Soba-MobileApp\node_modules\@react-native-community\cli-platform-android\native_modules.gradle' line: 397
What went wrong: A problem occurred evaluating script.
Could not find method exec() for arguments [ReactNativeModules$_getCommandOutput_closure16@f6e6863] on object of type org.gradle.api.internal.provider.DefaultProviderFactory_Decorated.
Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
Get more help at https://help.gradle.org
BUILD FAILED in 5s how to fix this i'm stuck for 2 day
hey @nhokmoon, make sure that npx react-native config
works correctly and returns proper config of your app.
@nhokmoon , did you fix the issue? i've been stuck for days now.
@nhokmoon
C:\Users\nhung\Desktop\soba\src\Soba-MobileApp\node_modules\.pnpm\execa@1.0.0\node_modules\execa\index.js:174:9
Does RN work with PNPM nowadays? It didn't use to.
Hello!
For me, it was because of the missing package
attribute in AndroidManifest.xml
in the module react-native-image-resizer
In node_modules/@bam_tech/react-native-image-resizer/android/src/main/AndroidManifest.xml
- <manifest xmlns:android="http://schemas.android.com/apk/res/android">
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.reactnativeimageresizer">
And the value of package
will the same as the value of namespace
in node_modules/@bam_tech/react-native-image-resizer/android/build.gradle
I know that making changes directly in the node_modules
is not good, so I will probably create a patch file for it.
Even though I raised a PR #399, I don't think that it is going to change in the module, since it was a change introduced in React Native 0.73 (react-native-community/discussions-and-proposals/issues/671) Maybe in the near future this will be applied in other node modules too? I don't know because the discussion I linked dates back to Jun 17, 2023
I found the solution to RN cli issues specifically for older RN versions as pointed by @nhokmoon. I am using RN 68.7. I added resolutions
to my package.json
to force use older RN CLI versions:
"resolutions": {
"@react-native-community/cli": "^7.0.0",
"@react-native-community/cli-config": "^7.0.0",
"@react-native-community/cli-debugger-ui": "^7.0.0",
"@react-native-community/cli-doctor": "^7.0.0",
"@react-native-community/cli-platform-android": "^7.0.0",
"@react-native-community/cli-platform-ios": "^7.0.0",
"@react-native-community/cli-server-api": "^7.0.0",
"@react-native-community/cli-tools": "^7.0.0",
"@react-native-community/cli-types": "^7.0.0"
}
And now the Android build is succeeding 🚀.
Check the compatible version of RN CLI version for your RN version: https://github.com/react-native-community/cli?tab=readme-ov-file#compatibility
I found the solution to RN cli issues specifically for older RN versions as pointed by @nhokmoon. I am using RN 68.7. I added
resolutions
to mypackage.json
to force use older RN CLI versions:"resolutions": { "@react-native-community/cli": "^7.0.0", "@react-native-community/cli-config": "^7.0.0", "@react-native-community/cli-debugger-ui": "^7.0.0", "@react-native-community/cli-doctor": "^7.0.0", "@react-native-community/cli-platform-android": "^7.0.0", "@react-native-community/cli-platform-ios": "^7.0.0", "@react-native-community/cli-server-api": "^7.0.0", "@react-native-community/cli-tools": "^7.0.0", "@react-native-community/cli-types": "^7.0.0" }
And now the Android build is succeeding 🚀.
Check the compatible version of RN CLI version for your RN version: https://github.com/react-native-community/cli?tab=readme-ov-file#compatibility
thanks i will try it
tream
Im Using 0.73 Facing Same Issue, but I also some more error Failed to install the app. Command failed with exit code 1: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081 Script 'E:\Final Year Project\Phase 2\Application\React Native App\DairyPureApp\node_modules\@react-native-community\cli-platform-android\native_modules.gradle' line: 401 :ReactNative:Running '[node, E:\Final Year Project\Phase 2\Application\React Native App\DairyPureApp\node_modules\@react-native-community\cli\build\bin.js, config]' command failed.
Hello, get same exception after upgrde to new version (0.74) of RN.
FAILURE: Build failed with an exception.
- Where: Script 'C:\Users\nhung\Desktop\soba\src\Soba-MobileApp\node_modules@react-native-community\cli-platform-android\native_modules.gradle' line: 397
Could not find method exec() for arguments [ReactNativeModules$_getCommandOutput_closure16@f6e6863] on object of type org.gradle.api.internal.provider.DefaultProviderFactory_Decorated.
BUILD FAILED in 5s how to fix this i'm stuck for 2 day
In my case the problem was an old android\gradlew.bat
It was created with previos RN version.
I copied gradlew.bat from blank project, and this issue moved away.
You may create reference project from last RN with command
npx @react-native-community/cli@latest init TestProject
P.S. There are a lot other diffirences in *.gradle files comes with new version of RN.
OS: Windows 10 Java 17 Gradle 7.3
Hey guys,
This might not be the place to write this, but this is the issue that was closest to the problem I was facing. I am currently trying to integrate react-native-auth0 to my Expo project.
My current dependencies are:
"dependencies": { "@expo/vector-icons": "^14.0.0", "@react-navigation/native": "^6.0.2", "expo": "~51.0.9", "expo-camera": "~15.0.10", "expo-constants": "~16.0.2", "expo-font": "~12.0.5", "expo-linking": "~6.3.1", "expo-modules-autolinking": "^1.11.1", "expo-router": "~3.5.14", "expo-splash-screen": "~0.27.4", "expo-status-bar": "~1.12.1", "expo-system-ui": "~3.0.4", "expo-web-browser": "~13.0.3", "react": "18.2.0", "react-dom": "18.2.0", "react-hook-form": "^7.51.5", "react-native": "0.74.1", "react-native-auth0": "^3.2.1", "react-native-floating-action": "^1.22.0", "react-native-gesture-handler": "~2.16.1", "react-native-reanimated": "~3.10.1", "react-native-safe-area-context": "4.10.1", "react-native-screens": "3.31.1", "react-native-web": "~0.19.10" }, "devDependencies": { "@babel/core": "^7.20.0", "@types/jest": "^29.5.12", "@types/react": "~18.2.45", "@types/react-test-renderer": "^18.0.7", "jest": "^29.2.1", "jest-expo": "~51.0.2", "react-test-renderer": "18.2.0", "typescript": "~5.3.3" },
I'm running Java 17 and Gradle 7.3 (which is what I need to use according to the compatibility matrix. The Auth0 library only runs with native code. So when trying to build the Android native code using the Expo builder, i.e. npx expo run:android
, I keep getting this error:
`npx expo run:android env: load .env env: export EXPO_PUBLIC_AUTH0_DOMAIN EXPO_PUBLIC_AUTH0_CLIENT_ID › Building app... Picked up _JAVA_OPTIONS: -Xmx512M Configuration on demand is an incubating feature.
FAILURE: Build failed with an exception.
Where:
Script '
What went wrong: A problem occurred evaluating script.
Could not find method exec() for arguments [autolinking_7wnwhgbtt7rc3qqznqll89fti$_run_closure1@46e55161] on object of type org.gradle.api.internal.provider.DefaultProviderFactory_Decorated.
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
Get more help at https://help.gradle.org
BUILD FAILED in 969ms
Error:
I get the same result when changing directory (cd) to the android
folder and running gradle build
.
This is the code in my expo\scripts\autolinking.gradle
:
// Resolve
expo>
expo-modules-autolinkingdependency chain def autolinkingPath = ["node", "--print", "require.resolve('expo-modules-autolinking/package.json', { paths: [require.resolve('expo/package.json')] })"] apply from: new File( providers.exec { workingDir(rootDir) commandLine(autolinkingPath) }.standardOutput.asText.get().trim(), "../scripts/android/autolinking_implementation.gradle" )
Any help would be appreciated. Please let me know if any other information is needed. For more context, this is the repository and branch I am working on https://github.com/lnaidu14/quickpay/tree/19-integrate-auth0
The problem is that the package attribute is initially present in the camera-roll manifest file, but for some reason it is removed from it after running Gradle. That's why this error disappears after removing node_modules but occurs again after running a build once again. Perhaps Gradle merges manifest files somehow incorrectly. If you remove the package attribute from the manifest file of your application (android/app/src/main/AndroidManifest.xml
), you will not get this error (although then you will get another error saying that the package attribute must be present in the manifest file of your application). In the node_modules/@react-native-camera-roll/camera-roll/android/build.gradle
file there's a property of namespace
however, it is used conditionally. Maybe it should always be included?
UPD. I just changed the line def shouldUseNameSpace = agpVersion >= 7
to def shouldUseNameSpace = false
and created a patch using patch-package and the issue was resolved for me.
After discussing this issue with @cortinico, the problem is with broken backward compatibility in libraries, right now for this we have two solutions:
- Use React Native
0.71
or0.72
,- Downgrade libraries to the version that contains
package
field inAndroidManfiest.xml
We'll upstream fixes for this to the older versions (0.69, 0.70) of RN soon.
Hi, were you able to upstream the fix for .69?
我也有这个问题,想问下怎么解决的
@captainalbert did you find a solution for .69
?
@captainalbert did you find a solution for
.69
?
Yes. What I do whenever I encounter this are the ff steps:
and the project will run fine again in my case.
I Have the same issues, React Native : 0.75
no previous solution worked
I'm able to fix my case. i run npx react-native config to see the exact issue that i was facing and saw this error Failed to build the app: No package name found. Found errors in /Volumes/Data/ReactNativeProjects/GitHub/butl-driver-v1/node_modules/react-native-gesture-handler/android/src/main/AndroidManifest.xml. so i went straight to the path above and added the package name for the library Example: "com.swmansion.gesturehandler" After that i'm able to run the project by npm run android. Hope my solution might help. RN 0.69.3
The solution is node_modules\@react-native-community\cli-platform-android\native_modules.gradle' line: 401 => yarn cache clean => npm install -g react-native-cli => npx react-native doctor => yarn global add @react-native-community/cli => npx expo prebuild => yarn expo run:android
Having same problem on 0.74.5
I have this problem on 0.75.4
BUİLD FAILED in 331ms error Failed to install the app. Command failed with exit code 1: ./gradlew app:installDebug -PreactNativeDevServerPort=8081 FAILURE: Build failed with an exception. Where: Script '/Users/minik/FishCep/root/mobile/node_modules/@react-native-community/cli-platform-android/native_modules.gradle' line: 418 What went wrong: Could not compile script '/Users/minik/FishCep/root/mobile/node_modules/@react-native-community/cli-platform-android/native_modules.gradle'.
startup failed: script '/Users/minik/FishCep/root/mobile/node_modules/@react-native-community/cli-platform-android/native_modules.gradle': 418: [Static type checking] - No such property: inputStream for class: java.lang.Process @ line 418, column 31. def output = process.inputStream.text.trim() ^ script '/Users/minik/FishCep/root/mobile/node_modules/@react-native-community/cli-platform-android/native_modules.gradle': 418: [Static type checking] - No such property: text for class: java.lang.Object @ line 418, column 43. f output = process.inputStream.text.trim ^ script '/Users/minik/FishCep/root/mobile/node_modules/@react-native-community/cli-platform-android/native_modules.gradle': 418: [Static type checking] - Cannot find matching method java.lang.Object#trim(). Please check if the declared type is correct and if the method exists. @ line 418, column 24. def output = process.inputStream.text.trim() ^ 3 errors * Try:
I thought the issues would be similar. Is there any solution?
same with react-native-maps
abdallah at buddy in ~/Data/work/trips/tale3 (main)
$ cd android && ./gradlew clean && cd ..
Starting a Gradle Daemon (subsequent builds will be faster)
FAILURE: Build failed with an exception.
* Where:
Script '/home/abdallah/Data/work/trips/tale3/node_modules/@react-native-community/cli-platform-android/native_modules.gradle' line: 450
* What went wrong:
A problem occurred evaluating script.
> Calling `[node, /home/abdallah/Data/work/trips/tale3/node_modules/@react-native-community/cli/build/bin.js, config]` finished with an exception. Error message: groovy.json.JsonException: Unable to determine the current character, it is not a string, number, array, or object
The current character read is 'i' with an int value of 105
Unable to determine the current character, it is not a string, number, array, or object
line number 1
index number 0
info Run CLI with --verbose flag for more details.
^. Output: info Run CLI with --verbose flag for more details.
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
* Get more help at https://help.gradle.org
same issue
I was building, running and demoing my app at 11:30am this morning using npx react-native run-android, I made a PR and merged my branch into Dev an hour later. The build failed with the error below. I thought this was odd so in my local I deleted node_modules and package-lock.json, ran cd android && ./gradlew clean, then cd.. and npx react-native run-android. My local started producing this same error. I have no idea what could have changed or what would have caused this.
I have been googling and trying different solutions with no success and a deadline looming. Can anybody help guide me to a solution please? TIA!
Environment
react-native info
Description
npx react-native run-android