Android Wrapper

User-Compiled Binaries

Common Requirements

Compilation of the Android wrapper requires a few common wrapper pre-requisites


  • Follow the instructions for Linux & OSX, but the first call to cmake should read:

    cmake .. -DCOOLPROP_ANDROID_MODULE=ON -G "MinGW Makefiles" -DNDK_PATH=c:/Downloads/android-ndk-r10e (change path based on your installation)
  • This change (telling CMake to use the MinGW generator with -G "MinGW Makefiles") is needed because by default on windows it tries to use the most-recent installed version of Visual Studio, which conflicts with the Android SDK.

Linux & OSX

  • Install NDK from here:

  • To Build
    • Check out the sources for CoolProp:

      git clone --recursive
    • Open the CMakeLists.txt file in the CoolProp directory for editing

    • Within the COOLPROP_ANDROID_MODULE modify the command: set(ANDROID_PACKAGE_NAME "CoolProp") to reflect your package name

    • Make and move into a build folder:

      mkdir -p CoolProp/build && cd CoolProp/build
    • If a target architecture other than the default (armeabi) is desired, the ndk-build can be modified by editing wrappers/Android/ For details see

    • Construct the makefile using CMake:

      cmake .. -DCOOLPROP_ANDROID_MODULE=ON -DNDK_PATH=~/Downloads/android-ndk-r10e (change path based on your installation)
    • Now actually do the build:

      cmake --build .
  • To Incorporate into an Android Studio Project
    • Copy the java files from the package directory (i.e build/com/example/myprogram) to the pacakge directory of the android proejct

    • Copy the the build/libs/armeabi folder containing the .so file to the app/src/main/jniLibs folder of the Android Project (you may have create the jniLibs folder).

    • In the main activity of the Android Project add the code below so the CoolProp functions can be called as described in the java wrapper documentation:

      static {

Example Code

package com.example.coolprop.androidexample;

import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.TextView;

public class MainActivity extends ActionBarActivity {

    static {

    protected void onCreate(Bundle savedInstanceState) {

        TextView CoolPropsDisplay = (TextView) findViewById(;
        CoolPropsDisplay.setText(Double.toString(CoolProp.PropsSI("T", "P", 101300, "Q", 0, "Water")));

    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(, menu);
        return true;

    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();

        //noinspection SimplifiableIfStatement
        if (id == {
            return true;

        return super.onOptionsItemSelected(item);
  • activity_main.xml
<RelativeLayout xmlns:android=""
    xmlns:tools="" android:layout_width="match_parent"
    android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity">


            android:textAlignment="gravity" />