I use the Realm.io library to transfer data to the MPAndroidChart graph. I add to the database as follows:

protected void writeToDB() { Realm realm = Realm.getInstance(this); realm.beginTransaction(); float f = 24; int i = 5; String s ="1100";; RealmDemoData d = new RealmDemoData(f, i, s); realm.copyToRealm(d); realm.commitTransaction(); } 

Everything is added, everything is fine, trying to get the data:

 RealmResults<RealmDemoData> result = mRealm.allObjects(RealmDemoData.class); RealmLineDataSet<RealmDemoData> set = new RealmLineDataSet<RealmDemoData>(result, "value", "xIndex"); 

And errors immediately take off, and only when I use RealmLineDataSet .
The error itself:

 02-06 23:21:13.676 6597-6597/com.akefa.smarthome002 E/AndroidRuntime: FATAL EXCEPTION: main java.lang.NoSuchMethodError: io.realm.RealmResults.sort at com.github.mikephil.charting.data.realm.base.RealmBaseDataSet.<init>(RealmBaseDataSet.java:71) at com.github.mikephil.charting.data.realm.base.RealmBarLineScatterCandleBubbleDataSet.<init>(RealmBarLineScatterCandleBubbleDataSet.java:32) at com.github.mikephil.charting.data.realm.base.RealmLineScatterCandleRadarDataSet.<init>(RealmLineScatterCandleRadarDataSet.java:39) at com.github.mikephil.charting.data.realm.base.RealmLineRadarDataSet.<init>(RealmLineRadarDataSet.java:43) at com.github.mikephil.charting.data.realm.implementation.RealmLineDataSet.<init>(RealmLineDataSet.java:95) at com.akefa.smarthome002.weather.MultiLineChartActivity.setData(MultiLineChartActivity.java:52) at com.akefa.smarthome002.weather.MultiLineChartActivity.onResume(MultiLineChartActivity.java:45) at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1154) at android.app.Activity.performResume(Activity.java:4539) at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2557) at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2595) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2109) at android.app.ActivityThread.access$600(ActivityThread.java:132) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1157) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:137) at android.app.ActivityThread.main(ActivityThread.java:4575) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:511) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:556) at dalvik.system.NativeStart.main(Native Method) 
  • RealmDemoData your RealmDemoData class RealmDemoData RealmObject and RealmLineDataSet class RealmLineDataSet exist? You get the error that the class or method you are trying to call does not exist. - pavlofff

1 answer 1

Yes, that's right, the error was in the RealmLineDataSet class, the plug-in jar did not correctly indicate the placement of RealmDinamicObject, plugged in as a module and the problem was solved, thanks!