Open ashivakarthik opened 5 years ago
@ashivakarthik All you need to make the AnyChart Android work is right here: https://github.com/AnyChart/AnyChart-Android/tree/master. This is the actual build, please use it.
wait @imaximova ... i don't get it ... u mean we need to build it? or what?
@ashivakarthik There's no need in building the repo. All you need is to add the repository to the project build.gradle and add the dependency to the module build.gradle. For details, check the Getting Started article.
Doesnt work.
@diaconori Please, can you provide more details about the issue? We will check it.
@Shestac92, I'll list it as following:
Build.Gradle (:app):
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.XXXXXX.XXXX"
minSdkVersion 19
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'com.google.android.material:material:1.1.0'
implementation 'com.github.AnyChart:AnyChart-Android:1.1.2'
implementation 'com.android.support:multidex:1.0.3'
}
Build.Gradle (project):
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.6.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
maven { url 'https://jitpack.io' }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
fragment_home.xml:
<?xml version="1.0" encoding="utf-8"?> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".home.HomeFragment">
<com.anychart.AnyChartView android:id="@+id/any_chart_view"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
MainActivity.java:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
AnyChartView chart = findViewById(R.id.any_chart_view);
Pie pie = AnyChart.pie();
List<DataEntry> data = new ArrayList<>();
data.add(new ValueDataEntry("John", 10000));
data.add(new ValueDataEntry("Jake", 12000));
data.add(new ValueDataEntry("Peter", 18000));
chart.setChart(pie);
BottomNavigationView bottomNavigationView = findViewById(R.id.bottom_navigation);
bottomNavigationView.setOnNavigationItemSelectedListener(navListener);
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new HomeFragment()).commit();
}
Exception:
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'com.anychart.AnyChartView$JsListener com.anychart.AnyChartView.getJsListener()' on a null object reference
at com.anychart.APIlib.addJSLine(APIlib.java:27)
at com.anychart.charts.Pie.
NONE of the StackOverflow answers have a solution to this fix. It throws the NullPointerException at:
Pie pie = AnyChart.pie();
A similar issue I am facing... I had added their dependency but anychart is not at all invoking in the xml and in the main activity. @diaconori you got the answer???
I can't find aar file in this also
https://github.com/AnyChart/AnyChart-Android/raw/master/builds/anychart-library.aar