package com.couchbase.lite.support;

import com.couchbase.lite.util.Log;

public class Version {

    public static final String VERSION;

    private static final String VERSION_NAME="${VERSION_NAME}";  // replaced during build process
    private static final String VERSION_CODE="${VERSION_CODE}";  // replaced during build process

    static {
        VERSION = String.format("%s-%s", getVersionName(), getVersionCode());
    }

    public static String getVersionName() {
        if (VERSION_NAME == "${VERSION_NAME}") {
            return "devbuild";
        }
        return VERSION_NAME;
    }

    public static int getVersionCode() {
        if (VERSION_CODE == "${VERSION_CODE}") {
            return 0;
        }
        try {
            Integer.parseInt(VERSION_CODE);
        } catch (NumberFormatException e) {
            Log.e(Log.TAG, "Cannot parse version code: %s", VERSION_CODE);
        }
        return -1;
    }


    public static String getVersion() {
        return String.format("%s-%s", getVersionName(), getVersionCode());
    }


}

@@ -354,77 +354,235 @@
     
-VERSION = String.format(%22%25s-%25s%22, getVersionName(), getVersionCode());
+int versCode=getVersionCode();%0A        if (versCode==-1) %7B%0A            VERSION = String.format(%22%25s-%25s%22, getVersionName(), getVersionCode());%0A        %7D else%7B%0A            VERSION = String.format(%22%25s%22, getVersionName());%0A        %7D
 %0A   

use correct VERSION for release versions(without VERSION_CODE in VERSION.java