Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort - javascript

This is done in VS Code. I have seen TONS OF similar posts, so this is a common occurence. I think it maybe stems from a misunderstanding of gradle builds so any help is greatly appreciated! I created a react-native app following their CLI guide. Running the command react-native android did not work, and I followed a stack overflow solution here https://stackoverflow.com/questions/60844245/how-solve-could-not-initialize-class-org-codehaus-groovy-reflection-reflectionc. The command works, and an emulator is created properly, without having to go into android studio and starting it from there. I do a little bit of coding, and then want to install some extensions. I install flow, and babel E6, boom react-native run-android no longer works. A workaround is to start from android studio. I have followed countless stackoverflow answers on the same question as this title, example gradlew.bat install debug error. I gave up and decided to start a new project, boom run-android doesn't work as it seems is standard. I change my gradle version as per the first link, and the command works now for this second project.
Gradlew --version of 1st project:
Gradle 6.3
------------------------------------------------------------
Build time: 2020-03-24 19:52:07 UTC
Revision: bacd40b727b0130eeac8855ae3f9fd9a0b207c60
Kotlin: 1.3.70
Groovy: 2.5.10
Ant: Apache Ant(TM) version 1.10.7 compiled on September 1 2019
JVM: 15.0.1 (Oracle Corporation 15.0.1+9-18)
OS: Windows 10 10.0 amd64
gradlew help of 1st project:
BUILD SUCCESSFUL in 5s
1 actionable task: 1 executed
gradlew build --warning-mode=all of first project:
The BuildListenr.buildStarted(Gradle) method has been deprecated
Internal API constructor DefaultDomainObjectSet(Class<T>) has been deprecated.
Injecting the input artifact of a transform as a File has been dprecated.
So from my understanding on their troubleshooting site, the issue lies with one of the requested tasks rather than a configuration step.
Furthermore I have tried disabling the flow and babel extensions, as well as remove the added config files that weren't included in the react-native init app. I have also tried changing the package.json file to the same as the working second project. Even if a solution is found for this project, I am still curious as to why everytime I start a react-native project I have to change the gradle version in gradle/gradle-wrapper.properties. Any help or input is greatly appreciated.

Related

React native project stucks on :unimodules-react-native-adapter:generateExpoModulesPackageList

It is an expo-eject project and the commands I have used after cloning the project are:
Yarn,
Yarn start,
Yarn android,
And it does not show any error but gets stuck on a same point everytime when I try to run the project.
The project runs fine on the laptops of other teammates, but I am facing this issue.
Here are the versions of the installed tools:
Nodejs 14.17.6,
Expo 4.11.0,
React-native-cli 2.0.1,
I am adding an image that shows where the project gets blocked.
This is the issue in running project.
Had the same issue, and tried #usama-alaf reply, which consisted of:
Installing the right SDK for the Android device
Linking the SDK path under project/android/local.properties
But none of the above worked for me. Digging a little deeper, I found this Github issue from Willem Horsten, where the developer states that there was a yarn.lock file on one of his Hard Drives. I'm actually running my development environment on a secondary HD, and I also had a lock file in the root of the drive, but after deleting it, nothing changed.
Here's what actually worked for me. I was running Node v12, and trying to build the project, and trying to check whether the Node version was the culprit, I did this:
Deleted my node_modules, yarn.lock, and all other lock files I could find (for some reason there was also a package-lock.json file on the project)
Since I'm using NVM, I switched to Node v15.14.0 (the latest I have installed).
Installed the dependencies again with yarn install
Ran yarn android, and the build worked this time.

(React Native): Execution failed for task ':app:generatePackageList'

I am generating an apk of a project that I developed using React Native. But when I run the command ./gradlew assembleRelease The following error appears:
> Configure project :react-native-audio
WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
It will be removed in version 5.0 of the Android Gradle plugin.
For more information, see http://d.android.com/r/tools/update-dependency-configurations.html.
> Task :app:generatePackageList FAILED
FAILURE: Build failed with an exception.
* Where:
Script 'C:\Users\romer\ProjetoAP\Gravador\teste\Gravador_de_audio\node_modules\#react-native-community\cli-platform-android\native_modules.gradle' line: 131
* What went wrong:
Execution failed for task ':app:generatePackageList'.
> argument type mismatch
* 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
Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/7.0/userguide/command_line_interface.html#sec:command_line_warnings
BUILD FAILED in 24s
1 actionable task: 1 executed
PS C:\users\romer\ProjetoAP\Gravador\teste\Gravador_de_audio\android>
How to solve this problem?
I just ran across the same problem and was able to track down why it was happening on my system. Using the --stacktrace flag helped to figure out what was going on, which ended up pointing to the react-native-community/cli package.
After scanning the issues and PRs in the react-native-community/cli repo, I found this PR https://github.com/react-native-community/cli/pull/1396 which adds support for Gradle 7.
I had Gradle 7 on my system and downgrading to Gradle 6, running gradle wrapper, then ./gradlew clean allowed me to move on.
Hope that solves your issue, or at least gives you some insight on how to track it down on your system!
Use Gradle Version 6.9
Here are the highlights of this release:
This is a small backport release.
Java 16 can be used to compile when used with Java toolchains
Dynamic versions can be used within plugin declarations
Native support for Apple Silicon processors
Use Gradle Wrapper to change the Version.
./gradlew wrapper --gradle-version 6.9
Instead of downgrading, I checked the reactNativeModule parameter mentioned at line 131.
It seems like ArrayList<HashMap<String, String>>[] packages = this.reactNativeModules, there is literally a mismatch.
Indeed reactNativeModule doesn't have brackets in his declaration.
So I changed :
ArrayList<HashMap<String, String>>[] packages = this.reactNativeModules
to
ArrayList<HashMap<String, String>> packages = this.reactNativeModules.
Upgrade your react-native version to the latest one with npx react-native upgrade
I had to upgrade from JDK 1.8 to 11 and this error occurred.
Thanks to J Myers answer I found that I had to upgrade the react native version: https://github.com/react-native-community/cli/pull/1396
Steps to solve it for React Native*
Find apply from: file("../../node_modules/#react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project) in your app -> build.gradle.
Check if this line of code is being repeated.
Comment out one of them.
This should solve your issue.
Replacing distributionUrl with https\://services.gradle.org/distributions/gradle-6.9-all.zip in gradle/wrapper/gradle-wrapper.properties fixed everything for me. Thank GOD
For me on react-native version 0.70.6
Issue is due to #react-native-community/cli-platform-android version so i just need to run
yarn add #react-native-community/cli-platform-android
As give here
Upgrading #react-native-community/cli as described here solved the issue for me: https://github.com/react-native-community/cli#updating-the-cli
If you use lock files (yarn.lock or package-lock.json) - find all the
#react-native-community/cli prefixed entries, remove them, run yarn
install / npm install once again.

Capacitor (build.gradle does not exist/operation not permitted) React app to Android can't build

I can't build my react webapp to android using capacitor (never done it before). However, I successfully did so to ios.
I've tried to sync gradle manually from android studio (file > sync project with gradle files), but still no luck.
These are the errors (steps to reproduce are included below):
12.41 Gradle sync failed: /spacex-launches/node_modules/#capacitor/android/capacitor/build.gradle
(Operation not permitted) (54 s 634 ms)
The main question here is, (Operation not permitted)
I've tried to allow all access for everything (read and write) for everyone for every file in the folder. Still, again, no luck.
The commands I ran to reproduce these errors:
npx cap init
npx cap app (then I picked android)
npx cap open android (it tried to sync and then gave me the errors above; thus build is not possible).
Any help would be appreciated!
Thanks a lot.
Turns out, opening the android folder manually using Android Studio, weirdly enough fixed it.
Assuming your source code is in a remote repository somewhere, try a fresh install in another directory. First, update the Ionic CLI.
npm i -g #ionic/cli#latest
git clone https://.../your-app.git
cd ./your-app
npm i
ionic build
ionic cap add android
ionic cap open android
Note you don't need to run npx cap init again. Since the iOS build is working, Capacitor is already installed in your project.
If you still can't build, ensure your environment is set up correctly. This can vary whether you are on Mac or Windows. The Capacitor docs provide guidance.

'React/UIView+React.h' file not found | AIRGMSMarker.h

Intro
Hi there! I'm working on my first react-native app. After months of work, I am finally ready to deploy to Test Flight. I built the project in expo. Runs great on the expo simulator. Next step, run in Xcode. I encountered a few errors but managed to find my way. Until, I hit this error, which, I just cannot seem to get around.
What I have done:
1)Ejected ExpoKit
2)Run npm install
3)Run pod install in my ios directory
The Error:
Now, I am trying to compile in debug and release configurations but the build fails :(. Here is the error I am receiving
Not sure what to do. I have searched all around and can't seem to find a working solution... Any ideas??
Versions
React Native - 0.54.2
React Native CLI - 2.0.1
I solved my issue with these steps
update pod
install pod
removed node_modules and npm install
Not sure this will help anyone but it fixed my problem.

Build Hangs While Running 'react-native run-ios'

I am stuck on a problem. While running commnand from cli react-native run-ios
Found Xcode project myproject.xcodeproj
Launching iPhone 6 (iOS 10.3)...
Building using "xcodebuild -project myproject.xcodeproj -configuration Debug -scheme myproject -destination id=CB73A374-3E21-4C73-BEC4-AD29A583FCE8 -derivedDataPath build"
User defaults from command line:
IDEDerivedDataPathOverride = /Users/.../myproject/ios/build
It just hangs and then nothing happens, no response.
I already checked an earlier question in stackoverflow and issue in github, but got no help. I may have asked a duplicate question but I am in badly need of a solution. Any help will be highly appreciated.
I know this is way later than the question was asked, but since it was never answered, I wanted to throw this up here cause it just happened to me.
I got past that by doing rm -rf node_modules/ and then doing npm install.
Hope this helps someone else in the future as well! :-D
This resolved the problem for me, Under project.workspace, there is a file called "contents.xcworkspacedata".(This can be opened from your IDE)
There was a duplication of the fileref tag, removed one and ran react-native run-ios, and it worked.
<FileRef
location = "group:project.xcodeproj">
</FileRef>
Another solution:
close your IDE
run in a terminal:
sudo kill -9 `ps aux | grep node | grep -v grep | awk '{print $2}'`
Re-open your IDE
re-run: (npx) react-native run-ios
For someone stuck on it in 2023, for me just trying to start a React Native project following their documentation did not work.
My Mac is M1, which caused a lot of different issues. Eventually, I solved it by:
Making sure my ruby version was correct. I used a combination of arch -arm64 rvm install 2.7.6 (The version being latest Ruby version required on boilerplate React Native project). Then to use the version, rvm use 2.7.6. I then initiated my React Native project using arch -arm64 npx react-native init <ProjectName>. Rest of the commands such as npx react-native run-ios worked as usual.
Moving the project away from iCloud Drive folder fixed it from being stuck on "Building the app..." (Still takes a while to build).
I spent my weekend trying to solve this. Hope this helps.

Categories