Copy the Chilkat Java Sources into your Android Project
The Chilkat Android download provides the Chilkat classes as Java
source files in the com.chilkatsoft package. Place them so their folder
path matches the package, and Android Studio compiles them with your app.
Where the source files go
Java source files live under app/src/main/java/ in a folder
path that matches their package. The Chilkat classes declare:
package com.chilkatsoft;
So they go in app/src/main/java/com/chilkatsoft/:
app/src/main/java/com/chilkatsoft/
├─ chilkat.java
├─ chilkatJNI.java
├─ CkHttp.java
├─ CkJsonObject.java
└─ ... (all the Ck*.java files)
Steps
-
Create the package folder
Under
app/src/main/java/, create the folderscom/chilkatsoft/(if they don't already exist). -
Copy the source files
Copy every Chilkat
.javafile from the download'ssrc/com/chilkatsoft/into that folder — includingchilkat.javaandchilkatJNI.java, not just theCk*classes. -
Sync the project
In Android Studio, right-click the
javafolder and choose Synchronize (or File → Sync Project) so the IDE picks up the new files.
Also required
- Add the native libraries to
app/src/main/jniLibs/<abi>/libchilkat.so— see Where to put the Chilkat JNI shared libraries. - Load the library with
System.loadLibrary("chilkat")before using any Chilkat class. - Add the
INTERNETpermission to your manifest for any networking feature.
With a default Android Studio project, jniLibs under
src/main/ is recognized automatically — no build.gradle
change is needed. Only set sourceSets { main { jniLibs.srcDirs = [...] } } if
you keep the libraries in a non-default location.
Use the Chilkat classes
Once the sources are in place (and the native library is loaded), import and use Chilkat like any other class:
import com.chilkatsoft.CkGlobal; import com.chilkatsoft.CkHttp; // Unlock once at startup (any string starts the 30-day trial). CkGlobal glob = new CkGlobal(); glob.UnlockBundle("Anything for 30-day trial"); CkHttp http = new CkHttp(); // ... use Chilkat methods