Creating a New Android Project
In this tutorial we will create a simple line chart with SciChart Android. Let's start by creating a new Android project in AndroidStudio and adding SciChart libraries as dependencies to it.
First, in Android Studio create a project with a Basic activity. The minimum SDK version must be API 19 (Android 4.4 KitKat) or higher:
The next step is to add SciChart libraries as dependencies to the project. We explain that below.
Setting Up the Build Configuration
To be able to use SciChart classes in your application, you need to add the SciChart Android libraries (AAR) as project dependencies. You can use Maven to download them from the web or download them directly.
Using Maven
The SciChart Android Maven repository URL is https://www.myget.org/F/abtsoftware/maven.Follow the steps below to configure your project to reference the SciChart Android libraries from Maven.
1. Open the "build.gradle" file for the project and declare a new Maven repository in the "repositories" node inside the "allprojects" node. Use the URL from above:
allprojects |
Copy Code |
---|---|
allprojects { repositories { jcenter() // Declaring a new Maven repository maven { url 'https://www.myget.org/F/abtsoftware/maven' } } } } } |
The screenshot below shows where the file can be found in the Project window in AndroidStudio:
2. Open the "build.gradle" file for a module which SciChart is intended to be used within. Add SciChart Android libraries as module dependencies:
Copy Code | |
---|---|
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.google.android.material:material:1.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
// Declare SciChart libraries as module dependencies
implementation (group: 'com.scichart.library', name: 'core', version: '3.0.0.4253', ext: 'aar')
implementation (group: 'com.scichart.library', name: 'data', version: '3.0.0.4253', ext: 'aar')
implementation (group: 'com.scichart.library', name: 'drawing', version: '3.0.0.4253', ext: 'aar')
implementation (group: 'com.scichart.library', name: 'charting3d', version: '3.0.0.4253', ext: 'aar')
implementation (group: 'com.scichart.library', name: 'charting', version: '3.0.0.4253', ext: 'aar')
implementation (group: 'com.scichart.library', name: 'extensions', version: '3.0.0.4253', ext: 'aar')
implementation (group: 'com.scichart.library', name: 'extensions3d', version: '3.0.0.4253', ext: 'aar')
} |
The screenshot below shows where the file can be found in the Project window in AndroidStudio:
Using Downloaded SciChart libs
In the example below we use the download approach.
- First download SciChart Android v3 from https://www.scichart.com/downloads/ and then unzip it.
- Copy the Lib folder into the same folder where you save your Android projects. In other words put it in a folder such that ../../Lib will be found from app folder of your Android app.
- Open the "build.gradle" file for the project and declare a new repository in the "repositories" node inside the "allprojects" node, pointing to the location of SciChart Android libraries:
Copy Code
allprojects { repositories { jcenter() // Set up a repository which looks for dependencies in the "libs" folder flatDir{dirs 'libs'} } }
- Open the "build.gradle" file for a module which SciChart is intended to be used within. Add SciChart Android libraries as module dependencies:
Copy Code
dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation 'androidx.appcompat:appcompat:1.0.2' implementation 'androidx.constraintlayout:constraintlayout:1.1.3' implementation 'com.google.android.material:material:1.0.0' testImplementation 'junit:junit:4.12' androidTestImplementation 'androidx.test:runner:1.2.0' androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' // Declare SciChart libraries as module dependencies implementation 'com.scichart:charting:+@aar' implementation 'com.scichart:charting3d:+@aar' implementation 'com.scichart:core:+@aar' implementation 'com.scichart:drawing:+@aar' implementation 'com.scichart:data:+@aar' implementation 'com.scichart:extensions:+@aar' implementation 'com.scichart:extensions3d:+@aar' }
The screenshot below shows where the file can be found in the Project window in AndroidStudio:
Building the Project
At this point the solution should build and run, however we now need to add functionality
Referencing Javadocs in Project
Optionally. you can reference Javadocs in your project but you need to add them manually into your project. To do this you need to open Project tab and switch from Android to Project pane:
After you switch to Project pane you need to find core, data, drawing and charting libraries in External Libraries. After you find them you need to add for each appropriate javadoc file. To do this you need to find library in library, click right mouse button and select Library Properties... in context menu:
After that you need to locate and add appropriate javadoc file for this library. To do this you need to click on '+' sign. You can find javadoc files in \Libs\Docs folder:
After javadocs were added click OK button to close the window. Then you need to repeat the steps above for other SciChart libraries(core, data, drawing and charting). After that you should be able to see documentation for SciChart classes in your project:
A Note on Licensing SciChart.
The SciChart Android control comes with an inbuilt fully-functional 30-day trial. You will need to apply a trial license to the applications that you build, including the tutorial.
A license key can be applied following the instructions at www.scichart.com/licensing-scichart-android.