Welcome Guest! To enable all features, please Login or Register.

Notification

Icon
Error

Options
View
Last Go to last post Unread Go to first unread post
#1 Posted : Friday, April 21, 2017 1:08:21 PM(UTC)

Roberto  
Roberto

Groups: Registered, Tech Support, Administrators
Posts: 39

Thanks: 2 times
Was thanked: 3 time(s) in 3 post(s)

A detailed tutorial for this can be found here: https://www.leadtools.com/help/sdk/tutorials/android-add-references-and-set-a-license.html

One of the more common issues we see in the support queue are issues with setting a license. This post will focus on the Android mobile platform and setting a license there. You can reference additional information regarding setting a license in this FAQ post: https://www.leadtools.com/support/forum/posts/t12112-How-do-I-set-an-evaluation-or-purchased-imaging-license

Android:

1. First, you will need to place the LEADTOOLS kernel as well as your license file in your Android Studio project. In your application's module, place leadtools.jar from /Bin/Java into the /libs folder. Create a /src/main/jniLibs folder, and then create a subfolder for the CPU architectures that you wish to support. In this example, we are supporting armeabi-v7a only. Place the appropriate version of libleadtools.so from /Bin/Android/ into this folder. Then, rename your license file such that it only contains lowercase letters. Create a /src/main/res/raw folder in your module and place the license file there.
add android license

2. Ensure that you are compiling leadtools.jar from the /libs folder. Open your module's build.gradle file and place one of the following lines in the 'dependencies' block. You can opt to compile all .jar files in the /libs folder, or compile individual files.
compile dependencies

3. Lastly, you will need to set your license at runtime. Here is an example on how to do so in onCreate() of your startup Activity. Be sure to replace "your_dev_key_goes_here" with your actual development key.
Code:
public class MainActivity extends AppCompatActivity { 
             
    private final String TAG = "MyTag"; 
             
    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
        super.onCreate(savedInstanceState); 
        setContentView(R.layout.activity_main); 
             
        // Get shared libraries path for APK 
        String sharedLibsPath = ""; 
        if (Build.VERSION.SDK_INT < 9) 
            sharedLibsPath = String.format("%s/lib/", this.getApplicationInfo().dataDir); 
        else 
            sharedLibsPath = this.getApplicationInfo().nativeLibraryDir; 
             
        // Load LEADTOOLS native libraries 
        try { 
            Platform.setLibPath(sharedLibsPath); 
            Platform.loadLibrary(LTLibrary.LEADTOOLS); 
        } 
        catch (Exception ex) { 
            Log.d(TAG, "Failed to load LEADTOOLS native libraries"); 
        } 
             
        // Initialize and set license 
        try{ 
            RasterSupport.initialize(this); 
            RasterSupport.setLicense(getResources().openRawResource(R.raw.leadtools), "your_dev_key_goes_here"); 
        } 
        catch(Exception ex){ 
            Log.d(TAG, "Failed to set LEADTOOLS license"); 
            finish(); 
        } 
             
        // Ensure that the LEADTOOLS kernel is not expired 
        if(RasterSupport.getKernelExpired()){ 
            Log.d(TAG, "LEADTOOLS kernel is expired"); 
            finish(); 
        } 
             
        //... 
    } 
} 

Edited by moderator Wednesday, December 27, 2023 11:36:25 AM(UTC)  | Reason: Not specified

Roberto Rodriguez
Developer Support Engineer
LEAD Technologies, Inc.

LEAD Logo
 

Try the latest version of LEADTOOLS for free for 60 days by downloading the evaluation: https://www.leadtools.com/downloads

Wanna join the discussion? Login to your LEADTOOLS Support accountor Register a new forum account.

You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Powered by YAF.NET | YAF.NET © 2003-2024, Yet Another Forum.NET
This page was generated in 0.144 seconds.