0
votes

We are trying to build our worklight apk using the new CLI feature. For backward compatability reasons, we have an android sdk folder structure which has API levels up to 18. In another location we have API levels up to 21.

When we run the CLI utility, we get the following error: WARNING: FWLST1119W: Android build will fail because the API level used to compile the project is not supported by the Worklight Studio.

The error goes on to tell us to use version 19 because this is the latest version etc...

The apk will build without a problem from Eclipse - we have configured eclipse to point to the newer android sdk installation folder.

So, my question is, how can we tell the CLI which android installation folder to use?

Thanks in advance.

1
Worklight CLI dosn't have that capabilities right now. To change the sdk for worklight you have to use GUI.BalajiG

1 Answers

0
votes

Ignore the message, the Worklight CLI doesn't build Android APK for you, so it doesn't need a JDK and Android SDK specified. Worklight CLI needs a JDK to compile server side code like custom java code and to build the war file.

The Worklight CLI creates a Android project for a hybrid app in the location "apps/myhybridapp/android/native/" this directory contains a AndroidManifest.xml

To build Android app package (apk) you need to use the android command line.

For example to update the project to be built by ant run the following command:

$ /Users/mfpuser/Library/Android/sdk/tools/android update project -p android/native -t android-19
Updated project.properties
Updated local.properties
No project name specified, using Activity name 'myapp'.
If you wish to change it, edit the first line of build.xml.
Added file android/native/build.xml
Added file android/native/proguard-project.txt

This command added the following files:

$ git status
    android/native/build.xml
    android/native/local.properties
    android/native/proguard-project.txt

The build.xml is a ant build file.

If you open the build.xml you will notice that there are two ways to specify the Android SDK directory. In order of preference: 1. local.properties 2. environment variable ANDROID_HOME

When I ran the command the local.propeties had the following content:

sdk.dir=/Users/mfpuser/Library/Android/sdk

You can edit local.properties to specify a different location for Android SDK

For Android API Level

The android update project also updated the file project.properties with the android target specified on the command line.

Here is the content of project.properties:

# Project target.
target=android-19

You can also edit this file to change the target api.

Now you are setup to run ant to build, make sure the JAVA_HOME is set to Oracle JDK 1.7 which will be need it to build Android App.

Like this:

$ echo $JAVA_HOME
/Library/Java/JavaVirtualMachines/jdk1.7.0_72.jdk/Contents/Home

Now you can run ant for example for a debug build

$ ant -f android/native/build.xml debug

But again there are many ways that Android apk can be built I just described one, you should check the Android documentation for more information including the new build system based on gradle.

I hope this helps.