领域问题,根本没有改变代码。以前工作正常,今天给了我这个错误。我不明白这里发生了什么。 Android 4.4。在Android 6.0上没有错误
崩溃的部分代码
queryDestination = realm.where(Destination.class);
for (int i = 0; i < queryDestination.findAll().size(); i++) {
for (int j = 0; j < chosenIds.size(); j++) {
if (queryDestination.findAll().get(i).getId().equals(chosenIds.get(j))) {
setLabelsAndPacketsCollated(i);
generalInvoiceIdsList.remove(queryDestination.findAll().get(i).getDestinationListId());
listAdapter.notifyDataSetChanged();
int k = i;
realm.executeTransaction(realm -> {
queryDestination.findAll().get(k).deleteFromRealm();
if (!realm.where(Example.class).findAll().isEmpty())
realm.where(Example.class).findAll().get(k).deleteFromRealm(); //17.02.17
});
}
}
}
堆栈跟踪:
java.lang.ArrayIndexOutOfBoundsException: Out of range in /Users/cm/Realm/realm-java/realm/realm-library/src/main/cpp/io_realm_internal_Collection.cpp line 133(requested: 1 valid: 1)
at io.realm.internal.Collection.nativeGetRow(Native Method)
at io.realm.internal.Collection.getUncheckedRow(Collection.java:386)
at io.realm.OrderedRealmCollectionImpl.get(OrderedRealmCollectionImpl.java:106)
at io.realm.RealmResults.get(RealmResults.java:53)
at ru.startandroid.retrofit.ui.CollateFragment.lambda$onButtonCollateClick$3(CollateFragment.java:231)
at ru.startandroid.retrofit.ui.CollateFragment$$Lambda$6.execute(Unknown Source)
at io.realm.Realm.executeTransaction(Realm.java:1325)
at ru.startandroid.retrofit.ui.CollateFragment.onButtonCollateClick(CollateFragment.java:228)
at ru.startandroid.retrofit.ui.CollateFragment.lambda$onCreateView$0(CollateFragment.java:177)
at ru.startandroid.retrofit.ui.CollateFragment$$Lambda$1.onClick(Unknown Source)
at android.view.View.performClick(View.java:4881)
at android.view.View$PerformClick.run(View.java:19592)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:146)
at android.app.ActivityThread.main(ActivityThread.java:5756)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1291)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1107)
at dalvik.system.NativeStart.main(Native Method)