Applies to Kony Visualizer Classic.
Building and testing Android applications in Kony Visualizer requires two primary resources: Android SDK and Gradle. Gradle is an advanced build toolkit that manages dependencies and allows a developer to define custom build logic. This section describes how to install and configure these resources.
Prerequisites that you need to download:
Required Android SDK Build Tool version is 26.0.2
Required Android SDK Platform API level is 26
Required Android SDK Build Tool version is 27.0.3
Required Android SDK Platform API level is 26
For any queries you may have about installing Android SDKs and Android Studio, see Android SDK and Platform FAQs.
To build and view applications on the Android platform, do the following:
You must install Android Studio for building and testing Android applications using Kony Visualizer. To download and install Android Studio, click Google Android Studio.
Required SDKs and support packages can be optionally downloaded during the Android Studio installation process. If you have not downloaded the required SDKs during the Android Studio installation, you can download and install the Android Command line tools (stand-alone SDK tools) by doing the following:
To download and install the Android Command line tools and necessary support packages, do the following:
Important: For Windows users, install the Android SDK to a folder with a path that has no spaces, for example:
C:\Android\android-sdk
The default installation path contains at least one space, which may result in the emulator not being accessible in Eclipse and, therefore, Kony Visualizer.
You can also download the missing artifacts using Android Studio.
Click Install missing platform(s) and sync project link in the message that appears.
Select the defaults through the Component Installer and wait until Finish is enabled.
Click the Install Build Tools 26.2 and sync project link in the message window.
Select the defaults through the Component Installer and wait until Finish is enabled.
Known Issues:
Now that you have installed the Android SDK, you need to configure Kony Visualizer to recognize the Android platform.
To configure Kony Visualizer to build for the Android platform, do the following:
The following procedure is for the Windows environment, for the Mac, run the following command:export ANDROID_HOME=/<installation location>
To set the Android SDK home environment variable, do the following:
Under some circumstances, you might have to add the Android SDK environment variables manually. This is most commonly necessary if you installed Kony Visualizer before installing the Android SDK. If you already had the Android SDK installed when you install Kony Visualizer, Kony Visualizer detects the presence of the Android SDK and adds the necessary environment variables automatically.
For more information, click the procedure you want.
Add Windows Android Environment Variables Manually
Add Mac Android Environment Variables Manually
To manually set the Android environment variables for a Windows computer, do the following:
/bin
folder in your installation of the JDK. For example:C:\Java\jdk1.7.0_79\bin
/emulators, /tools
, and /platform-tools
folders in your installation of the Android SDK. For example:C:\Android\android-sdk\emulator; C:\Android\android-sdk\tools;C:\Android\android-sdk\platform-tools
To manually set the Android environment variables for a Mac computer, do the following:
.bash_profile
, and then open it. If you do not have the .bash_profile
file, create it./emulators, /tools
, and /platform-tools
folders in your installation of the Android SDK. For example:C:\Android\android-sdk\emulator; C:\Android\android-sdk\tools;C:\Android\android-sdk\platform-tools
On Android 4.1 and lower, the Developer options screen is available by default. On Android 4.2 and higher, do the following:
To List the Android devices connected to the Windows 10 PC, do the following:
adb devices -l
to list the Android devices connected to the Windows 10 PC. To connect to an Android device on your Windows machine, do the following:
monitor.bat
and click on the connected device. Google has stopped supporting the standalone AVD manager and SDK Manager GUI tools, with latest Android SDK tools. When using, latest Android SDK tools >= 25.3.0, support for launching AVD Manager GUI to create android emulators and SDK manager to download missing components are deprecated from Kony Visualizer V8 release. You must install Android Studio on your machine to get GUI to create and use Android emulators. Click here for more information.
Alternatively, you can use avdmanager command line utility to create the emulators. Refer https://developer.android.com/studio/command-line/avdmanager.html for avdmanager command usage.
When using older Android SDK tools( < 25.3.0), you still would be able to create and launch AVDs using AVD Manager and SDK Manager GUI Tools.
This section describes the various Gradle-related changes pertaining to different versions of Kony Visualizer.
The Android plugin version has been updated to 3.0.1.
Gradle version has been updated to 4.3.
compileSdkVersion has been changed to 26.
buildToolsVersion has been changed to 26.0.2.
Support library dependencies changed to 26.0.0.
compileSdkVersion has been changed to 28.
buildToolsVersion has been changed to 28.0.3.
Support library dependencies changed to 28.0.0.
Kony minsdkversion has been changed to API level 17 (4.2).
For using Gradle, you must go through the following sections:
Important: When you upgrade to Kony Visualizer 8.2 and later, ensure that there are no conflicts in the dependencies of the build.gradle and libs folder. For example, appcompat-v7 added to the build.gradle is X version and if the same file is in the libs folder is of Y version. Due to differences in versions of the file, following build exceptions occur.
duplicate entry exception or com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
For more information on how to debug these type of conflicts, click here.
libproject
mechanism. .aar
format in the lib
folder. .aar
format, see Migrating from Eclipse ADT on the Android Developer site.Build failures occur if there are any deviations from the Android-specified requirements. To build an understanding of how Android enforces its requirements, you can create a native application and test various scenarios. In creating such an app, you will want to be aware of the following:
abc.txt
or cert.crt
is added to the drawable folder, Gradle will fail the build.libpng warning: iCCP: Not recognizing known sRGB profile that has been edited
If the build fails with the following exceptions and you do not know the root cause, following the debugging procedure provided here:
Execution failed for the task :app:transformClassesWithDexForDebug.
com.android.build.api.transform.TransformException: Error while generating the main dex list.
DexArchiveException or ProgramTypealreadyPresent or DuplicateClassesException
The debugging procedure for these build issues is as follows:
For Mobile: <workspace>\temp\<appid folder>\build\luaandroid\dist\<appid folder>\
For Tablet: <workspace>\temp\<appid folder>\build\luatabandroid\dist\<appid folder>\
com.android.tools.build:gradle version
to 3.4.0-beta03 in the build.gradle
file:
buildscript {dependencies{classpath 'com.android.tools.build:gradle:3.4.0-beta03'}}
distributionUrl
in the gradle-wrapper.properties
file (available in dist\<appid folder>\gradle\wrapper) to https://services.gradle.org/distributions/gradle-5.1.1-all.zip.gradlew assembleDebug
The build log then prints the complete details of all the conflicting libraries that fetch duplicate classes.
gradlew dependencies
configurations.all { resolutionStrategy { force "com.android.support:design:Y" } }
Remove any duplicate jars or classes found in any of the .aar files and libraries.
For example, you can use the following script to delete the volley and gson-2.2.4 jar files from libs if they conflict with your dependencies in the build.gradle file.
task deleteJars {
delete "libs/volley.jar"
delete "libs/gson-2.2.4.jar"
}}
Note: To add additional entries in the build.gradle file, select the build.gradle entries to suffix option under the Gradle Entries tab in Application Properties. For more information on Gradle properties, click here.
If your computer has proxy settings, you can alleviate build errors at the system level, and at the project level.
To address proxy-related build issues at the system level, you can either disable your computer's proxy settings, or create a gradle.properties file to your Gradle installation.
To create a gradle.properties file, do the following:
C:\Users\<UserName>\.gradle
/Users/<UserName>/.gradle
gradle.properties
gradle.properties
file to include the following settings (replace the values given in the example with your own settings).
For more information, see The Build Environment on the Gradle web site.
To automate project-level requirements, do the following:
gradle.properties
file mentioned earlier to the project folder. For example:C:\<workspace>\<ProjectName>
For the Mac/Users/<UserName>/<Workspace>/<ProjectName>
androidprecompiletask.xml
from the path<workspace>\temp\DeepLinkApp\build\luaandroid\extres
<workspace>\DeepLinkApp
androidprecompiletask.xml
in a text editor such as Notepad or TextEdit, and edit it as your situation requires. For example:<target name = "PreCompileSetup"> <echo message = "basedir = ${basedir}, appdir = ${app.dir}, isMobileBuild = ${isMobileBuild}"> <echo message = "Build mode = ${build.option}, Packagepath = ${packagepath}, x86 Support = ${supportx86}"> <delete file = "${app.dir}/gradle.properties"> <copy file = "${basedir}/gradle.properties"> tofile = "${app.dir}/gradle.properties"> </target>
To manually make the necessary changes at the project level, do the following:
Note: This needs to be done following each time you build the project
<Workspace>\temp\<ProjectName>\build\luaandroid\dist\<ProjectName>
/Users/<UserName>/<Workspace>/temp/<ProjectName>/build/luaandroid/dist/<ProjectName>
gradle.properties
file to include the proxy settings mentioned earlier.gradle assembleDebug
Android generates a packaging error if one or more JAR files have duplicate files or classes. To solve this issue, do one of the following:
cmd.exe
. When it appears in the search results, right-click it, and then click Run as administrator.<Workspace>\temp\<ProjectName>\build\luaandroid\dist\<ProjectName>
/Users/<UserName>/<Workspace>/temp/<ProjectName>/build/luaandroid/dist/<ProjectName>
gradle assembleDebug
packagingOptions
tag in the build.gradle
file. To do so, do the following:build.gradle
file, which is located at the following path:<Workspace>\temp\<ProjectName>\build\luaandroid\dist\<ProjectName>
/Users/<UserName>/<Workspace>/temp/<ProjectName>/build/luaandroid/dist/<ProjectName>
build.gradle
file in a text editor such as Notepad or TextEdit.build.gradle
file, inside the Android tag, add the following lines.packagingOptions { exclude 'META-INF/LICENSE.txt' //File name to delete }
Gradle checks for PNG files while building your application. If a JPEG file in the folder is named as a PNG file (that is, the JPG has a .png extension) Gradle generates a build error. To avoid this issue, Kony developed a Python script tool to check if the image files are correctly named. You can use this tool to convert the JPEG files to PNG.
To use the Python JPG conversion tool, do the following:
https://www.python.org/ftp/python/2.7.10/python-2.7.10.msi
http://effbot.org/downloads/PIL-1.1.7.win32-py2.7.exe
$ python pngConversion.py -p E:\res\drawable(replace with the folder)
The following issues and errors can arise as a result of a Gradle migration.
Gradle Could not resolve com.android.tools.build:gradle:1.3.1
This condition can occur if there is no internet connection or when the system is being used when the proxy is not set. To resolve, set the proxy, or connect the computer to an internet connection.
Error: Gradle Wrapper not found in Android SDK
If you have been using Cordova applications in Visualizer and upgrade your Android SDK tools version to later than 25.2.5, when you build a project with Cordova support the Gradle Wrapper not found error occurs. Android removed Gradle wrapper package from the Android SDK tools version later than 25.2.5. As a result, Gradle wrapper does not exist in the Android SDK PATH and that results in the error.
To resolve, add Gradle to your path environment variable. For more information, refer to Gradle in Android Platform Guide.
Error: Unsupported type net, etc.
This condition can occur if the application is packing some internal files which are used in the android fwk, this would normally happen if the application is be packing *.xml which can be found in the following folder:..\resources\res\values
To resolve, modify the XML files to change the custom tags net to string.
Duplicate Entry error
Occurs when the same .jar files are being added multiple times, or when different .jar files have the same classes. To resolve, remove the duplicate classes from .jar files.
Gradle OOM issue
To resolve, add javaMaxHeapSize (build.gradle), org.gradle.jvmargs(gradle.properties) values to the script. These are general options, which you can configure according to the needs of your app.
Peer not authenticated (proxy with https setting)
To resolve, download the local proxy server certificate and add it to the Java Key store.
Error: Could not create the Java Virtual Machine
Usually occurs when Gradle is not able to allocate the required memory to build the project, generally noticed on 32-bit computers. If the error occurs on a 64-bit computer, add javaMaxHeapSize (build.gradle), org.gradle.jvmargs (gradle.properties) values to the script. These are general options, which you can configure according to the needs of your app.
The following build issue may occur while using the Quantum Visualizer plugin compatible with Android 12(API Level 31) compile-SDK:
[exec-shell] An exception has occurred in the compiler (1.8.0_151). Please file a bug against the Java compiler via the Java bug reporting page (http://bugreport.java.com) after checking the Bug Database (http://bugs.java.com) for duplicates. Include your program and the following diagnostic in your report. Thank you.
[exec-shell] java.lang.AssertionError: annotationType(): unrecognized Attribute name MODULE (class com.sun.tools.javac.util.UnsharedNameTable$NameImpl)
[exec-shell] \tat com.sun.tools.javac.util.Assert.error(Assert.java:133)
You can use one of the following workarounds to resolve the build issue:
Delete the compileOptions entries if Java 1.8 compatibility is not required
If the app does not require compatibility with Java version 1.8, delete the following Android compileOptions from the build.gradle file:
android.compileOptions.sourceCompatibility = JavaVersion.VERSION_1_8
android.compileOptions.targetCompatibility = JavaVersion.VERSION_1_8
The Android Framework does not add these lines of code, by default. You can add these lines by using the precompile-task or the Gradle Entries section of Kony Visualizer if the app requires support for Java 1.8.
Delete the sourceCompatibility entry from the Android compileOptions
Delete the sourceCompatibility
entry from the compileOptions in the build.gradle file, if the application build is successful by using just the targetCompatibility entry as follows:
android.compileOptions.targetCompatibility = JavaVersion.VERSION_1_8
Upgrade the Gradle plugin and Gradle Wrapper
Upgrade the version of the Gradle plugin to 4.0.0 in the build.gradle
file, and the version of the Gradle Wrapper to 6.5 in the gradle\gradle-wrapper.properties
file by using the precompile task.
Upgrade to JDK 11 within Kony Visualizer
Add the following line in the Gradle Entries section of Kony Visualizer:org.gradle.java.home=<jdk11_path>
Note:
Ensure that you provide the correct file path.
For example, org.gradle.java.home=D:\\JavaLoc\\jdk11
.
Copyright © 2013 Kony, Inc. All rights reserved. |