Can't create Android build

Hi all.

I’m facing a problem when I’m trying create android builds.

When I run the command: ionic run android I get the following error:

Running command: “C:\Program Files\nodejs\node.exe” C:\Users\Felipe\Desktop\projects\scgasapp\hooks\after_prepare\010_add_platform_class.js C:\Users\Felipe\Desktop\projects\scgasapp

add to body class: platform-android

ANDROID_HOME=C:\Users\Felipe\AppData\Local\Android\sdk

JAVA_HOME=C:\Program Files\Java\jdk1.8.0_65

The system cannot find the path specified.

Error: cmd: Command failed with exit code 1

My system information:

Cordova CLI: 7.0.1
Ionic CLI Version: 2.1.8
Ionic App Lib Version: 2.1.4
ios-deploy version: Not installed
ios-sim version: Not installed
OS: Windows 10
Node Version: v6.10.3
Xcode version: Not installed

My ANDROID_HOME and JAVA_HOME are valid.

Anyone can help me with this problem?

Thanks!

Hello,

  1. Is your android device connect via USB to your windows device?
  2. Is it recognized with drivers? (check connected devices on chrome inspector tools for example)
  3. If all the above are yes, then it’s because of the Android JDK. With recent updates the path of JAVA_HOME=C:\Program Files\Java\jdk1.8.0_65 changed. So your Ionic project is looking for the wrong place basically. You require an update, but if you do so, Ionic V1 will also stay to the old pathes and it will put you in a chain of updates.
    If you record the new pathes of Android JDK, you can tell it in some file in Windows (windows environment variables), and Ionic manually. But as I started with Ionic V2, I can’t tell you sorry.

Have fun with ionic :slight_smile:

Generally error messages that sound like this are preceded immediately by whatever “the path specified” was, which is pretty vital information.

Hi, thanks for your reply.

  1. Is your android device connect via USB to your windows device? Yes
  2. Is it recognized with drivers? (check connected devices on chrome inspector tools for example) Yes
  3. image

image

I got everything updated… Really don’t know what is happening.

@felipesabino I think because now Windows doesn’t know where is java core located, and same for Ionic.
I explain.

Go to my computer > properties > environment variables. On my old Win 7 this look like that, with a button for environment variables.
image

There is the same in Win10, just not at the same place. I know this Android JDK place changed when I updated Android, but it doesn’t update it in Windows core/start values. Try to change them and reboot windows so they both match :slight_smile: And if all goes well, your “android run” should work again.

Hope it helps =)

Problem solved.

Uninstall Ionic
Unistall Android Studio(And SDK)
Reinstall last ionic version
Reinstall last Android Studio version
Delete the project platform and node_modules folders
Run the command ionic cordova run android (My ionic version is 3)
CLI will ask to install some versions of ionic, I just choosed yes
After that I runned in the android device with success

Thanks for the messages!