0

Iam new with cordova.

I have been installed cordova on my computer system.

I have been followed the instruction that i got from internet.

I have installed node js version "V4.4.5 X86".

I have installed Ant Apache version "1.9.6".

I have installed git version "2.16.2.windows.1".

I have installed cordova version "8.0.0" using "npm".

I have installed phonegap version "8.0.0" using "npm".

I have installed the stand alone Android SDK "Installer R24.4.1 Windows".

I have set my global environment variable on windows.

These are the list of variable that i have been input :

- JAVA_HOME : C:\Program Files\Java\jdk1.8.0_05
- ANDROID_HOME : C:\Program Files\Android\android-sdk
- ANT_HOME : C:\apache-ant-1.9.6

and i have been added value for "PATH" variable with this :

- C:\Program Files\Java\jdk1.8.0_05\bin;
- C:\Program Files\Android\android-sdk\tools;
- C:\Program Files\Android\android-sdk\platform-tools;

Four above is the new value that i added, of course iam using semicolon for value separator.

This is the full value for PATH Variable on my computer :

- C:\Windows\system32;
- C:\Windows;
- C:\Windows\System32\Wbem;
- C:\Windows\System32\WindowsPowerShell\v1.0\;
- C:\Program Files\nodejs\;
- C:\Program Files\Java\jdk1.8.0_05\bin;
- C:\Program Files\Android\android-sdk\tools;
- C:\Program Files\Android\android-sdk\platform-tools;
- C:\apache-ant-1.9.6\bin;C:\Program Files\Git\cmd

When i start to run cordova command for creating a project it just fine.

Here is the command.

cordova create hello com.example.hello HelloWorld

The command run fine.

After that i run command for add android platform.

Here is the command.

cordova platform add android

The command run fine.

And then the problem come when i build the apps using this command.

cordova build

When the command run it just stop until this.

Android Studio project detected
ANDROID_HOME=C:\Program Files\Android\android-sdk
JAVA_HOME=C:\Program Files\Java\jdk1.6.0_16

It just stop like that, there is no error, i dont know what to do.

And i have been use --verbose to know detail.

Here is the --verbose output detail.

No scripts found for hook "before_build".
No scripts found for hook "before_prepare".
Checking config.xml and package.json for saved platforms that haven't been added to the project
Config.xml and package.json platforms are the same. No pkg.json modification.
Package.json and config.xml platforms are different. Updating config.xml with most current list of platforms.
PlatformApi successfully found for platform android
Android Studio project detected
Checking config.xml for saved plugins that haven't been added to the project
Checking for any plugins added to the project that have not been installed in android platform
No differences found between plugins added to project and installed in android platform. Continuing...
Generating platform-specific config.xml from defaults for android at D:\Project\hello\platforms\android\app\src\main\res\xml\config.xml
Merging project's config.xml into platform-specific android config.xml
Merging and updating files from [www, platforms\android\platform_www] to platforms\android\app\src\main\assets\www
Wrote out android application name "HelloWorld" to D:\Project\hello\platforms\android\app\src\main\res\values\strings.xml
android-versionCode not found in config.xml. Generating a code based on version in config.xml (1.0.0): 10000
Wrote out Android package name "com.example.hello" to D:\Project\hello\platforms\android\app\src\main\java\com\example\hello\MainActivity.java
This app does not have launcher icons defined
This app does not have splash screens defined
This app does not have additional resource files defined
Prepared android project successfully
No scripts found for hook "after_prepare".
No scripts found for hook "before_compile".
ANDROID_HOME=C:\Program Files\Android\android-sdk
JAVA_HOME=C:\Program Files\Java\jdk1.6.0_16

But i have still got no clue what does the output above means.

This is the tutorial that i have follow.

- https://www.youtube.com/watch?v=atH7naB4fDk -----> Installing Cordova & Android SDK on Windows 7, 8 & 10 to Develop Mobile app

- https://www.youtube.com/watch?v=qMhBnzGIsqk -----> How to Install Phonegap CLI and Cordova CLI on windows for android

I try to use an alternative using phonegap command, because i already install phonegap on my machine.

I use this command to build my project.

phonegap create testing

The command run fine.

After that i run command for add andrroid platform for phonegap.

Here is the command.

phonegap platform add android

The command run fine.

And then the problem is when build the apps using this command.

phonegap build android

Here is the output for the command.

[phonegap] executing 'cordova build android' ...
[phonegap] completed 'cordova build android --no-telemetry'

The problem is i dont get the "apk" file.

Please, i really need help.

It really makes me feel desperate.

I still dont know what should i do to resolve this.

I have record the video, so you all can see what i really face.

https://www.youtube.com/watch?v=fDRHcaAt_WY

I have downloaded all i need using SDK Manager.

This is the screenshot.

SCREENSHOT 1

SCREENSHOT 2

I hope you also watch the video.

Iam not write this question for my video rate.

I make a video so you can see more clearly about problem that i faced.

Iam sorry for my bad english.

Ikhsan Bahar
  • 154
  • 1
  • 1
  • 14
  • Did you load the project in android studio which is generated using command prompt – kiran kumar Mar 30 '18 at 11:25
  • I load the project file using cordova command, iam not using android studio. – Ikhsan Bahar Mar 30 '18 at 11:42
  • what's `cordova requirements` shows? I don't see you installed gradle. – scor4er Mar 30 '18 at 11:43
  • Did you mean i have to install android studio for using cordova..? – Ikhsan Bahar Mar 30 '18 at 11:43
  • You should install android studio & import the project in to android studio and search how to generate apk – kiran kumar Mar 30 '18 at 11:46
  • @scor4er this isi the result `Please install Android target / API level: "android-26". Hint: Open the SDK manager by running: "C:\Program Files\Android\android-sdk\too ls\android.bat" You will require: 1. "SDK Platform" for API level android-26 2. "Android SDK Platform-tools (latest) 3. "Android SDK Build-tools" (latest) Gradle: not installed Could not find an installed version of Gradle either in Android Studio, or on your system to install the gradle wrapper. Please include gradle in your path, or install Android Studio` – Ikhsan Bahar Mar 30 '18 at 11:48
  • First of all thanks for the clue @scor4er so how i can install gradle..? – Ikhsan Bahar Mar 30 '18 at 11:49
  • @kirankumar i think android studio for cordova is an optional because we will not used java programming, dont you think so..? – Ikhsan Bahar Mar 30 '18 at 11:50
  • its optional but you can debug better and generate signed apk & so on... so i recommend to install android studio – kiran kumar Mar 30 '18 at 11:53
  • So what i faced for now is only because my cordova doesnt meet the requirement..? – Ikhsan Bahar Mar 30 '18 at 11:56
  • @Forkiki you could install gradle without Android Studio using scoop for example: `iex (new-object net.webclient).downloadstring('https://get.scoop.sh')` `scoop install gradle`. That's for PowerShell. – scor4er Mar 30 '18 at 11:57
  • where i can input that command @scor4er ? – Ikhsan Bahar Mar 30 '18 at 11:58
  • @Forkiki after this you either need to install `android-26` platform or go to gradle config file and change your platform to the android-24 which is already installed on your machine. – scor4er Mar 30 '18 at 11:59
  • @scor4er How can i do it on window..? is Power Shell a different Software..? – Ikhsan Bahar Mar 30 '18 at 11:59
  • @Forkiki PowerShell is a standard windows tool. Run->powershell – scor4er Mar 30 '18 at 12:00
  • ok thanks again @scor4er i will try my very best again to continue my cordova project. – Ikhsan Bahar Mar 30 '18 at 12:03
  • Thanks too @kirankumar for your suggestion. – Ikhsan Bahar Mar 30 '18 at 12:03
  • @Forkiki I added my comments as an answer, good luck! – scor4er Mar 30 '18 at 12:15

2 Answers2

1

So you haven't installed Android Studio. That's the source of problems. But you could avoid them.

At first to diagnose a problem you need to run the cordova requirements command. You already have run it and now you see the output:

Please install Android target / API level: "android-26". 
Hint: Open the SDK manager by running: "C:\Program Files\Android\android-sdk\too ls\android.bat" 
You will require: 
1. "SDK Platform" for API level android-26 
2. "Android SDK Platform-tools (latest) 
3. "Android SDK Build-tools" (latest) 
Gradle: not installed Could not find an installed version of Gradle either in Android Studio, or on your system to install the gradle wrapper. Please include gradle in your path, or install Android Studio

So you can see two problems.

  1. You don't have the android platform/build-tools version 26 installed. Cordova requires it.

To fix this: open your Android SDK manager and check the needed platform. android-26 in your case. Don't forget to check the latest build tools and platform tools also.

  1. You don't have gradle installed. To install it you could use scoop tool (

To fix this: open PowerShell (Run->powershell). Run the following commands (you need to have PowerShell version 3 to do this).

iex (new-object net.webclient).downloadstring('https://get.scoop.sh')
scoop install gradle

Now run cordova requirements command again. It should say that you're OK to build the project.

An easier way is just to install Android Studio which already has gradle and Android SDK manager included.

scor4er
  • 1,580
  • 12
  • 23
  • WOOW, thanks again @scor4er, you answer is really help, i will let you know as soon as possible for my next trial result. – Ikhsan Bahar Mar 30 '18 at 12:21
  • Hi @scor4er, iam really sorry for my late reply. What you saying about gradle is absolutely correct and now my cordova is run well for building an android APK. Thanks again to you. Maybe I will try to post more detail on answer section. – Ikhsan Bahar Apr 07 '18 at 09:10
0

There are several things that you have to pay attention for before you build an android APK using cordova.

First : Make sure that you have installed "nodejs", you can download "nodejs" from nodejs official website "https://nodejs.org/en/" so you can get a latest version of "nodejs".

Second : Make sure that you have installed "npm". "npm" is a stand for "Node Package Manager" so you can install cordova using "npm" command. To see that you have installed "npm" you can check inside your "nodejs" folder that usually located in "C:\Program Files (x86)\nodejs" or in where ever folder location depends on first configuration when you install nodejs.

Third : After you have checked that "npm" have installed inside your computer, you are ready to install cordova by run "npm install -g cordova" in your command prompt and then wait until the instalation is finish.

Fourth : After you have installed "cordova" inside your machine, now you can create a new android project by following the instruction from cordova official wbsite. "https://cordova.apache.org/docs/en/latest/guide/cli/index.html"

OK, now lets move on to step 5.

Fifth : After you have followed the instruction from cordova official website until you create a new android project and until you create an android platform, you still cannot build an APK yet before you install "gradle" inside your computer.

Sixth : You can download gradle from gradle official website "https://gradle.org/" or you can download the zip file from this website "https://services.gradle.org/distributions/" if you download a zip file you only need to extract the file to where ever location you want, but i will assume that you install it on "C:" location and i will assume that you are using Windows.

Seventh : In this step maybe it quite difficult or maybe not, because you have to make sure that you have set all environment variables that needs to build an android APK. To set the environment variable you can click "start" button on your desktop and just type "variable" on search box and choose "Edit the system environment variables", after you click it, the "System Properties" window will appear and then click "Environment Variables" buttons, after you click the button, "Environment Variables" window will appear. Now you can set some new variables that needs for APK build.

Before we continue there is one thing that you have to make sure, you have to install an "Android SDK Manager" in order to download all needs to build an android APK based on android version that you get from your cordova.

To check your android version just type "cordova platform version android" in your command prompt.

You can download a stand alone "Android Development Tools Installer" in order to get your own "Android SDK Manager" from this website "https://filehippo.com/download_android_sdk/download/dd03cc329af0cd74b0e34afce1b4888e/" i get the download link from stackoverflow answer link "https://stackoverflow.com/a/43893235/3367798".

After you download a stand alone "Android Development Tools Installer", you can install it on your computer, and then after you install it, you can open "SDK Manager" that located at folder that you have configured when you install it.

After you have opened "SDK Manager" you can download all needs in order to create an android APK.

OK, now these are the list of variable that you have to input. You have to input it on "System variables" section .

Variable name: _JAVA_OPTIONS
Variable value: -Xmx512M

Variable name: ANDROID_HOME
Variable value: D:\Android\android-sdk

In this case i put my "Android Development Tool" at "D:" location.

Variable name: GRADLE_HOME
Variable value: C:\GRADLE

Variable name: JAVA_HOME
Variable value: C:\Program Files (x86)\Java\jdk1.8.0_121

After you add all environment variables above, now you have to add value for "Path" in "System variables" section, here are the value that you have to add.

%JAVA_HOME%\bin;
%ANDROID_HOME%\tools;
%ANDROID_HOME%\platform-tools;
%GRADLE_HOME%\bin

Please pay attention for semicolon ";" sign because it is the delimeter that read by system.

Eight : After you follow all instruction above then you can build your own APK using this command "cordova build android".

Please pay attention for "JAVA", you have to make sure that you have installed "JAVA" on your computer. It usually located at "C:\Program Files (x86)\Java". If you doesn't see the folder then you have to download it from this website "https://java.com/en/download/".

If you read word by word all instruction above carefully then it should works, because for me it works.

I hope what i wrote above is helpful.

CHEERS.

Ikhsan Bahar
  • 154
  • 1
  • 1
  • 14
  • If you have an error that caused by "licenses" you can solved it by following this youtube video `https://www.youtube.com/watch?v=IvXqvFETzYA` – Ikhsan Bahar Apr 07 '18 at 09:17