Saturday, October 15, 2016

A checklist on common failures when installing Android Studio and running your Hello World program.

This is a checklist on common failures I met when I was trying to install Android Studio and to make the Hello Android program run.

1. Is the path to JDK set up properly?

Inside your project, go to File -> Project Structure to pop up a window and then check JDK location inside the SDK Location page.

Outside any of your projects, you can also set the same thing in Android Studio main screen. In the bottom, you see configure menu, and click to go to Project Defaults -> Project Structure.


 - When your JDK path is not set up properly, you may see some errors like

     "Error:CreateProcess error=216, This version of %1 is not compatible with the version of Windows you're running. Check your computer's system information and then contact the software publisher."


  cf. android-studio-error-errorcreateprocess-error-216-this-version-of-1-is-not-c 


2. Gradle version problems

Inside your project, go to File -> Settings to pop up a window and then find Gradle in Build, Execution, Deployment section. There can you find a place for you to set the path of your Gradle installation.

Note that build.gralde often has a version information about Gradle your project use to be built with.



  cf. gradle-project-refresh-failed-after-android-studio-update

3. JVM options for Gradle

I oftne see JVM options that should be modified for successful builds. Open up  gradle.properties in you project. You may see JVM options like

 - org.gradle.jvmargs=-Xmx1536m

but people in stackoverflow recommed me to cut it the maximum size down to

 - org.gradle.jvmargs=-Xmx512m -XX:MaxPermSize=512m

I do not know exactly why such a change gives me a success in building my Android project, but 1536m seems to be quite a big number for my notebook computer with 4GB RAM.


 - When you have a problem as one explained above, you may see a error like

 "Error:Unable to start the daemon process.
  This problem might be caused by incorrect configuration of the daemon.
  For example, an unrecognized jvm option is used.
  Please refer to the user guide chapter on the daemon
  at   http://gradle.org/docs/1.10/userguide/gradle_daemon.html
  Please read below process output to find out more:
    -----------------------
  Error occurred during initialization of VM Could not reserve enough space for object
  heap Error: Could not create the Java Virtual Machine.
  Error: A fatal exception has occurred. Program will exit."

 cf. android-studio-gradle-project-sync-failed

4. Too much space on C drive on my Windows due to Android studio, SDK, virtual machines, and projects.

Usually, I am using Windows where C drive is relatively small such as 100GB and D drive is relatively big such as 400GB. But Android Studio seems to install more on C drive by defaults. It may result in the shortage of C drive space in your Windows PC. It is possible to do the followings to mitigate this problem:

 - You can move Android SDK installed in C drive onto your preferred directory in D drive. After installing Android Studio, you can set SDK Location from the main Android studio window (Configure -> Project Defaults -> Project Structure -> SDK Location)

 - It does not mean that you Android Virtual device is created there. Each AVD is created under C:\Users\YourUserName\.android\.avd.  Until now, I do not know how I can move this directory to D drive. Once I know, I will post the information.

 - When you create you Android project, be careful to choose some folder in D drive. The default location is C drive.




6 comments:

rh said...

Hi, I have reached through your blog from stackoverflow -
*** Android Studio Error: Error:CreateProcess error=216, This version of %1 is not compatible with the version of Windows you're running***
I am looking for a solution to this problem. I have tried setting variable path (some suggested) but it does not work.
Can you please let me know what to do.
Thanks,
https://goo.gl/jhMRzZ

CurvyMilfLover said...
This comment has been removed by the author.
pustelnyck said...

Hi!

I've got one more problem:
"Protocol Family Unavailable"
or
"An established connection was aborted by the software in your host machine"

What did work was setting _JAVA_OPTIONS environment variable to make Java use IPv4.
_JAVA_OPTIONS = -Djava.net.preferIPv4Stack=true

Thanks to discussion here:
http://stackoverflow.com/questions/29323700/android-studio-gradle-error-protocol-family-unavailable/

Unknown said...
This comment has been removed by the author.
Unknown said...

@Rahul Kumar
I've solved with :
File-> Project structure -> SDK Location
unflag "Use embedded JDK..." and using this path
C:\Program Files\Java\jdk1.8.0_112 which is where i've installed my jdk

Anonymous said...

Thanks @maurizio vigna
your solution for @Rahul Kumar
solved my problem

Parvez