gradlew commands showing no result - android

I am trying to run following commands on Terminal window of Android Studio, but nothing is coming in result:
ms-macbook-3868:ProjectName my_name$ ./gradlew install
ms-macbook-3868:ProjectName my_name$ ./gradlew bintrayUpload
ms-macbook-3868:ProjectName my_name$
Is this issue with Android Studio?
Please help.

Related

React Native Error when running React-Native run-android

I get this strange error in VScode when I try to execute the command React-native run-android in the terminal.
Also ran react-native doctor and all green checkmarks for Node,yarn, android_home, and android sdk 0 errors
Not sure how to fix these issues as I have tried all suggestions in previous threads. Anyone have this issue that could assist? This is a windows machine.
Error Image
1.first Gradle needed to connect to the internet.
2.cd android
./gradlew clean
./gradlew wrapper
./gradlew -v // to download the new version
3.project app-level build.gradle file:
update version this
com.google.firebase:firebase-analytics
and this
com.google.gms:google-services

React-native run-android is not working because it cant found any emulators macOS

I created react-native project and when I run react-native run-ios it is working perfectly.
But the problem is android.
Whenever I run react-native run-android it gives me this error:
error Failed to launch emulator. Reason: No emulators found as an output of `emulator -list-avds`.
After this error it begins to install the app and in the end I get this error.
error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup. Run CLI with --verbose flag for more details.
Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081
java.lang.NoClassDefFoundError: Could not initialize class org.codehaus.groovy.vmplugin.v7.Java7
I installed latest java and jdk tools.
I found some solutions on stack overflow and I followed one which suggested to clean Gradlew file in the android folder but it did not work either.
any suggestions please?
My OS is macOS Catalina
Just in case anyone encounters this problem.
I solved it this way
1.ANDROID STUDIO
I went to the android studio and updated all the tools needed for the emulator
2.Android folder inside the project
I went to the android folder of my project, inside of android/app/gradle Gradle-wrapper file and updated distributionUrl to the latest version
3.Clear cache
I ran npm --reset-cache start
4.Final step
After all of this I opened android emulator and ran react-native run-android in my app and it worked

React-Native: error Failed to install the app. Make sure you have an Android emulator running

I just initialized a new React Native project via:
react-native init AwesomeProject
and I am already getting this error:
BUILD FAILED in 3s
error Failed to install the app. Make sure you have an Android emulator running or a device connected. Run CLI with --verbose flag for more details.
Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:installDebug'.
> com.android.builder.testing.api.DeviceException: No connected devices!
* 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 3s
at checkExecSyncError (child_process.js:637:11)
at execFileSync (child_process.js:655:13)
at runOnAllDevices (/Users/danale/Projects/engageMobile/node_modules/#react-native-community/cli-platform-android/build/commands/runAndroid/runOnAllDevices.js:75:39)
at buildAndRun (/Users/danale/Projects/engageMobile/node_modules/#react-native-community/cli-platform-android/build/commands/runAndroid/index.js:169:41)
at then.result (/Users/danale/Projects/engageMobile/node_modules/#react-native-community/cli-platform-android/build/commands/runAndroid/index.js:135:12)
at processTicksAndRejections (internal/process/next_tick.js:81:5)
It is a boilerplate app only thus far. I am using zsh and not bash for command line interface.
I also develop in flutter and I do not get this problem, it opens up the Nexus 5X simulator without a hitch.
What could be the problem?
I tried changing permissions, but that is not it.
So apparently I have more experience with ios than android and while react-native run-ios automatically opens up a simulator for you, react-native run-android does not, important point, similar commands, don't do similar things, i.e. open up a simulator.
Once I opened up the application inside of Android Studio and then went to AVD Manager and opened up the simulator for Android Studio and then ran react-native run-android, it worked perfectly.
None of the above worked for me when I start a new project
try this
go to android folder and edit build.gradle
set buildToolsVersion = "23.0.1" mine was 30.0.2 when i changed it to "23.0.1" it started working
In the android folder run
gradlew.bat installDebug
and make sure the Build is successful
That should do it go back to your project folder and run
npm run android
If your nodejs already running or any device is already connected before init project then it wont be considered for react-native.
Make sure your Android simulator is running.
Close ALL terminal window.
Run 'react-native run-android'
It's should open two terminal windows. If you see a same error again,
close the second terminal ( the one where is compile), and run 'npm start' in 1 open terminal.
I ran across the same problem.
Even though my android simulator works fine, once in a while, some corruption occurs, and then react-native run-android throws above error.
One solution that works for me is to close all command prompts, close the virtual devices and re-run them fresh, always worked for me.
Basically open your react native project in android studio, and it will download gradle in android studio instead of the command terminal. then open your command terminal and run the code "npm run android" and it shall work
I think you forgot to create virtual device first.
open android studio application
chose configure icon and then select AVD Manager
create your virtual device here.
after finish, you can run on cmd/terminal npx react-native run-android

Could not create service of type ScriptPluginFactory using BuildScopeServices.createScriptPluginFactory() react-native. How to fix?

I have the template code for my "Helloworld" app written in javascript and react-native on Windows. I connected my android emulator and wanted to launch the app on it. The following happens when I run "react-native run-android" command. Node.js opens as a separate window and it's written "Loading dependency graph, done". However, in the terminal window, there is following error message:
>User helloworld $ react-native run-android
Starting JS server...
Building and installing the app on the device (cd android && gradlew.bat installDebug)...
FAILURE: Build failed with an exception.
>*What went wrong:
Could not create service of type ScriptPluginFactory using
BuildScopeServices.createScriptPluginFactory().
>Could not create service of type PluginResolutionStrategyInternal using BuildScopeServices.createPluginResolutionStrategy().
>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 1s
Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/getting-started.html
Command failed: gradlew.bat installDebug
Error: Command failed: gradlew.bat installDebug
at checkExecSyncError (child_process.js:616:11)
at Object.execFileSync (child_process.js:634:13)
at runOnAllDevices (C:\Users\User\helloworld\node_modules\react-native\local-cli\runAndroid\runAndroid.js:299:19)
at buildAndRun (C:\Users\User\helloworld\node_modules\react-native\local-cli\runAndroid\runAndroid.js:135:12)
at isPackagerRunning.then.result (C:\Users\User\helloworld\node_modules\react-native\local-cli\runAndroid\runAndroid.js:65:12)
at process._tickCallback (internal/process/next_tick.js:68:7)
-Concerning whether emulator is connected:
$ adb devices
List of devices attached
emulator-5554 device
(Works similarly for my Android smartphone). USB debugging is enabled.
-Concerning what I have tried to solve the problem:
My user is set as administrator.
I had JDK11.0.1 version. I installed JDK1.8.0_201 and it is now set as my java version.
User helloworld $ java -version
java version "1.8.0_201"
I created ".gradle" folder in my project's directory in case there are problems with accessing/creating this kind of folder.
-I specified the path for sdk.dir in local.properties file
-My OS is Windows 8.1. Gradle's version is 4.7.
-I have installed Android Studio, JDK8 and 11.
-I am using GitBash for the terminal purposes.
-I have the following system's environment variables:
ANDROID_HOME = c:\Users\User\AppData\Local\Android\Sdk
GRADLE_HOME = C:\Users\User.gradle\wrapper\dists\gradle-4.7-all\4cret0dgl5o3b21weaoncl7ys\gradle-4.7
JAVA_HOME = C:\Program Files\Java\jdk1.8.0_201
Path = C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\Git\cmd;.\Plugins;C:\Users\User\AppData\Local\Programs\Python\Python37-32;C:\Program Files\nodejs\;c:\Users\User\AppData\Local\Android\Sdk\platform-tools;C:\Users\User\AppData\Local\Android\Sdk\platform-tools;%GRADLE_HOME%\bin;%JAVA_HOME%\bin
In case you are interested what was in the question before:
My initial problem was that there just was not any error shown, but still nothing was launched on the emulator. I went around that by putting my project's "android" folder into Android Studio and it launched the app on my smartphone. However, when I introduced small changes to App.js, the project could not be updated due to some unknown error, and I couldn't reopen it as a new project. So I had to solve this problem by trying to run the app by using "react-native run-android" through terminal, and now I'm at this state of the problem.
Mmmm... when you run react-native run-android on the console, 1 it should check if you have the android sdk's, second it should compile some things, and third, it should start metro bundler in ANOTHER console . The "Loading dependency graph, done" should appear on that OTHER console, while the main console is gonna still compile for about a minute or even more... then it's gonna launch the intent and open the app. Sometimes it just displays a blank screen after the first load, so you should exit the app and delete it from recents, and reopen the app
Post screenshots, it seems like you only see that secondary console while the main console is not displaying (?)
Do you want to run a react-native or purely java application for which you must have used Android studio?
If for the studio app: you must enable the developer's options from your phone for enabling that check this:
https://www.samsung.com/uk/support/mobile-devices/how-do-i-turn-on-the-developer-options-menu-on-my-samsung-galaxy-device/

'gradlew' is not recognized as an internal or external command error in Android Studio terminal

Getting error - 'gradlew' is not recognized as an internal or external command. operable program or batch file. inside Android Studio terminal.
Can anyone please tell why it's not recognizing gradlew
gradlew command is available in your project directory. If you are trying to run this command from somewhere else it will throw error.
Also gradlew command package is automatically generated by Android studio when you create a new project. It will also prompt you to generate new gradle wrapper when you open the project.
you have to use ./gradlew instead of gradlew , if you are using Mac or Linux
It's under the Android folder, so you have to do cd Android first from your project root folder, then :
PS C:\code\my_app\android> ./gradlew signingReport
in vscode do this step
go to your project directory
cd to android
type ./gradlew in your terminal instead of gradlew
voila, it works for windows user
Assume that you app's name is video_compresser, so when you open terminal on Windows PC(because I am trying this on Windows) it shows the prompt like this.
C:\Users\Nuwan\StudioProjects\video_compresser>
If you run gradlew from here you will get the below message
'gradlew' is not recognized as an internal or external command,
operable program or batch file.
so you have to go to android directory by typing cd android command from terminal.
then the prompt should be like this,
C:\Users\Nuwan\StudioProjects\video_compresser\android>
then type gradlew followed by other commands you need and the error should be gone.
Try using,
./gradle clean
./gradle assembleRelease
worked for me.
make sure you have debug.keystore file in
PS C:\code\my_app\android>
before you run
./gradlew signingReport
Instead of the powershell, use the Windows Command Prompt to run the command.
(This is an accidental finding. I used the visual studio code terminal to run the command gradlew assembleRelease to build the apk of a react-native project, but it outputs an error similar to above. I tried bash terminal, again failed to run. Out of curiosity, I used the Windows command prompt, then it worked. Hope this will help if other solutions are not working).
If you use powershell, and the gradlew file is in the terminal current work directory, try .\gradlew instead of gradlew. Powershell don't run the command in the current work directory automatically.
ionic cordova build android --prod --release --alias=cos-android --password=abcd --versionCode=00001 --versionName=00001 -- -- -- --packageType=bundle
cordova build android --prod --release --alias=cos-android --password=abcd --versionCode=00001 --versionName=00001 -- -- --packageType=bundle
gradlew command is only available in your project directory or gradlew file location. If you are trying to run this command from somewhere else it will throw error.
so go to that particular location where gradlew file available
go to android directory by typing
"cd android" in terminal.
then the prompt should be like this,
PS C:\src\offx> cd android
PS C:\src\offx\android>
(//then type) ".\gradlew signinReport"
PS C:\src\offx\android> .\gradlew signinReport
Then you will get your sha keys
I am using windows OS and have to run a Java project in IntelliJ. I used the command prompt in admin mode then it worked for me.

Categories

Resources