It may be a red herring, but my app is full of UI-less task fragments to perform most network operations and work around the activity lifecycle. An example of this type of architecture is described here. https://stackoverflow.com/a/12303649/2662474
On new Google Pixel and Nexus phones running Oreo 8.0, the app has started crashing on resume of many different activities in a way that is very difficult to debug and seems like a low level Android bug that was introduced. It is not happening on any previous OS versions.
Fatal Exception: java.lang.RuntimeException: Unable to resume activity {com.mycompany.shop/com.mycompany.shop.activity.MainNavActivity}: java.lang.IndexOutOfBoundsException: Index: 3, Size: 3
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3645)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3685)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1643)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6541)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
Caused by java.lang.IndexOutOfBoundsException: Index: 3, Size: 3
at java.util.ArrayList.get(ArrayList.java:437)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1610)
at android.app.FragmentManagerImpl.dispatchMoveToState(FragmentManager.java:3035)
at android.app.FragmentManagerImpl.dispatchResume(FragmentManager.java:3001)
at android.app.FragmentController.dispatchResume(FragmentController.java:200)
at android.app.Activity.performResume(Activity.java:7100)
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3620)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3685)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1643)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6541)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
Please help!
Your error is occurring in the method moveToState() of the nested class FragmentManagerImpl in FragmentManager. The specific code that is causing the erorr is Fragment f = mAdded.get(i) in the following lines:
final int numAdded = mAdded.size();
for (int i = 0; i < numAdded; i++) {
Fragment f = mAdded.get(i); // [causing the error]
moveFragmentToExpectedState(f);
if (f.mLoaderManager != null) {
loadersRunning |= f.mLoaderManager.hasRunningLoaders();
}
}
mAdded is a list of added fragment and is defined as:
ArrayList<Fragment> mAdded;
When the error occurs, i == 3 and the size of the mAdded Arraylist is something less than that. (Error line: "java.lang.IndexOutOfBoundsException: Index: 3, Size: 3") For this to occur, a fragment must have been removed from mAdded somewhere within this for-loop, specifically somewhere in the call chain starting with moveFragmentToExpectedState().
You mention that your app is "work[ing] around the activity lifecycle." Maybe you are getting a fragment into an unexpected state according the Oreo 8.0. I suggest that you put your app into the debugger and set a breakpoint in this for loop. You can then try to track down where the Arraylist mAdded is being changed. That should at least point you in the right direction for the solution.
btw, the source code for API 26 has been released. It can help you in debugging.
Update: From looking at the source, that area of FragmentManger in API 26 has received substantial work from the version in API 25. You may want to take azizbekian's suggestion and move to android.support.v4.app.Fragment. The support version seems to be more in line with API 25 than API 26. This could be a stop-gap measure until you can figure out the root cause.
Regarding your current implementation, I would look for anything that would remove or detach a fragment during the onResume() processing, especially if it is done off the UI thread and maybe in a non thread-safe manner. Look for anything that invoke, directly or indirectly, removeFragment() or detachFragment() of FragmentManager since these seem to be the only places where fragments are removed from mAdded.
Did you try this?: Nesting fragments inside a viewpager fragment throws IndexOutOfBoundsException
You may using getSupportFragmentManager() to call remove().
So, change getSupportFragmentManager() to YourFragment.this.getFragmentManager()
Linked answer said:
Change
getActivity().getSupportFragmentManager().beginTransaction().remove(instance).commit();
to
ThisFragment.this.getFragmentManager().beginTransaction().remove(instance).commit();
Related
I'm getting this warning as the first line from my app in logcat, and I have no idea what it refers to and how I should go about fixing it. Google doesn't offer much info on this (in fact, none at all). Please advise. What kind of flags might this be about? Is there a way to find out what the specified bit might refer to (or, perhaps, has been referring to on older Android versions but has become invalid in Android 10)? There is no such line in the log on Android 9 or earlier versions.
I bring a stone to the building. I retrace the code for the error message. It is at line 345 in the C ++ file dalvik_system_ZygoteHooks.cc
At a minimum, if (runtime_flags! = 0) then the error message will be printed. 0x8000 also corresponds to the USE_APP_IMAGE_STARTUP_CACHE flag (see line 157). The test on the USE_APP_IMAGE_STARTUP_CACHE flag is done on line 340. Normally, runtime_flags should no longer have a raised bit for USE_APP_IMAGE_STARTUP_CACHE but this does not seem to be the case since the error is printed.
But in the end, the error does not seem to have an impact on the application.
I searched and I have some suggestion to you.
First of all take a look at this links:
hexadecimal-0x8000
difference between constants 32768 and 0x8000
Now this links may be can help you :
Android Fragment no view found for ID
FLAG_ACTIVITY_CLEAR_TOP
addFlags(0x8000)
and last thing is:
Uninstall App from emulator and Run project Again.
First Edit:
I Searched again and i think we are close to answer, so please check this links and say what do you think? are they Irrelevant? or we are on the right way.
...
AConfiguration
org.robolectric.res.android
Class AConfiguration
ACONFIGURATION_SCREEN_ROUND
public static final int ACONFIGURATION_SCREEN_ROUND
...
\sdk\ndk-bundle\sysroot\usr\include\android
configuration.h
* Bit mask for
* layout direction
* configuration.
ACONFIGURATION_LAYOUTDIR = 0x4000,
ACONFIGURATION_SCREEN_ROUND = 0x8000
...
https://developer.android.com/ndk/reference/group/configuration
android_ndk_sys
Constant : ACONFIGURATION_SCREEN_ROUND
->
Constant android_ndk_sys::ACONFIGURATION_SCREEN_ROUND
pub const ACONFIGURATION_SCREEN_ROUND: _bindgen_ty_3
->
Type Definition android_ndk_sys::_bindgen_ty_3
type _bindgen_ty_3 = u32;
...
ACAMERA_VENDOR = 0x8000
ACAMERA_VENDOR = 0x8000
ACAMERA_DISTORTION_CORRECTION << 16,
ACAMERA_HEIC_START = ACAMERA_HEIC << 16,
ACAMERA_HEIC_INFO_START = ACAMERA_HEIC_INFO << 16,
ACAMERA_VENDOR_START = ACAMERA_VENDOR << 16
In my case at least happens because The fragment tried to update the view (or something like this) when a different activity was already running so just
#Override
public void onStop() {
super.onStop();
getActivity().finish();
}
inside the fragment solved this error
Not sure if this will help anyone else, but I found I only get this peculiar error only on an Emulator!
so maybe a bug with Emulator 🤷♂️ .
Anyway, I suggest testing on a real device as this is the second time this sort of issues wasting so much of my time to investigate, I won't trust the Emulators anymore especially when they do not give a clear error log.
It's a very strange Xiaomi device's OS exception. Even if I do have logs available from Fabric, the stack trace doesn't refer any of my code.
A crash details are below as reported in crashalytics(Fabric),
21K crashes
All crashes on Xiaomi devices
Crashes on Android OS version 6, 7 and 8
Crash Log:
# OS Version: 8.1.0
# Device: Redmi Note 5 pro
# RAM Free: 30.1%
# Disk Free: 74.2%
#0. Crashed: main
at android.widget.Editor.touchPositionIsInSelection(Editor.java:1084)
at android.widget.Editor.performLongClick(Editor.java:1205)
at android.widget.TextView.performLongClick(TextView.java:10908)
at android.view.View.performLongClick(View.java:6360)
at android.view.View$CheckForLongPress.run(View.java:24768)
at android.os.Handler.handleCallback(Handler.java:790)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:171)
at android.app.ActivityThread.main(ActivityThread.java:6606)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:518)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:823)
--
Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'int android.widget.Editor$SelectionModifierCursorController.getMinTouchOffset()' on a null object reference
at android.widget.Editor.touchPositionIsInSelection(Editor.java:1084)
at android.widget.Editor.performLongClick(Editor.java:1205)
at android.widget.TextView.performLongClick(TextView.java:10908)
at android.view.View.performLongClick(View.java:6360)
at android.view.View$CheckForLongPress.run(View.java:24768)
at android.os.Handler.handleCallback(Handler.java:790)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:171)
at android.app.ActivityThread.main(ActivityThread.java:6606)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:518)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:823)
#0. Crashed: main
at android.widget.Editor.touchPositionIsInSelection(Editor.java:1084)
at android.widget.Editor.performLongClick(Editor.java:1205)
at android.widget.TextView.performLongClick(TextView.java:10908)
at android.view.View.performLongClick(View.java:6360)
at android.view.View$CheckForLongPress.run(View.java:24768)
at android.os.Handler.handleCallback(Handler.java:790)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:171)
at android.app.ActivityThread.main(ActivityThread.java:6606)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:518)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:823)
Similar Reference:
https://issuetracker.google.com/issues/37127697
java.lang.NullPointerException with Nougat
Also asked on Xiaomi official forum http://en.miui.com/forum.php?mod=viewthread&tid=4595164
Please do provide any working solution as soon as possible. As users must not be happy with these crashes.
Thanks in advance.
1) First of all, only if required, set one of these.
textView.setMovementMethod(LinkMovementMethod.getInstance());
or
setAutoLinkMask(Linkify.ALL);
or
Linkify.addLinks(textView, Linkify.PHONE_NUMBERS | Linkify.EMAIL_ADDRESSES | Linkify.MAP_ADDRESSES);
2) Secondly, set a long click listener for TextView and it must return true.
textView.setOnLongClickListener(new View.OnLongClickListener() {
#Override
public boolean onLongClick(View v) {
// do soemthing if needed
return true;
}
});
There is some internal crashing issue on Xiaomi devices. If you override setOnLongClickListener(reference) first and then follow the step one, it will use internal implementation and that will keep on crashing. So it is import to follow above steps in sequence.
I am open to other solutions, however by following this approach I don't see crash reports anymore.
Do you have a custom TextView in your app? Is it perhaps resizeable or has additional functionality?
Xiaomi's Android skin is likely interfering with that, and causing crashes. I suggest trying to long click all TextViews in your app.
It happen when user doing long click on all selected text.
Just define longClickListener:
edit_text.setOnLongClickListener {
doSomething()
true
}
and later you can remove it
edit_text.setOnLongClickListener(null)
For me this crash happened when TextView contained link and setAutoLinkMask(Linkify.ALL); was called for the view. In this case Android handles all clicks (including long clicks) by this view. On devices of other brands link was opened after long click, but on Xiaomi device crash happened. It seems, that they have a bit different logic of handling onTouchEvent inside the TextView. I've played a bit around and found, that setting android:textIsSelectable="false" for the TextView in layout file solves the problem.
I know, that it's not scalable solution, but for my case it was perfect, so I stopped investigating further. Maybe it will give a hint to someone else.
I get this error on crashlytics panel:
Fatal Exception: java.lang.NoSuchMethodError
android.support.v4.app.FragmentActivity.isChangingConfigurations
com.hannesdorfmann.mosby.mvp.MvpFragment.shouldInstanceBeRetained (MvpFragment.java:91)
com.hannesdorfmann.mosby.mvp.delegate.MvpInternalDelegate.detachView (MvpInternalDelegate.java:70)
com.hannesdorfmann.mosby.mvp.delegate.FragmentMvpDelegateImpl.onDestroyView (FragmentMvpDelegateImpl.java:73)
com.hannesdorfmann.mosby.mvp.MvpFragment.onDestroyView (MvpFragment.java:106)
com.hannesdorfmann.mosby.mvp.MvpFragment.shouldInstanceBeRetained (MvpFragment.java:91)
I override manifest for library to use it with api level 10 and I already test it on android 2.3.3 and it was working ok! but now I see this crash on crashlytics. Hi I can fix this for my version? is crash related to api 10? because the method is for support v4 library so I can't understand why this occurred.
yes the method isChangingConfigurations() has been introduced with API 11:
https://developer.android.com/reference/android/app/Activity.html#isChangingConfigurations()
as part of theandroid.app.Activity plattform class (and not as part android.support.v4.app.FragmentActivity, but FragmentActivity extends Activity).
Hence, this won't work on API < 11.
You could implement isChangingConfigurations() in your Activity and either call
super.isChangingConfigurations() if API >=11 or implement your own thing if (API < 11). You may want to take a look at Activities source code, but I'm not sure how this could be back ported. https://github.com/android/platform_frameworks_base/blob/master/core/java/android/app/Activity.java#L5152
You could try to just return false if API < 11 . That would mean that the View's state (and Presenter) will not survive screen orientation changes. DISCLAIMER: That might also cause some other unwanted side effects I'm not aware of right now and could break with any future release of Mosby or support library.
I'm seeing markers jump around on the map on Android Maps API v2 even when nothing is happening in the app.
Here's a video of the behavior:
https://youtu.be/cOUGD0T5Ojs
What I expect
Markers should remain stationary at their originally added lat/long.
What steps will reproduce the problem?
Build, install, and run the v2.0.6 tag of OneBusAway:
a. git clone https://github.com/OneBusAway/onebusaway-android.git
b. git checkout v2.0.6
c. gradlew installObaGoogleDebug
d. adb shell am start -n com.joulespersecond.seattlebusbot/org.onebusaway.android.ui.HomeActivity
Browse to any supported city (e.g., Seattle or Tampa), and watch the green bus stop markers jump around on the map
I should add that I can't always reproduce this. It seems like everything works fine for a time, but then when the markers start jumping around they don't stop.
Marker Implementation Details
The code that loads the icons used for the 9 marker types (8 directions + no direction) is here:
https://github.com/OneBusAway/onebusaway-android/blob/master/onebusaway-android/src/google/java/org/onebusaway/android/map/googlemapsv2/StopOverlay.java#L175
I'm using this drawable:
https://github.com/OneBusAway/onebusaway-android/blob/master/onebusaway-android/src/main/res/drawable/map_stop_icon.xml
...which is a number of shapes - this creates the main green circle with the white outline and the drop shadoes. Then, I'm drawing the direction arrow on top of this drawable for each of the 8 directions - code for drawing directions is here:
https://github.com/OneBusAway/onebusaway-android/blob/master/onebusaway-android/src/google/java/org/onebusaway/android/map/googlemapsv2/StopOverlay.java#L208
In the code to load the icons, I'm caching the BitmapDescriptor returned from BitmapDescriptorFactory.fromBitmap() for each of the 9 icon types on first load, so this isn't done each time a marker is put on the map.
I also saw the app crash to "Unfortunately, OneBusAway has stopped." and saw this exception in Logcat after letting the app sit on the map screen for a few minutes:
08-10 16:40:02.422 15843-15929/com.joulespersecond.seattlebusbot E/AndroidRuntime﹕ FATAL EXCEPTION: GLThread 8614
Process: com.joulespersecond.seattlebusbot, PID: 15843
java.lang.IllegalArgumentException: Comparison method violates its general contract!
at java.util.ComparableTimSort.mergeHi(ComparableTimSort.java:831)
at java.util.ComparableTimSort.mergeAt(ComparableTimSort.java:449)
at java.util.ComparableTimSort.mergeCollapse(ComparableTimSort.java:372)
at java.util.ComparableTimSort.sort(ComparableTimSort.java:178)
at java.util.ComparableTimSort.sort(ComparableTimSort.java:142)
at java.util.Arrays.sort(Arrays.java:1957)
at java.util.Collections.sort(Collections.java:1864)
at com.google.maps.api.android.lib6.gmm6.n.bl.a(Unknown Source)
at com.google.maps.api.android.lib6.gmm6.n.l.a(Unknown Source)
at com.google.maps.api.android.lib6.gmm6.n.l.b(Unknown Source)
at com.google.maps.api.android.lib6.gmm6.n.cv.f(Unknown Source)
at com.google.maps.api.android.lib6.gmm6.n.cv.run(Unknown Source)
I've seen this on an LG G4 and Nexus 6. More details on LG device is below.
LG G4 LS991 with Android 5.1 (LS991ZV4)
Google Play Services client library version = compile 'com.google.android.gms:play-services-maps:7.5.0' and compile 'com.google.android.gms:play-services-maps:7.8.0'
Google Play Services version on the device - Google Play Services 7.8.99 (2134222-440)
Android SDK Version: compileSdkVersion 21 buildToolsVersion "21.1.2"
This issue hasn't always existed, which makes me believe it was introduced during an update to Android Google Play Services/Maps at some point.
I've opened an issue for this on gmaps-api-issues as well, but no response as of this post:
https://code.google.com/p/gmaps-api-issues/issues/detail?id=8455
Has anyone else seen this? Any ideas for fixes?
EDIT
I should add that I can't always reproduce this. It seems like everything works fine for a time, but then when the markers start jumping around they don't stop.
EDIT 2
I've created a smaller demo project here on Github that uses the same marker implementation:
https://github.com/barbeau/maps-demo
However, I haven't yet seen the same problem there.
EDIT 3
I've changed to caching Bitmaps instead of BitmapDescriptors in https://github.com/OneBusAway/onebusaway-android/commit/01b35e9a07313a627843819d66b3f6a9bb7e848f.
We'll see if this fixes the problem. It's intermittent, so the only way I'll know is if I don't see the problem again for some period of time.
EDIT 4
I'm still seeing the problem, so looks like switching from caching BitmapDescriptors to Bitmaps, and changing to using ContextCompat.getDrawable(), didn't have any effect.
EDIT 5
Not sure if this is related, but I'm also seeing the following output in Logcat when this happens:
09-01 10:46:00.339 9278-9278/? E/libEGL﹕ validate_display:255 error 3008 (EGL_BAD_DISPLAY)
09-01 10:46:00.339 9278-9278/? E/libEGL﹕ validate_display:255 error 3008 (EGL_BAD_DISPLAY)
and
9-01 10:46:00.069 9278-9278/? W/ResourcesManager﹕ Asset path '/system/framework/com.google.android.maps.jar' does not exist or contains no resources.
and
09-01 10:46:16.019 1137-4311/? W/ActivityManager﹕ Scheduling restart of crashed service com.google.android.gms/.usagereporting.service.UsageReportingService in 1000ms
09-01 10:46:16.019 1137-4311/? W/ActivityManager﹕ Scheduling restart of crashed service com.google.android.gms/.icing.service.IndexService in 11000ms
and
09-01 10:48:38.609 5402-26676/? E/SQLiteDatabase﹕ Error inserting context_name=8 end_time=1441118918490 context_family=7 module_id=com.google.android.contextmanager.module.PowerConnectionModule version=1 sync_state_mod_time_millis=1441118918532 start_time=1441118643058 sync_state=0 context_id=9680c4f4-789a-4d86-acbf-43d2098e89b8 time_type=3 proto_blob=[B#28265a3
android.database.sqlite.SQLiteConstraintException: UNIQUE constraint failed: context.context_id (code 2067)
at android.database.sqlite.SQLiteConnection.nativeExecuteForLastInsertedRowId(Native Method)
at android.database.sqlite.SQLiteConnection.executeForLastInsertedRowId(SQLiteConnection.java:790)
at android.database.sqlite.SQLiteSession.executeForLastInsertedRowId(SQLiteSession.java:926)
at android.database.sqlite.SQLiteStatement.executeInsert(SQLiteStatement.java:86)
at android.database.sqlite.SQLiteDatabase.insertWithOnConflict(SQLiteDatabase.java:1581)
at android.database.sqlite.SQLiteDatabase.insert(SQLiteDatabase.java:1451)
at com.google.android.contextmanager.q.ak.a(SourceFile:405)
at com.google.android.contextmanager.q.ak.b(SourceFile:380)
at com.google.android.contextmanager.q.ak.a(SourceFile:346)
at com.google.android.contextmanager.q.ak.b(SourceFile:373)
at com.google.android.contextmanager.g.a.j.a(SourceFile:58)
at com.google.android.contextmanager.g.a.a.run(SourceFile:52)
at com.google.android.contextmanager.g.i.handleMessage(SourceFile:214)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.os.HandlerThread.run(HandlerThread.java:61)
EDIT 6
I haven't seen this issue lately, and I noticed that Google Play services on the LG G4 device was bumped to 8.1.15 (2250156-240). So, maybe it was fixed with an update of Google Play services? I'll report back again later.
EDIT 7
I've seen this again in 8.1.15 (2250156-240) and 8.1.18 (2272748-240), although it doesn't seem nearly as bad as it used to be (i.e., fewer markers jump around, and the jumping is less noticeable). It seems to be triggered mainly when resuming the app when its been in the background for a while. If I kill the app and then start it fresh, the problem disappears.
EDIT 8
I found a way to consistently reproduce this - see:
https://code.google.com/p/gmaps-api-issues/issues/detail?id=8455#c2
From above issue:
Build, install, and run the v2.0.6 tag of OneBusAway:
a. git clone https://github.com/OneBusAway/onebusaway-android.git
b. git checkout v2.0.6
c. gradlew installObaGoogleDebug
d. adb shell am start -n com.joulespersecond.seattlebusbot/org.onebusaway.android.ui.HomeActivity
Hold the device in a portrait orientation
If you're not physically located in Seattle or Tampa (or any of the supported regions), you'll need to go to "Settings->Your region" and manually set the region. After doing this, scroll the map to the region (or select "Take me there" when prompted).
Tap on a bus stop on the map
Tap on the 3 dots "more" button next to arrival time (or tap on arrival in list in sliding panel)
Tap on option "Show route on map"
After the route loads on the map, change the device orientation to landscape.
Watch the markers jump around after the map reloads
Full video capture on LG G4 that shows new steps to produce and issue:
https://youtu.be/oiBoMTPDVrU
I think this is definitely related to multiple instances of the SupportMapFragment existing simultaneously. In v2.0.6 I wasn't handling fragments correctly when the Activity was destroyed and recreated with a savedInstanceState (i.e., when the Activity was killed after being in background for a while, or on orientation change).
In v2.0.6, my code looked something like this:
public class HomeActivity ...{
BaseMapFragment mMapFragment;
...
private void showMap() {
FragmentManager fm = getSupportFragmentManager();
if (mMapFragment == null) {
mMapFragment = BaseMapFragment.newInstance();
fm.beginTransaction()
.add(R.id.main_fragment_container, mMapFragment)
.commit();
}
}
...
}
So, I was leaking an instance of BaseMapFragment (which extends SupportMapFragment) in those cases - an instance already existed in the FragmentManager, but I didn't have a local reference to it. I actually noticed this issue when Action Bar menu items were being duplicated for another fragment I was handling similarly.
I changed the code to look something like this, which first checks to see if the FragmentManager has an existing BaseMapFragment:
public class HomeActivity ...{
BaseMapFragment mMapFragment;
...
private void showMap() {
FragmentManager fm = getSupportFragmentManager();
// First check to see if an instance of BaseMapFragment already exists
mMapFragment = (BaseMapFragment) fm.findFragmentByTag(BaseMapFragment.TAG);
if (mMapFragment == null) {
mMapFragment = BaseMapFragment.newInstance();
fm.beginTransaction()
.add(R.id.main_fragment_container, mMapFragment, BaseMapFragment.TAG)
.commit();
}
}
...
}
The UI flow has changed in the master branch (I'm no longer opening a new Activity to view the route), so I can't directly test there if the problem is still reproducible after this code change.
However, I created this branch, which is branched from master but changed to have the same UI flow as v2.0.6, and includes the above fix for the fragment leak:
https://github.com/CUTR-at-USF/onebusaway-android/tree/jumpingMarkersTest
From some quick testing with this branch, it seems that handling the fragments correctly on orientation change (i.e., not leaking the fragment) may have fixed the jumping markers issue - at least using the steps above it no longer reproduces on a LG G4 with Android 5.1.
I got into this crash log when I'm on a fragment and call popBackStackImmediate() to return to previous one, I'm wondering why Android code saves current fragment before removing it. Will it allow 'forward' later (similar to browser behaviour)? or any other reason?
android.view.View.saveHierarchyState(View.java:12679)
Thanks
java.lang.IndexOutOfBoundsException: setSpan (0 ... -1) has end before start
at android.text.SpannableStringInternal.checkRange(SpannableStringInternal.java:341)
at android.text.SpannableStringInternal.setSpan(SpannableStringInternal.java:77)
at android.text.SpannableString.setSpan(SpannableString.java:46)
at android.text.SpannableStringInternal.<init>(SpannableStringInternal.java:50)
at android.text.SpannableString.<init>(SpannableString.java:30)
at android.widget.TextView.onSaveInstanceState(TextView.java:3505)
at android.view.View.dispatchSaveInstanceState(View.java:12696)
at android.view.ViewGroup.dispatchSaveInstanceState(ViewGroup.java:2615)
at android.view.ViewGroup.dispatchSaveInstanceState(ViewGroup.java:2615)
at android.view.View.saveHierarchyState(View.java:12679)
at android.support.v4.app.FragmentManagerImpl.saveFragmentViewState(FragmentManager.java:1629)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1013)
at android.support.v4.app.FragmentManagerImpl.removeFragment(FragmentManager.java:1223)
at android.support.v4.app.BackStackRecord.popFromBackStack(BackStackRecord.java:901)
at android.support.v4.app.FragmentManagerImpl.popBackStackState(FragmentManager.java:1541)
at android.support.v4.app.FragmentManagerImpl.popBackStackImmediate(FragmentManager.java:502)