I am using Visual studio code to develop React-native apps and nox player as android emulator. I don't want to install Java SDK/JDK to resolve the below issue. I am using yarn, and yarn android command in order to run the app in android simulator nox player. I couldn't run the app due to below error.
› Building app...
ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation.
C:\Users\...\android\gradlew.bat exited with non-zero code: 1
Error: C:\Users\...\android\gradlew.bat exited with non-zero code: 1
at ChildProcess.completionListener (C:\Users\...\AppData\Roaming\npm\node_modules\expo-cli\node_modules\#expo\spawn-async\src\spawnAsync.ts:65:13)
at Object.onceWrapper (node:events:642:26)
at ChildProcess.emit (node:events:527:28)
at ChildProcess.cp.emit (C:\Users\...\AppData\Roaming\npm\node_modules\expo-cli\node_modules\cross-spawn\lib\enoent.js:34:29)
at maybeClose (node:internal/child_process:1092:16)
at Process.ChildProcess._handle.onexit (node:internal/child_process:302:5)
...
at spawnAsync (C:\Users\...\AppData\Roaming\npm\node_modules\expo-cli\node_modules\#expo\spawn-async\src\spawnAsync.ts:26:19)
at spawnGradleAsync (C:\Users\...\AppData\Roaming\npm\node_modules\expo-cli\src\commands\run\android\spawnGradleAsync.ts:83:18)
at assembleAsync (C:\Users\...\AppData\Roaming\npm\node_modules\expo-cli\src\commands\run\android\spawnGradleAsync.ts:57:16)
at actionAsync (C:\Users\...\AppData\Roaming\npm\node_modules\expo-cli\src\commands\run\android\runAndroid.ts:143:9)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Windows 11:
Resolution: In package.json file I have changed "main": "index.js" to "main": "node_modules/expo/AppEntry.js" it worked for me.
It would be great if this solution helps anyone, let me know for any additional information.
I wrote a Gradle task which executes the fastlane supply command via the command line. The task looks like this:
task uploadToPlayStore(type: Exec) {
group = "upload"
commandLine "fastlane", "supply",
"--aab", "$project.rootDir/app/build/outputs/bundle/upload/${archiveFile}.aab",
"--mapping", "$project.rootDir/app/build/outputs/mapping/upload/mapping.txt",
"--skip_upload_apk", "true",
"--skip_upload_metadata", "true",
"--skip_upload_images", "true",
"--skip_upload_screenshots", "true",
"--track", "internal",
"--package_name", "$appPackage",
"--json_key", "~/Documents/key.json"
}
This task runs successfully from the terminal on the Jenkins slave I'm running it on, and via Android Studio as a Gradle task and via its terminal by ./gradlew uploadToPlayStore. At first it wasn't running properly via Android Studio's terminal until I did a Invalidate Cache and Restart of Android Studio. It was giving this error:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:uploadToPlayStore'.
...............
Caused by: org.gradle.process.internal.ExecException: A problem occurred starting process 'command 'fastlane''
...............
Caused by: net.rubygrapefruit.platform.NativeException: Could not start 'fastlane'
...............
Caused by: java.io.IOException: Cannot run program "fastlane" (in directory "/Users/..."): error=2, No such file or directory
...............
Caused by: java.io.IOException: error=2, No such file or directory
Currently when I try to run my Jenkins Multibranch Pipeline I get the same error I previously got in Android Studio. From what I've found so far, it appears that Jenkins can't find the fastlane command for some reason. I tried setting an Environment Variable for the build Node where I'm building my projects, but I still get the same error.
This is the stage in the Jenkinsfile where I run my Fastlane task:
stage('Upload To Google Play Store') {
steps {
script {
if (env.BRANCH_NAME.startsWith("release")) {
sh './gradlew uploadToPlayStore --stacktrace'
} else {
echo 'Skipping stage since we\'re not on a release branch...'
}
}
}
}
Update (1): When running the command as "~/.rvm/rubies/ruby-2.4.2/bin/fastlane", "supply", ... with the --debug flag active I get the following stacktrace:
22:54:51.135 [DEBUG] [org.gradle.process.internal.DefaultExecHandle] Changing state to: STARTING
22:54:51.137 [DEBUG] [org.gradle.process.internal.DefaultExecHandle] Waiting until process started: command '/Users/bild_nachine/.rvm/rubies/ruby-2.4.2/bin/fastlane'.
22:54:51.147 [DEBUG] [org.gradle.process.internal.DefaultExecHandle] Changing state to: STARTED
22:54:51.147 [INFO] [org.gradle.process.internal.DefaultExecHandle] Successfully started process 'command '/Users/bild_nachine/.rvm/rubies/ruby-2.4.2/bin/fastlane''
22:54:51.148 [DEBUG] [org.gradle.process.internal.ExecHandleRunner] waiting until streams are handled...
22:54:51.150 [ERROR] [system.err] env: ruby_executable_hooks: No such file or directory
22:54:51.152 [DEBUG] [org.gradle.process.internal.DefaultExecHandle] Changing state to: FAILED
22:54:51.152 [DEBUG] [org.gradle.process.internal.DefaultExecHandle] Process 'command '/Users/bild_nachine/.rvm/rubies/ruby-2.4.2/bin/fastlane'' finished with exit value 127 (state: FAILED)
Update (2): After about a day of debugging I found out that when I run the gem env command via the Script Console of the Jenkins node I get a different RUBYGEMS version, gem paths and shell paths. I'm currently trying to make the Jenkins node use the Ruby Gems installed on the machine and not its own (or something in those lines).
Update (3): After about 3 days of debugging I finally managed to figure out exactly what's wrong. The problem is that when running a Jenkins pipeline job, you can't really set the environment variables via the standard web interface and plugins (like EnvInject). Also Mac OS has a built-in ruby environment, which is used by the Jenkins node by default, on which I couldn't install the Fastlane Gem.
The solution was as follows:
Install RVM or RBEnv on your Jenkins slave
Install Fastlane
Add the proper environment variables to your Jenkinsfile
You usually need to set up the PATH manually, as the Jenkins slave does not pick up the full path.
It can be done through the Jenkins dashboard on the slave's configuration page (Manage Jenkins -> Manage Nodes -> -> Configure).
You can find out where fastlane has installed by running which fastlane on the slave.
Here is output of meteor run android-device:
meteor run android-device
[[[[[ ~/repo/socialize ]]]]]
=> Started proxy.
=> Started MongoDB. Building for web.browser - Babel compiling files:
client/lib/module/angular-ios9-uiwebview.patch.js
client/lib/module/aws-sdk.min.js [BABEL] Note: The code generator has
deoptimised the styling of "/client/lib/module/aws-sdk.min.js" as it
exceeds the max of "100KB". client/lib/module/helpers.js
client/lib/app.js client/controllers/appCtrl.js
client/controllers/cardsCtrl.js client/controllers/chatCtrl.js
client/controllers/connectionsCtrl.js
client/controllers/eCardCtrl.js
client/controllers/forgetPassCtrle.js
client/controllers/groupsParentCtrl.js
client/controllers/homeCtrl.js client/controllers/loginCtrl.js
client/controllers/myGroupsCtrl.js client/controllers/profileCtrl.js
client/controllers/publicGroupsCtrl.js
client/controllers/recentCtrl.js client/controllers/signUpCtrl.js
client/directives/autoFocus.js client/directives/msdElastic.js
client/directives/resizeFooter.js client/filters/calendar.js
client/filters/chatLinkFilter.js client/filters/chatName.js
client/services/mockService.js client/services/s3BucketService.js
collections/cards/cards.js
collections/cardsCategory/cardsCategory.js
collections/chats/chats.js collections/circles/circles.js
collections/groups/groups.js collections/messages/messages.js
collections/users/users.js client/routes.js Building for
web.cordova - Babel compiling files: Building for
os.linux.x86_64 | Babel compiling files:
server/cards/permissions.js server/cards/publications.js
server/cardsCategory/methods.js server/cardsCategory/permissions.js
server/cardsCategory/publications.js server/cardsCategory/seed.js
server/chats/methods.js server/chats/permissions.js
server/chats/publications.js server/circles/methods.js
server/circles/permissions.js server/circles/publications.js
server/groups/methods.js server/groups/permissions.js
server/groups/publications.js server/messages/methods.js
server/messages/permissions.js server/messages/publications.js
server/users/methods.js server/users/permissions.js
server/users/publications.js server/users/seed.js
WARNING: You are testing your app on a remote device. For the mobile app to be able to
connect to the local server, make sure your device is on the same
network, and that the
network configuration allows clients to talk to each other (no client isolation).
=> Errors executing Cordova commands:
While running Cordova app for platform Android with options --device: >Error:
Command failed:
/home/haider/repo/socialize/.meteor/local/cordova-build/platforms/android/cordova/run
--device
events.js:72
throw er; // Unhandled 'error' event ^
Error: spawn EACCES
at errnoException (child_process.js:1011:11)
at Process.ChildProcess._handle.onexit (child_process.js:802:34) at
ChildProcess.exitCallback (/tools/utils/processes.js:137:23) at
ChildProcess.emit (events.js:98:17) at
Process.ChildProcess._handle.onexit (child_process.js:820:12)
ExitWithCode:1
I tried to compile webrtc native code.
Added here main reference link for installation step:
http://webrtc.org/native-code/android/
http://www.khirman.com/building-webrtc-libraries-android/
While executing
"gclient runhooks"
getting error like this:
umnteam#umn-desktop:~/webrtc_androd_latest$ gclient runhooks
________ running '/usr/bin/python -c import os,sys;script = os.path.join("trunk","check_root_dir.py");_ = os.system("%s %s" % (sys.executable,script)) if os.path.exists(script) else 0' in '/home/umnteam/webrtc_androd_latest'
________ running '/usr/bin/python -u src/sync_chromium.py --target-revision d66326c14bb70a1d61d75b096a9a344bc9a53c1a' in '/home/umnteam/webrtc_androd_latest'
Chromium already up to date: d66326c14bb70a1d61d75b096a9a344bc9a53c1a
________ running '/usr/bin/python src/setup_links.py' in '/home/umnteam/webrtc_androd_latest'
________ running '/usr/bin/python src/build/landmines.py --landmine-scripts src/webrtc/build/get_landmines.py --src-dir src' in '/home/umnteam/webrtc_androd_latest'
________ running '/usr/bin/python src/third_party/instrumented_libraries/scripts/download_binaries.py' in '/home/umnteam/webrtc_androd_latest'
________ running 'download_from_google_storage --directory --recursive --num_threads=10 --no_auth --quiet --bucket chromium-webrtc-resources src/resources' in '/home/umnteam/webrtc_androd_latest'
Hook 'download_from_google_storage --directory --recursive --num_threads=10 --no_auth --quiet --bucket chromium-webrtc-resources src/resources' took 10.58 secs
________ running '/usr/bin/python src/webrtc/build/gyp_webrtc -Dextra_gyp_flag=0' in '/home/umnteam/webrtc_androd_latest'
Updating projects from gyp files...
/home/umnteam/webrtc_androd_latest/src/third_party/android_tools/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-i686/bin/arm-linux-androideabi-gcc: 1: /home/umnteam/webrtc_androd_latest/src/third_party/android_tools/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-i686/bin/arm-linux-androideabi-gcc: Syntax error: "(" unexpected
gyp: Call to '/home/umnteam/webrtc_androd_latest/src/third_party/android_tools/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-i686/bin/*-gcc -print-libgcc-file-name' returned exit status 2 while in all.gyp.
Error: Command '/usr/bin/python src/webrtc/build/gyp_webrtc -Dextra_gyp_flag=0' returned non-zero exit status 1 in /home/umnteam/webrtc_androd_latest
Please help me to find out the issue
Issue solved after upgrade my RAM. Always check RAM usage while compiling webRTC. It will solve most of the issues.
I Have installed everything required to run and build ionic app, it was running smoothly until now. Suddenly it has started giving all type of errors. I am new to ionic development so not able to understand this. Even tried google search, but was of no help till now.
I am getting below error, when trying to build application. It works perfectly with serve command in local browser. What could be the issue? Let me know if any more details are required from my side.
C:\Users\Solution\reliableapp>ionic build android
Running command: "C:\Program Files (x86)\nodejs\node.exe" C:\Users\Solution\reli
ableapp\hooks\after_prepare\010_add_platform_class.js C:\Users\Solution\reliable
app
add to body class: platform-android
Running command: cmd "/s /c "C:\Users\Solution\reliableapp\platforms\android\cor
dova\build.bat""
ANDROID_HOME=C:\Users\Solution\AppData\Local\Android\android-sdk
JAVA_HOME=C:\Program Files (x86)\java\jdk1.7.0_71
Running: C:\Users\Solution\reliableapp\platforms\android\gradlew cdvBuildDebug -
b C:\Users\Solution\reliableapp\platforms\android\build.gradle -Dorg.gradle.daem
on=true
Downloading http://services.gradle.org/distributions/gradle-2.2.1-all.zip
Exception in thread "main" java.lang.RuntimeException: java.net.UnknownHostExcep
tion: downloads.gradle.org
at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAcc
essManager.java:78)
at org.gradle.wrapper.Install.createDist(Install.java:47)
at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:129)
at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:48)
Caused by: java.net.UnknownHostException: downloads.gradle.org
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java
:178)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:579)
at java.net.Socket.connect(Socket.java:528)
at sun.net.NetworkClient.doConnect(NetworkClient.java:180)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:432)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:527)
at sun.net.www.http.HttpClient.<init>(HttpClient.java:211)
at sun.net.www.http.HttpClient.New(HttpClient.java:308)
at sun.net.www.http.HttpClient.New(HttpClient.java:326)
at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLC
onnection.java:996)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConne
ction.java:932)
at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection
.java:850)
at sun.net.www.protocol.http.HttpURLConnection.followRedirect(HttpURLCon
nection.java:2398)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLCon
nection.java:1557)
at org.gradle.wrapper.Download.downloadInternal(Download.java:59)
at org.gradle.wrapper.Download.download(Download.java:45)
at org.gradle.wrapper.Install$1.call(Install.java:60)
at org.gradle.wrapper.Install$1.call(Install.java:47)
at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAcc
essManager.java:65)
... 3 more
C:\Users\Solution\reliableapp\platforms\android\cordova\node_modules\q\q.js:126
throw e;
^
Error code 1 for command: cmd with args: /s /c "C:\Users\Solution\reliableapp\pl
atforms\android\gradlew cdvBuildDebug -b C:\Users\Solution\reliableapp\platforms
\android\build.gradle -Dorg.gradle.daemon=true"
ERROR building one of the platforms: Error: cmd: Command failed with exit code 1
You may not have the required environment or OS to build this project
Error: cmd: Command failed with exit code 1
at ChildProcess.whenDone (C:\Users\Solution\AppData\Roaming\npm\node_modules
\cordova\node_modules\cordova-lib\src\cordova\superspawn.js:139:23)
at emitTwo (events.js:87:13)
at ChildProcess.emit (events.js:172:7)
at maybeClose (internal/child_process.js:817:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5)
C:\Users\Solution\reliableapp>ionic serve
Running live reload server: http://192.168.1.36:35729
Watching : [ 'www/**/*', '!www/lib/**/*' ]
Running dev server: http://192.168.1.36:8100
Ionic server commands, enter:
restart or r to restart the client app from the root
goto or g and a url to have the app navigate to the given url
consolelogs or c to enable/disable console log output
serverlogs or s to enable/disable server log output
quit or q to shutdown the server and exit
ionic $ q