I'm trying to get a brand new set up in place to run the example Ionic 4 app on an android device. I'm running on a brand new iMac and have installed all the needed prerequisites (ionic cli, npm, JDK8, Gradle, Android SDK, set up environmental variables, etc.) All latest version, fresh install.
I'm able to create the example app, add android platform, and build fine. But when I try to run to a device I get this error:
cordova build android
native-run android --app platforms/android/app/build/outputs/apk/debug/app-debug.apk --forward 8100:8100
[native-run] Error: spawn /Users/mike/Library/Android/sdk/platform-tools/adb ENOENT
[native-run] at Process.ChildProcess._handle.onexit (internal/child_process.js:267:19)
[native-run] at onErrorNT (internal/child_process.js:469:16)
[native-run] at processTicksAndRejections (internal/process/task_queues.js:84:21)
[ERROR] An error occurred while running subprocess native-run.
What concerns me is the file path shown (.../sdk/platform-tools/adb) is different from where I see the location when navigating there myself (i.e. the fresh install of Android Studio has this at the location .../sdk/platform-tools/platform-tools/adb .... (note the extra "platform-tools" folder.
When I run "adb devices" it works, but only when I have the environmental variable (PATH) set to .../platform-tools/platform-tools/adb but when I try the ionic run command its obviously trying the other location. How? Why? What did I install wrong???
After much toiling... final step was to completely uninstall and remove all components of Android Studio, then reinstall again. This solved it and removed the duplicate folders. No idea how it would have happened on a standard install but if anyone else experiences it, this would be my recommendation.
Related
I'm trying to create a React Native app for Android. I use bash from the command line in Windows 10. I browse to the location of my React Native project and then run "react-native run-android". But then I get an error like this:
$ react-native run-android
info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 864 file(s) to forward-jetify. Using 4 workers...
info Starting JS server...
/bin/sh: 1: adb: not found
info Launching emulator...
error Failed to launch emulator. Reason: No emulators found as an output of `emulator -list-avds`.
warn Please launch an emulator manually or connect a device. Otherwise app may fail to launch.
info Installing the 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.
error Failed to install the app. Make sure you have the Android development environment set up: https://facebook.github.io/react-native/docs/getting-started.html#android-development-environment. Run CLI with --verbose flag for more details.
Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081
at checkExecSyncError (child_process.js:601:13)
at execFileSync (child_process.js:621:13)
at runOnAllDevices (/mnt/c/users/lenovo/documents/repositories/upself rn/upself/node_modules/#react-native-community/cli-platform-android/build/commands/runAndroid/runOnAllDevices.js:94:39)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)
TL;DR it tells me to set the environment variable for JAVA_HOME. AFAIK.
The problem is I've already set the JAVA_HOME since I installed the Windows 10 in my laptop which was months ago. I use JDK 12 and have developed few native Android app using Android Studio using this same laptop and never have I encountered any missing JAVA_HOME issue.
This is what I've tried to try to solve this issue:
Run the cmd as administrator
Set the JAVA_HOME to c:\Program Files\Java\jdk-12.0.2\ and the one in Android Studio default SDK location C:\Users\lenovo\AppData\Local\Android\Sdk. Both dont work.
Restart my laptop and cmd (done it multiple times but it still doesnt work).
Put a quotation mark between the path (found this in a stack overflow question).
I've read many questions in stack overflow but none of those works.
So, could anyone help me to solve this problem? Why is it unable to detect the environment path?
According to react native document, you should install just JDK 8 for running react native app
https://facebook.github.io/react-native/docs/getting-started
after installing java and set the environment variable, you must reboot your system.
https://www.thewindowsclub.com/set-java_home-in-windows-10
I installed android studio, I configured the environment variables and everything, I installed genymotion and created a device, but running the react-native run-android in the project folder occurs the following error:
error 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
error Command failed: gradlew.bat app:installDebug. Run CLI with --verbose flag for more details.
please help me in this problem. React-native does not find Genymotion disositivo, in this link has more details: https://pt.stackoverflow.com/questions/382115/react-native-n%C3%A3o-reconhece-genymotion
It tries to connect the emulator to the ADB, by the IP of the device. To check the IP of the device, simply click on an emulator window, the IP address is in the title of the window.
No terminal will run the command:
$ adb connect ip_of_your_emulator:5555
Soon after, run:
$ adb devices
If the name of your file appears in the list, your emulator has been connected successfully!
With the emulator open, simply run the native run-android in the folder of your project.
I've had the same problem earlier this month. As far as I can tell the newer versions of Genymotion don't register on adb devices, a user in the Expo forums speculates it's because they have a paywall now.
I recommend switching to Android Studio, that's what I did to solve my problem.
I ran react-native with the --verbose flag, and got the following error:
...
error Failed to install the app. Make sure you have the Android development
environment set up: https://reactnative.dev/docs/environment-setup.
Error: spawn ./gradlew EACCES
...
So, I gave permissions to the android/gradlew folder as follows:
chmod 755 android/gradlew
But then, I got an error regarding Google Play Licenses:
error Failed to install the app. Please accept all necessary Android SDK
licenses using Android SDK Manager: "$ANDROID_HOME/tools/bin/sdkmanager --licenses".
Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081
So yeah, pretty the solution was:
Downloading Android Studio with its own SDK
Change the env variabe ANDROID_HOME to the one installed with Android Studio
Installing Google Play Licensing Library (In Android Studio, go to Settings>SDK Manager>SDK Tools, select Google Play License Library and then install)
I am building an app using ionic framework.
when I execute the command 'ionic build android' it is showing the following message.
C:\Windows\System32\todo>ionic build android
Running command: "C:\Program Files\nodejs\node.exe" C:\Windows\System32\todo\hooks\after_prepare\010_add_platform_class.js C:\Windows\System32\todo
add to body class: platform-android
ANDROID_HOME=C:\Program Files (x86)\Android\android-sdk\
JAVA_HOME=C:\Program Files\java\jdk1.8.0_66
Error: spawn cmd ENOENT
I am running it on a windows 7 system using node.js command prompt
I have googled, but couldn't find any helpful solution.
Plese help. Thanks in advance
This issue may be due to your are not set current path of npm(C:\Users\\AppData\Roaming\npm) in environment variable.
On some systems, it was the problem of access:
Android Studio 3.0 removes the execute permission from Gradle, breaking the build
you can change the permissions and check the result!
The problem may come from windows services. Windows child process services not running properly.
In windows, OS => Go to System Config and enable all services and restart the computer. For more details check here.
When I tried to install the Android platform, I get a error that the environment variable ANDROID_HOME cant be found, but if I echo it, it proves it exists.
Let me walk you to it:
1) Lets create a new app
dbugger#mercury:~/projects/meteor$ meteor create test
Created a new Meteor app in 'test'.
To run your new app:
cd test
meteor
If you are new to Meteor, try some of the learning resources here:
https://www.meteor.com/learn
2) So far, so good. Lets now install the android platform
dbugger#mercury:~/projects/meteor$ cd test/
dbugger#mercury:~/projects/meteor/test$ meteor add-platform android --verbose
Writing new config.xml
Creating Cordova project
% Creating a new cordova project.
Adding platform Android to Cordova project
=> Errors executing Cordova commands:
While adding platform Android to Cordova project:
Cordova error: CordovaError: Failed to fetch platform android
Probably this is either a connection problem, or platform spec is incorrect.
Check your connection and platform name/version/URL.
undefined
at /home/dbugger/.meteor/packages/meteor-tool/.1.1.10.ki0ccv++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/dev_bundle/lib/node_modules/cordova-lib/src/cordova/platform.js:270:25
at _rejected (/home/dbugger/.meteor/packages/meteor-tool/.1.1.10.ki0ccv++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/dev_bundle/lib/node_modules/q/q.js:797:24)
at /home/dbugger/.meteor/packages/meteor-tool/.1.1.10.ki0ccv++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/dev_bundle/lib/node_modules/q/q.js:823:30
at Promise.when (/home/dbugger/.meteor/packages/meteor-tool/.1.1.10.ki0ccv++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/dev_bundle/lib/node_modules/q/q.js:1035:31)
at Promise.promise.promiseDispatch (/home/dbugger/.meteor/packages/meteor-tool/.1.1.10.ki0ccv++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/dev_bundle/lib/node_modules/q/q.js:741:41)
at /home/dbugger/.meteor/packages/meteor-tool/.1.1.10.ki0ccv++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/dev_bundle/lib/node_modules/q/q.js:557:44
at flush (/home/dbugger/.meteor/packages/meteor-tool/.1.1.10.ki0ccv++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/dev_bundle/lib/node_modules/q/q.js:108:17)
at process._tickCallback (node.js:448:13)
(If the error message contains suggestions for a fix, note that this may not apply to the Meteor integration. You can try running again with the --verbose option to help diagnose the issue.)
3) Well, that did not work out so well. Let's try with sudo
dbugger#mercury:~/projects/meteor/test$ sudo meteor add-platform android --verbose
Adding platform Android to Cordova project
% Adding android project...
android: added platform
Checking Cordova requirements for platform Android
Your system does not yet seem to fulfill all requirements to build apps for Android.
Please follow the installation instructions here:
https://github.com/meteor/meteor/wiki/Mobile-Development-Install:-Android-on-Linux
Status of the requirements:
✓ Java JDK
✗ Android SDK: Failed to find 'ANDROID_HOME' environment variable. Try setting setting it manually.
Failed to find 'android' command in your 'PATH'. Try update your 'PATH' to include path to valid SDK directory.
✗ Android target: Android SDK not found. Make sure that it is installed. If it is not at the default location, set the ANDROID_HOME environment variable.
✗ Gradle: Could not find gradle wrapper within Android SDK. Could not find Android SDK directory.
Might need to install Android SDK or set up 'ANDROID_HOME' env variable.
4) Wait, what? Im sure that environment variable is set. Let's check it.
dbugger#mercury:~/projects/meteor/test$ echo $ANDROID_HOME
/home/dbugger/Android/Sdk
5) I knew it! So why did it fail...? Let's check it up again
dbugger#mercury:~/projects/meteor/test$ sudo meteor add-platform android --verbose
While adding platforms:
error: android: platform is already added
What?! Now it turns out that it DID install in the end?? What is going on here? I suspect something is greatly misconfigured in my system, but I am not sure what...
you are using sudo!
you probably shouldn't
even if the ANDROID_HOME variable is defined for your current user does not mean it is also defined for the root user, which is what the environment of the sudo call will be.
I'd really recommend against using sudo for meteor. If you can avoid that, then it should work and your problem is solved. Otherwise make sure to define the ANDROID_HOME variable also for the root user, or just use
sudo env ANDROID_HOME=[whatever you want it to be] meteor
instead.
I followed the documentation and some tutorials on Phonegap to install it on Windows 7, but I'm stuck.
So far, I've installed Java 1.7.0_06, Ant-Apache 1.9.2, Eclipse, Android SDK with Android 4.3 (API 18), all Tools and all Extras in the SDK Manager), NodeJS 0.10.18 and Git.
I wrote all paths in the PATH variables in Windows it's look like this (decomposed) :
F:\nodejs;
F:\android-sdk\sdk\platform-tools;
F:\android-sdk\sdk\tools;
%JAVA_HOME%\bin;
%ANT_HOME%\bin;
C:\Program Files (x86)\Git\bin
Where %JAVA_HOME% and %ANT_HOME% have the right path, they give me the their version when I type java -version or ant -version in the CLI
So I went in the CLI, I installed Phonegap with the following command :
npm install -g phonegap
It give me the 3.0.0-0.14.3 version when I type phonegap -v.
Now, I went to my folder F:\apps and I created a new project with the following command :
phonegap create hello com.example.hello HelloWorld
Everything goes well, the files are created.
I went in the 'hello' folder, and I typed this command :
phonegap local build android
And there come the problem, I get this error :
[phonegap] adding the Android platform...
[error] The command `android` failed. Make sure you have the latest AndroidSDK installed, and the `android` command (inside the tools/ folder) added to your path. Output:
I tried this command too :
phonegap build android
But it get stuck at this, nothing happen next :
[phonegap] detecting Android SDK environment...
[phonegap] using the remote environment
[phonegap] compressing the app...
After lot's of research, I don't know what I can do anymore to find the problem, and I'm quiet new with all this CLI... So yeah, do you have any idea why the command 'android' failed ?
Thanks
Open environment variables, on the first part 'user variables' add new variable with this name android and the variable F:\android-sdk\sdk\tools;
Then edit the user variables PATH and add this at end of the line %android%;
close your CMD and try again.