How to integrate the Anyline SDK for Android
Hello and welcome to our first tutorial here at Anyline! We will show you how you can easily integrate the Android Anyline SDK into your app and how to generate the community license key! If you want to skip the reading and just watch the video, please jump to the bottom of the page!
The first step to your scanning use case is to create a new Android project in Android studio. The minimum SDK version supported by Anyline is API 15 which is IceCreamSandwich. We are going to create an empty Activity. We actually don’t need it for this tutorial, but it is going to help us later on when we are going to implement a use case. We will call it MainActivity – that’s fine for the moment.
Generally there are two ways to integrate the Anyline SDK into your app. One way is to go to our website and download the SDK bundle which includes the examples app, the source code of the examples app and the SDK for offline integration. The other way is to download and include the SDK with Maven. To do that, we are going to add it as a dependency to the build.gradle in the app-module. In order to do that we have to open the build.gradle and copy the maven part from our documentation and paste it to the gradle file. I always tend to forget the syntax for this step. So we are going to cheat a little bit. And we are going to copy this part from the Anyline documentation website .
In the Android Quick Start Guide, you can see the maven repository. Just copy that and paste it into our gradle file. Now, to add the AnylineSDK as a dependency, we copy the compile dependency also. If we hit sync now, gradle is going to fetch the SDK from the maven storage, and set up the Anyline SDK for us to use. Let’s verify that by opening our MainActivity. And you can see that the Auto-complete feature already suggests the Anyline classes for us. So everything is set up for us already, and we can start to develop our Scanning use case. In order to run our app with the Anyline SDK included, we require a SDK licence key.
Getting the licence key
We will now generate a Community License on the Anyline website. You have to register here and request the SDK key. The best part about this is that the Community License is free for non-commercial usage. You will get an email where you can see the further steps and the link in the email will bring you right to the Anyline customer portal. Just pick a password and register! You will then receive an e-mail with the further instruction to go to the Anyline Portal. There you click on manage licences and we’ll generate the community license in order to get started.
This is the part where we need to go back to our app because a licence is always bound to an application ID or bundle indentifier. This was created before when we created the new app. When we go back to the build.gradle file of the app-module you can see the application ID. Select it here, copy it, go back to the portal and paste it there.
The finish line
That’s all you need to generate the licence. If you hit generate now you receive the licence key! Copy the licence key and go back to Android studio. Open the strings.xml and create a new string and paste the key here. Then you’ve got it as resource in your project. When you now go back to the MainActivity, you can just grab the licence key with getString(R,string.anyline_licence). Now you have your licence and the SDK integrated so now you are all set to start your scanning use case! :)