Introduction to Android SDK Libraries¶
- All supporting documentation can be found on this site. A PDF is included within the builds to direct you to this site and includes some useful tips on how to use the site.
Library & Resources
Jars: This directory contains all the jar files necessary to run CoPilot
Native Libs: This directory contains native libraries for different processor architectures
Assets: This directory contains all the files needed by CoPilot
AndroidManifest_template.xml: Reference AndroidManifest.xml file
- Sample app APK which can be installed on an Android device
Contains Android Studio Sample Application project
More information about building sample application into Android Studio can be found below.
Library & Resources¶
- This directory holds all of the necessary jars required by SDK Libraries. These must be referenced in your application project
- This directory contains native libraries required by SDK Libraries. These must be referenced in your application project
- This directory contains themes, skins, configuration and other files required by SDK Libraries. These should be copied to your project folder
- This file has receiver and service information as well as permissions required by SDK Libraries. This should be merged with your AndroidManifest.xml file
Sample Application Import into Android Studio¶
The sample application is an example of how CoPilot could be integrated into your application. The APIs available in the sample application provide guidance on how these APIs could be implemented. We recommend you use the sample application as much as possible to guide you how to integrate with SDK Libraries.
If you are just getting started, take a look at MainActivity.java. This is the application’s launcher activity. It demonstrates how to start and bind to the CoPilot service and what to do once the service is started. After binding to the service, you will receive a callback (onCPStartup()) from CoPilot that indicates that the library is ready to receive API calls.
Our sample application has various classes, each of which corresponds to a different API module. These API modules are controlled by ApiMainActivity.java. If you have a question about how to use a specific API, check the corresponding class for further details on how it is intended to be used.
Build the Sample Project with Android Studio¶
To build the SDK Libraries Sample Application in Android Studio, open the SampleApp/CPIKSampleApplication_AndroidStudio directory from Android Studio.
The sample application uses the latest Android SDK and build tools. However, the developer may change compileSdkVersion and buildToolsVersion in build.gradle (module’s) to use different SDK and build tools.
If build tools are changed, the developer may also be required to update the version of support libraries (appcompat-v7, support-v4) under the dependency section in build.gradle(module’s).
Once setup is finished, the user must add their product key to mainActivity.java (Line 68).
Library Integration instructions – Android Studio
Copy all the contents of the “Library and Resources/assets” folder to “<your project>/app/src/main/assets/”. If the assets* folder does not appear under the project in Android Studio, manually synchronize project (FileSynchronize)
Copy all the jars in the “Library and Resources/jars” folder to “<your project>/app/libs/” including android-support-v7-appcompat.jar
If your module’s (not project’s) build.gradle doesn’t contain
compile fileTree(dir: 'libs', include: ['*.jar'])
In the dependencies block, add it. Alternatively, you can add the following lines to the dependencies block:
compile project(‘:androidsupportv7appcompat’) compile files('libs/billinginterfacelib.jar') compile files('libs/com_android_vending_licensing.jar') compile files('libs/copilot.jar') compile files('libs/cpik.jar') compile files('libs/google play licensing library.jar') compile files('libs/googleplaybilling.jar') compile files(‘libs/gson-2.2.4.jar’) compile files('libs/huddevelopkit.jar')
Copy all the contents of the “Library and Resource/native libs” folder to “<your project>/app/src/main/jniLibs/”. If the jniLibs folder does not appear under the project in Android Studio, manually synchronize project (FileSynchronize).
Merge AndroidManifest_template.xml with your project’s AndroidManifest.xml file.
The minSDKVersion and targetedSDKVersion in AndroidManifest.xml are overridden by the values in the module’s build.gradle file
I get a build error during building the Sample application about ‘\@style/Theme.AppCompat’
This can happen when building the Sample App project because it depends on the Android Support library. This can be downloaded and installed from the SDK Manager in Android Studio.
I get a build error while building the Sample application about “Reference to ‘R’ is ambiguous”
The error here will be along the lines of: Reference to ‘R’ is ambiguous, both ‘com…..R’ and ‘com.alk.copilot.R’ match.
If this happens, check if there is a line saying
In your own app’s .java file. If there is, then delete it or comment it out. This should resolve the problem.