Import the shinobicharts Library

Android Studio

To use the shinobicharts library you’ll need to declare a dependency on it from your application. This section covers both the process of importing the library from a locally stored .aar file and importing the library from a private repository.

From a locally stored .aar file

Open up Android Studio and make sure you’ve unzipped the download bundle. This guide assumes that you have already created a project for your application within Android Studio.

  1. With your project open within Android Studio, click File > New > New Module…. In the Create New Module window that appears, in the lower panel click on Import .JAR or .AAR Package. With Import .JAR or .AAR Package highlighted, click Next.
  2. Click the ellipsis button (…) and browse to the directory in which you unzipped the download bundle. Locate the shinobicontrols-android-charts-<edition>-java-1.9.4-0.aar. Click Finish.
  3. You should now see a new module within your project which represents the imported shinobicharts Library. You must now include a reference to the library in your project’s dependencies.
  4. Click File > Project Structure…. In the Project Stucture window, on the left hand side click on your application module (usually called app). With this selected, click the Dependencies tab.
  5. Click the plus (+) symbol at the right side of the window and choose Module Dependency. From the drop down list select the entry for the new library module which you created in the previous steps and click OK.
  6. Click OK again to close the Project Structure window. This should automatically trigger a Gradle build of your project.
  7. You should now be able to reference the shinobicharts library within your application project.

If you are using the SupportChartFragment you will also need to add a dependency on the Android Support Library from your app. Back in the Project Structure window:

  1. Select your app module in the list of modules on the left hand side.
  2. Click the plus (+) symbol again but this time choose Library Dependency.
  3. Select the entry that says support-v4 (com.android.support:support-v4:25.2.0) and click OK.

From a private repository

This section of the guide assumes that you have already created a project for your application within Android Studio. It also assumes that you have declared the repository (where the shinobicharts library will reside) within your project’s master gradle.build file.

When installing/deploying the .aar file to a Maven repository you can use the provided pom.xml file (also in the ‘lib’ folder of the download bundle). This will declare a dependency on the Android Support Library, which the SupportChartFragment makes use of. It will also set the following:

  • groupId: com.shinobicontrols.android.charts
  • artifactId: shinobicontrols-android-charts-<edition>-java
  • version: 1.9.4-0
  • packaging: aar

To add a dependency to your application on the shinobicharts library, which resides in your repository:

  1. Open the build.gradle file of your application’s module
  2. In the dependencies section, add a dependency to shinobicharts for the compile configuration using the groupId, artifactId and version that you set when installing the .aar file. If you used the provided pom.xml file you would do the following:

    dependencies {
        compile 'com.shinobicontrols.android.charts:shinobicontrols-android-charts-<edition>-java:1.9.4-0'
    }
    
  3. Sync your project with the Gradle files by clicking on the Sync Now link or on the Sync Project with Gradle Files button

  4. You should now be able to reference the shinobicharts library within your application project.

Important: if you did not use the provided pom.xml file when installing the shinobicharts library into your repository, you will also need to add a dependency on the Android Support Library to your application's build.gradle file:

dependencies {
    compile 'com.shinobicontrols.android.charts:shinobicontrols-android-charts-<edition>-java:1.9.4-0'
    compile 'com.android.support:support-v4:25.2.0'
}

Hardware Acceleration

In order to display a chart, some devices need to be explicitly told that the application requires hardware acceleration. To do this simple add android:hardwareAccelerated="true" to the application element of your app’s AndroidManifest.xml file.