How to Import the Anyline Example Project into Android Studio 2019-05-22T13:21:20+00:00

Project Description

How to Import the Anyline Example Project into Android Studio

Hello and welcome to our second tutorial here at Anyline! We will show you how you can easily import the Anyline Example Project into Android Studio! If you want to skip the reading and just watch the video, please jump to the bottom of the page!

What we will need

Before we start we will need a couple of things for this tutorial.

First of all – we need Android Studio. So if you haven’t installed it yet – no problem – there are lots of tutorials out there on how to do this. Just pause this video and come back once you have installed everything you need.  Next, we’ll need an Android device on which we’ll install and try out our example app. You can use an Emulator if you don’t have a device at hand. Since Android 4.0 Ice Cream Sandwich, the Emulator supports Camera emulation via the computer’s webcam.

Integrate Anyline into your Android app today!

Download Anyline SDK Now!

We have to make sure that USB debugging is enabled on the device, as this is required to install the Android Example Project. If you have not set this up on your device, it’s time to pause the video again and find a tutorial on how to enable developer mode and allow usb debugging on the phone. The last thing we will need is a cable to connect the android device with our computer. That’s it, now we’re all set up and ready to start.  

Giphy of Mr. Burns of the Simpsons

Let’s get started

The example project is part of our SDK download bundle. So to get the source code of the example project we need to download the latest version of the Anyline SDK from the website. Go to and click on the FREE DOWNLOAD button, find the right platform, in this case we want the native Andoroid SDK, and hit the download button. 

Since we only want to get the example project running we do not need to register for now. However, if you want to integrate the Anyline SDK in your own app, you will need to complete registration and generate a license key. In case you want to know more about how to setup a new project with our SDK have look on our first tutorial. After the download is finished, the next thing to do is to find our download bundle and unpack it. As you can see there are several folders in there. The one we are interested in is the AnylineSDK-Examples. Within this folder you find an apk file ready to install on your device, as well as the examples source folder. This is the folder we want to import in Android Studio. You can copy this folder to wherever you want your Android Studio Projects to be placed. I am just going to leave it here for this demo. So next we open Android Studio and click on “open an existing Android Studio Project”, we navigate to the AnylineSDK-Examples folder and select the source folder. Next hit ok and wait for Android Studio to import the project.

Importing the Example Project

You will probably get a message that the gradle settings are not set for this project yet. When you click OK, the gradle wrapper will take care of downloading the latest supported gradle version. When you click on CANCEL you can manually set the path to a local gradle distribution. We want the gradle wrapper to take care of everything, so we’ll hit ok and wait. 

giphy of man sitting in a chair and waiting

Ok, so now we got an error that ndk integration is deprecated for the current plugin. So Android Studio suggests 2 possible solutions: try out a new experimental gradle plugin or setting the option “useDeprecatedNdk” to true in the gradle properties file. We’ll go for the second option, so click on it and wait for Android Studio to fix it.

Oh… another message. Now Android Studio recommends that we update the Gradle plugin version. Since there is already a more recent version available than the one we used in our version of the example project. We’ll just click “remind me later” and use the old version for now.

You can always update the gradle version later, in fact Android Studio will remind you to do so the next time you open the project. The progress bar on the bottom vanished and there are no more messages, so apparently everything finished correctly.

Getting an overview of the project structure

Now, we want to get an overview about the project structure. To do so we hit the project tab on the top left side of the Android Studio window and navigate to the app folder. In the java directory we’ll find all the java classes for this examples app. Since we are mainly interested in the Anyline relevant classes we look for all the Activities with names starting with the word “Scan” which are nicely grouped per module. So, if we are looking for the barcode example we open the ScanBarcodeActivity in the corresponding folder.

All the energy relevant Activities can be found in the meter module and most of the other Activities are in the ocr package. This ocr module will be especially interesting, if you want to build your own use case. But more on that later. If we now open the ScanVoucherCodeActivity for instance, we get a good example on how to integrate the AnylineOcrScanView and how to configure it using the AnylineOcrConfig.

If you want a detailed description about the available parameters and how they work, you can check out our documentation and look for Parameters under Modules – AnylineOcr.

If you rather have a practical example, stay tuned for our next video, where we will give a short demo on how to configure the ocr module for a totally new use case, using only the AnylineOcrConfig and the Anyline View Configuration. 

Speaking of Anyline View Configuration, you can find these config files in the assets directory.

Let’s look at the voucher code example again.With this json file you can easily customize the look and feel of your ScanView. For example you can change the cutout in size, color or position, exchange the flash logo and position or adapt your feedback options. There are lots of different options to customize the view to your personal needs. For more details, have a look at our documentation site.

Run the project on your device

But let’s get back to our main goal of this video, which is to import the Project and run it on our device. We already finished the import of the source project, now everything that is left to do is hit run. So we just klick this green arrow in the middle of the toolbar and select the device on which we want to install it. If you have not connected your device to the computer your devices list will be empty like mine. Let’s change that – just connect the device to the computer using a usb cable. If it’s the first time connection your phone, you will a dialog like this …. asking to “trust this computer”, let’s check the box to always trust this computer, to avoid this dialog in the future and click ok.

Now, the device should be listed under “connected devices”. If it’s not there don’t panic, just click cancel and run again, then it should appear. Select your device and hit ok. Now, we just have to wait until the build process is finished and the generated apk file will be installed on the device. This can take some time…. So in the meantime we can get some demo material, which we want to scan later. If you have a barcode or maybe your passport next to you, you can try out the app with that.

But since not everybody has all the stuff handy we can scan, we made an examples sheet with some images of all use cases that are available in our Anyline OCR Scanner on google play. You can find the pdf on our website by clicking Demo Material in the footer.  Now you can either print it out or try scanning from the screen. Just be aware that with a low screen resolution or reflections the scan process might not work that well as with real life examples. 

The install should be finished by now, so let’s check it out.

Ready to try out scanning!

If everything worked correctly, the app should be installed and already started.  

Great – Now we can try out scanning. Just select any mode you want –  but we’ll stick to the Voucher Code use case we saw earlier. If you have a device running Android 6.0 or higher, you will get a dialog which requests permission to use the camera. So if you want to scan anything, we need the camera. Just hit ok.

Here we go. Place the image in the cutout and – et voilà – there is our result.  

Great! You made it. You successfully imported the examples project in Android Studio and installed the app from source on your device! :) 

If you’ve read this and you’re curious about the Anyline SDK, go ahead: download it and try it out for free! And most important: if you like, give us feedback on the process! :)


If you have questions, suggestions or feedback on this, please don’t hesitate to reach out to us via FacebookTwitter or simply via [email protected]! Cheers!