Running Phonegap Android app on OSX - android

I am trying, to no avail, to run an Android version of a Phonegap app I have made.
The app works fine on iOS when running:
phonegap run ios
However, when I run:
phonegap run android
I get
[phonegap] executing 'cordova run android'...
[phonegap] completed 'cordova run android'`
But nothing happens. When I run:
phonegap run android --verbose
I get the error(s):
BUILD FAILED
/usr/local/Cellar/android-sdk/24.1.2/tools/ant/build.xml:601: The following error occurred while executing this line:
/usr/local/Cellar/android-sdk/24.1.2/tools/ant/build.xml:653: The following error occurred while executing this line:
/usr/local/Cellar/android-sdk/24.1.2/tools/ant/build.xml:698: null returned: 1
and
ERROR running one or more of the platforms: Error: /Users/*/Google Drive/Websites/angular-phonegap/*/platforms/android/cordova/run: Command failed with exit code 1
You may not have the required environment or OS to run this project
I faced a similar problem in the past that involved editing my PATH variable, not sure if this is the same issue or what. In any case, any help is greatly appreciated.
Thanks

i think that you not have all requirements, please check another time, as you can see here, cordova fail with this error where not find a specific platform command to run.
Follow these instruction:
Check that the java sdk is already installed and already in your Path.
Check to have already installed android studio or sdk standalone and the bin folder of the sdk is in Path.
Check to have installed ant ( on Mac install it with brew, this is the best option ) and to have it in path.
For a complete list to check refer to this cordova docs.
Be patient and follow the step one by one, your problem must be in one of these steps.

Related

Android Studio doesn't install SDKs... what?

I'm trying to use Cordova to build a hello world app and after adding ANDROID_HOME variable (You'd be shocked how long that took to figure out) all I keep seeing when building is this:
BUILD FAILED
Total time: 1 mins 6.679 secs Error:
/Users/vladdy/Desktop/laboratory/cordovaBackgroundApp/platforms/android/gradlew:
Command failed with exit code 1 Error output:
FAILURE: Build failed
with an exception.
What went wrong: A problem occurred configuring root project 'android'.
Failed to find target with hash string 'android-25' in: /Users/vladdy/Library/Android/sdk
Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
Ok fair enough so let's go install it:
Waiting patiently for the install, and same error running cordova build.
I wonder what else we need to install? But look, it seems that Android Studio still has Nougat and 25 available:
Why is Android Studio not installing anything?
I can see why PhoneGap Build is so popular...
Edit:
cordova requirements is now broken reporting the following:
My ~/.bash_profile:
export ANDROID_HOME=/Users/vladdy/Library/Android/sdk/
Requirements?
If you don't need Android Studio, I recommend not downloading it, instead, as #Tom-Esendam also suggest, go for the command-line tool.
Android Studio and Command Line Tool
Direct download link of Command Line Tool for OSX (2017-03-21)
Proxy?
And if your behind a proxy server, don't forget to add it to the settings in the SDK Manager Settings.
What does the different programs and commands?
cordova build doesn't download any SDK's.
cordova prepare appends the necessary SDK files to the cordova build folders.
After download of Command Line Tool:
After unzipping it, set ANDROID_HOME to it's root, so you have:
build-tools
extras
platforms
platform-tools
system-images
tools
catalogs under the root.
Adding SDK's:
Then install SDK's with ./tools/android.
Android SDK Manager downloads the SDK's, so you check what you need and hit OK to download it.
Preparing the build
Make sure all proxy settings are set if your behind a proxy.
Before running cordova build run cordova prepare. This shouldn't be necessary, but least I need to run that even thou cordova build should include that.
I don't know about the mac version. But on windows you have a standalone sdk manager. If there is one on mac try that?

Cordova fail when try to build Android app with error "Command failed with exit code 2" Linux

I'm using Ubuntu Gnome 14.04 64 Bit (for the moment) with kernel 3.19.0-33-generic.
I created a new app (a clean one, no plugin, no www folder with content) to try to build it.
After type in the bash "cordova build android"
I get this error:
Running command: /home/aby/Desktop/testApp/platforms/android/cordova/build
[Error: Android SDK not found. Make sure that it is installed. If it is not at the default location, set the ANDROID_HOME environment variable.]
ERROR building one of the platforms: Error:/home/aby/Desktop/testApp/platforms/android/cordova/build: Command failed with exit code 2
You may not have the required environment or OS to build this project
Error: /home/aby/Desktop/testApp/platforms/android/cordova/build: Command failed with exit code 2
Now if you printenv | grep android
You will get
ANDROID_HOME=/opt/android-sdk-linux
ANDROID_PLATFORM_TOOLS=/opt/android-sdk-linux/platform-tools
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/opt/android-sdk-linux/tools:/opt/android-sdk-linux/platform-tools:/opt/android-sdk-linux/tools:/opt/android-sdk-linux/platform-tools:/home/aby/bin:/home/aby/opt/jdk8/jdk1.8.0_45/bin:/opt/android-sdk-linux/tools:/opt/android-sdk-linux/platform-tools:/opt/android-sdk-linux/tools:/opt/android-sdk-linux/platform-tools
ANDROID_SDK=/opt/android-sdk-linux
You can see that the variables exist, in fact before I run cordova build android I had to use cordova platform add android and its works with no problem.
So I found this Bug, and tried some solution like update android(project) or remove and install it again with no success.
I reinstall the Andoroid SDK, and updated the "/.bashrc", "/.profile" and "~/.pam_enviroment" with the environment values and also this not help.
So how can I fix this? How can I build my app with no error? What I missing?(If you consider that you need another information please tell me).
Thanks, in advance.
At the end I could fix my problem when I change the "Owner" / "Group" to the android sdk folder and Permission to "/tools/android".
Here a link to my previous question, and the solution (at least for me) to fix this error.

ionic build android stopped working

In my Windows 7 machine, I had ionic build android working. I could build the apk, deploy/debug with ionic run android --livereload --consolelogs etc. All of sudden (as in I don't know what possibly could have caused this), the ionic build android stopped working. When I try to run it, it freezes in this screen:
ajunior#DES6635D C:\src\to\my\project
> ionic build android
Running command: "C:\Program Files\nodejs\node.exe" C:\src\to\my\project\hooks\after_prepare\010_add_platform_class.js C:\src\to\my\project
add to body class: platform-android
Running command: cmd "/s /c "C:\src\to\my\project\platforms\android\cordova\build.bat""
Event after an hour or so, no output is given; I have to manually break the process with Ctrl+C.
Any suggestions? The strange thing is that this was working this morning (and all the other days for the last two weeks), so I believe that it's not related to PATH, Android SDK or anything like that. Nothing was installed, uninstalled or updated in this time. I already tried restarting the machine, but that also didn't work.
When in path via cmd run: cordova build android --ant
It will build like that (you must have ant installed of course).
Then: cordova run android
If cordova run android gives issues just fetch the apk from the build folder in your ionic project:
platforms\android\build\outputs\apk
Then allow cellphone to accept Unknown Sources, copy the file to your phone and install.

Error during executing Android command: Ant Jar

So this is the error I get when I try to run any command except "create".
An error occurred during creation of android sub-project. Creating Cordova project for the Android platform: Command failed to execute : ant jar
These are my PATHS
PATH "%JAVA_HOME%\bin;%ANT_HOME%\bin"
JAVA_HOME "C:\Program Files\Java\jdk1.7.0_45"
ANT_HOME "C:\java\ant\apache-ant-1.8.2"
My OS: Windows 8
PS: I've gone through every single post that stated this error but, none of the responses solved my issue.
I discovered this was a phonegap version related issue. When I updated it was all fine.

Cordova (v3.0.0) CLI failing on Mac - no output for 'which android' command

All,
I am trying to upgrade to Cordova v3.0.0 and have installed the cordova package from npm, have installed the latest Android SDK and ensured the necessary PATH variables are in place.
Also I can run adb and android commands from terminal, but I noticed that I don't get any output for which android command.
And the which not resolving I believe is the error I am getting when I try to do cordova platform add android in my newly created project. The error is:
[Error: An error occured during creation of android sub-project. An unexpected error occurred: ANDROID_BIN="${ANDROID_BIN:=$( which android )}" exited with 1
Deleting project...
]
I have been poring over all the Google search results for this error and as to why which android does not resolve, but to no avail.
Could someone please help me out?
Figured out finally !
I had included the platform-tools and tools like this:
PATH="~/android/sdk/tools:~/android/sdk/platform-tools:$PATH"
And when I changed that to the below, it just started working...
PATH="/Users/<username>/android/sdk/tools:/Users/<username>/android/sdk/platform-tools:$PATH"
So much for the which implementation in Mac. Hope this might helps someone starting with Mac like me.

Categories

Resources