Skip to content
This repository was archived by the owner on Aug 8, 2023. It is now read-only.
This repository was archived by the owner on Aug 8, 2023. It is now read-only.

MapFragment and SupportMapFragment not using account manager #5075

Closed

Description

@cammace

We have deprecated MapboxMapOptions.accessToken() and you should be able to remove it and MapboxAccountManager provide the token. This isn't the case, If you remove options.accessToken() from the testapp fragment activity it will crash.

cc: @bleege

Activity

  1. added
    Android
    on May 19, 2016
  2. added this to the android-v4.1.0 milestone on May 19, 2016
  3. tobrun commented on May 20, 2016

    @tobrun
    Member

    Capturing from chat with @cammace that @bleege is planning to pick this up, if not LMK.

  4. tobrun commented on May 20, 2016

    @tobrun
    Member

    Adding a note here that we can remove StyleInitializer as a result, this was introduced to be able to handle the case where the user provided a style in xml and the accesstoken in code (this resulted in trying to load the style without an accesstoken). Now we always have a reference to that token so it may be deleted.

  5. self-assigned this
    on May 20, 2016
  6. bleege commented on May 24, 2016

    @bleege
    Contributor

    Picking this up now...

  7. bleege commented on May 24, 2016

    @bleege
    Contributor

    Discovered that this is going to be a little bigger lift than the previous conversions as it's possible to store the Access Token in the AppManifest for MapFragment and SupportMapFragment in addition to the usual programmatic style.

  8. tobrun commented on May 25, 2016

    @tobrun
    Member

    @bleege while clicking through MapboxMapOptions just now.
    I noticed that deprecation needs to be updated. I missed this in #5065

  9. bleege commented on May 25, 2016

    @bleege
    Contributor

    @tobrun Yep, deprecation is part of the conversion to use MapboxAccountManager. I'll make sure it gets in there. 👍

  10. bleege commented on May 25, 2016

    @bleege
    Contributor

    Ok, documenting what the final state should look like:

    1. MapFragmentActivity should have MapboxMapOptions.accessToken() removed.
    2. SupportMapFragmentActivity should have MapboxMapOptions.accessToken() removed.
    3. MapFragment.onCreateView() should be refactored to check for MapboxAccountManager.getInstance() and use access token then first and only if it exists while relying on the existing MapboxMapOptions.accessToken() and AppManifest getToken() if it does not exist.
    4. SupportMapFragment.onCreateView() should be refactored to check for MapboxAccountManager.getInstance() and use access token then first and only if it exists while relying on the existing MapboxMapOptions.accessToken() and AppManifest getToken() if it does not exist.
    5. Add Deprecation tags to:
      1. MapboxFragment.getToken()
      2. SupportMapboxFragment.getToken()
      3. MapboxConstants.KEY_META_DATA_MANIFEST

    I think this should do it, but will find out after building and feedback from others.

  11. added 3 commits that reference this issue on May 25, 2016
  12. bleege commented on May 25, 2016

    @bleege
    Contributor

    I've noticed that when testing with both the access token set and not set in MapFragmentActivity the activity crashes when I try to load it in the TestApp. I've stepped through the code base and discovered that it makes it through MapFragment.createView() and discovers the access token fine both ways. The stack trace (see below) seems to indicate that it's an issue with Instant Run.

    I'm going to verify that it was still good in the TestApp from master before my 3 changes on the branch to make sure that the debug process is starting from a legit spot.

    05-25 16:53:01.004 15765-15765/com.mapbox.mapboxsdk.testapp I/Timeline: Timeline: Activity_launch_request id:com.mapbox.mapboxsdk.testapp time:164829668
    05-25 16:53:01.104 15765-15765/com.mapbox.mapboxsdk.testapp D/Activity: performCreate Call secproduct feature valuefalse
    05-25 16:53:01.104 15765-15765/com.mapbox.mapboxsdk.testapp D/Activity: performCreate Call debug elastic valuetrue
    05-25 16:53:01.264 15765-15765/com.mapbox.mapboxsdk.testapp D/AndroidRuntime: Shutting down VM
    05-25 16:53:01.274 15765-15765/com.mapbox.mapboxsdk.testapp E/AndroidRuntime: FATAL EXCEPTION: main
                                                                                  Process: com.mapbox.mapboxsdk.testapp, PID: 15765
                                                                                  java.lang.UnsatisfiedLinkError: com.android.tools.fd.runtime.IncrementalClassLoader$DelegateClassLoader[DexPathList[[dex file "/data/data/com.mapbox.mapboxsdk.testapp/files/instant-run/dex/slice-support-annotations-23.4.0_04a2370ef5dcf6f091064d539cf534927f05a927-classes.dex", dex file "/data/data/com.mapbox.mapboxsdk.testapp/files/instant-run/dex/slice-slice_9-classes.dex", dex file "/data/data/com.mapbox.mapboxsdk.testapp/files/instant-run/dex/slice-slice_8-classes.dex", dex file "/data/data/com.mapbox.mapboxsdk.testapp/files/instant-run/dex/slice-slice_7-classes.dex", dex file "/data/data/com.mapbox.mapboxsdk.testapp/files/instant-run/dex/slice-slice_6-classes.dex", dex file "/data/data/com.mapbox.mapboxsdk.testapp/files/instant-run/dex/slice-slice_5-classes.dex", dex file "/data/data/com.mapbox.mapboxsdk.testapp/files/instant-run/dex/slice-slice_4-classes.dex", dex file "/data/data/com.mapbox.mapboxsdk.testapp/files/instant-run/dex/slice-slice_3-classes.dex", dex file "/data/data/com.mapbox.mapboxsdk.testapp/files/instant-run/dex/slice-slice_2-classes.dex", dex file "/data/data/com.mapbox.mapboxsdk.testapp/files/instant-run/dex/slice-slice_1-classes.dex", dex file "/data/data/com.mapbox.mapboxsdk.testapp/files/instant-run/dex/slice-slice_0-classes.dex", dex file "/data/data/com.mapbox.mapboxsdk.testapp/files/instant-run/dex/slice-retrofit-2.0.0-beta2_7d8e7e73bafe6095b4a84cb4938d2da678f45eb4-classes.dex", dex file "/data/data/com.mapbox.mapboxsdk.testapp/files/instant-run/dex/slice-okio-1.8.0_c5baa29f5fae5888a8665cf3edb4917ce0358d25-classes.dex", dex file "/data/data/com.mapbox.mapboxsdk.testapp/files/instant-run/dex/slice-okhttp-3.3.0_e1d36ca3045ebd118d4d00bd9ef96f353ce5e5c9-classes.dex", dex file "/data/data/com.mapbox.mapboxsdk.testapp/files/instant-run/dex/slice-okhttp-2.5.0_5dd158fe04709a67bb93b4a34bf476815cf80107-classes.dex", dex file "/data/data/com.mapbox.mapboxsdk.testapp/files/instant-run/dex/slice-leakcanary-watcher-1.4-beta1_5536cd189f0723fd037323832ef68ccf576465ba-classes.dex", dex file "/data/data/com.mapbox.mapboxsdk.testapp/files/instant-run/dex/slice-leakcanary-analyzer-1.4-beta1_474ae61f11fd29b610bb4a3fef3d7eead108deb0-classes.dex", dex file "/data/data/com.mapbox.mapboxsdk.testapp/files/instant-run/dex/slice-internal_impl-23.4.0_cc799c0d9487896bd46471b0f6e6db8c99931918-classes.dex", dex file "/data/data/com.mapbox.mapboxsdk.testapp/files/instant-run/dex/slice-haha-2.0.2_b5ac781814e730a0a53b4367cb98b60b154c9c12-classes.dex", dex file "/data/data/com.mapbox.mapboxsdk.testapp/files/instant-run/dex/slice-guava-18.0_a86682c32428cb91caa67be07f25205caeb390f1-classes.dex", dex file "/data/data/com.mapbox.mapboxsdk.testapp/files/instant-run/dex/slice-gson-2.3.1_651b769da75570d6fe6fea4b54668b7c1b0fb88e-classes.dex", dex file "/data/data/com.mapbox.mapboxsdk.testapp/files/instant-run/dex/slice-converter-gson-2.0.0-beta2_b30b492565a0bc6149af8109e6247aaff6192e3b-classes.dex", dex file "/data/data/com.mapbox.mapboxsdk.testapp/files/instant-run/dex/slice-com.squareup.leakcanary-leakcanary-android-1.4-beta1_fc0ad17440db7f698ca34841d375276db7ee1ecc-classes.dex", dex file "/data/data/com.mapbox.mapboxsdk.testapp/files/instant-run/dex/slice-com.mapzen.android-lost-1.1.0_1681734e2f803ea170cef70ac97bc3a871b83d71-classes.dex", dex file "/data/data/com.mapbox.mapboxsdk.testapp/files/instant-run/dex/slice-com.mapbox.mapboxsdk-mapbox-android-geocoder-1.0.0_b8514593b8d16d99273d8ad0e651a812fbbe78a6-classes.dex", dex file "/data/data/com.mapbox.mapboxsdk.testapp/files/instant-run/dex/slice-com.mapbox.mapboxsdk-mapbox-android-directions-1.0.0_95e3e5412f1779d3534140fa00a0e5b54d957b9b-classes.dex", dex file "/data/data/com.mapbox.mapboxsdk.testapp/files/instant-run/dex/slice-com.android.support-support-vector-drawable-23.4.0_b1c8db43eab90b14ccc3301821d237b63a3ef419-classes.dex", dex file "/data/data/com.mapbox.mapboxsdk.testapp/files/instant-run/dex/slice-com.android.support-support-v4-23.4.0_f361c4dc5fef681e9606f7e9306543
    05-25 16:53:01.274 15765-15765/com.mapbox.mapboxsdk.testapp D/Error: ERR: exClass=java.lang.UnsatisfiedLinkError
    05-25 16:53:01.274 15765-15765/com.mapbox.mapboxsdk.testapp D/Error: ERR: exMsg=com.android.tools.fd.runtime.IncrementalClassLoader$DelegateClassLoader[DexPathList[[dex file "/data/data/com.mapbox.mapboxsdk.testapp/files/instant-run/dex/slice-support-annotations-23.4.0_04a2370ef5dcf6f091064d539cf534927f05a927-classes.dex", dex file "/data/data/com.mapbox.mapboxsdk.testapp/files/instant-run/dex/slice-slice_9-classes.dex", dex file "/data/data/com.mapbox.mapboxsdk.testapp/files/instant-run/dex/slice-slice_8-classes.dex", dex file "/data/data/com.mapbox.mapboxsdk.testapp/files/instant-run/dex/slice-slice_7-classes.dex", dex file "/data/data/com.mapbox.mapboxsdk.testapp/files/instant-run/dex/slice-slice_6-classes.dex", dex file "/data/data/com.mapbox.mapboxsdk.testapp/files/instant-run/dex/slice-slice_5-classes.dex", dex file "/data/data/com.mapbox.mapboxsdk.testapp/files/instant-run/dex/slice-slice_4-classes.dex", dex file "/data/data/com.mapbox.mapboxsdk.testapp/files/instant-run/dex/slice-slice_3-classes.dex", dex file "/data/data/com.mapbox.mapboxsdk.testapp/files/instant-run/dex/slice-slice_2-classes.dex", dex file "/data/data/com.mapbox.mapboxsdk.testapp/files/instant-run/dex/slice-slice_1-classes.dex", dex file "/data/data/com.mapbox.mapboxsdk.testapp/files/instant-run/dex/slice-slice_0-classes.dex", dex file "/data/data/com.mapbox.mapboxsdk.testapp/files/instant-run/dex/slice-retrofit-2.0.0-beta2_7d8e7e73bafe6095b4a84cb4938d2da678f45eb4-classes.dex", dex file "/data/data/com.mapbox.mapboxsdk.testapp/files/instant-run/dex/slice-okio-1.8.0_c5baa29f5fae5888a8665cf3edb4917ce0358d25-classes.dex", dex file "/data/data/com.mapbox.mapboxsdk.testapp/files/instant-run/dex/slice-okhttp-3.3.0_e1d36ca3045ebd118d4d00bd9ef96f353ce5e5c9-classes.dex", dex file "/data/data/com.mapbox.mapboxsdk.testapp/files/instant-run/dex/slice-okhttp-2.5.0_5dd158fe04709a67bb93b4a34bf476815cf80107-classes.dex", dex file "/data/data/com.mapbox.mapboxsdk.testapp/files/instant-run/dex/slice-leakcanary-watcher-1.4-beta1_5536cd189f0723fd037323832ef68ccf576465ba-classes.dex", dex file "/data/data/com.mapbox.mapboxsdk.testapp/files/instant-run/dex/slice-leakcanary-analyzer-1.4-beta1_474ae61f11fd29b610bb4a3fef3d7eead108deb0-classes.dex", dex file "/data/data/com.mapbox.mapboxsdk.testapp/files/instant-run/dex/slice-internal_impl-23.4.0_cc799c0d9487896bd46471b0f6e6db8c99931918-classes.dex", dex file "/data/data/com.mapbox.mapboxsdk.testapp/files/instant-run/dex/slice-haha-2.0.2_b5ac781814e730a0a53b4367cb98b60b154c9c12-classes.dex", dex file "/data/data/com.mapbox.mapboxsdk.testapp/files/instant-run/dex/slice-guava-18.0_a86682c32428cb91caa67be07f25205caeb390f1-classes.dex", dex file "/data/data/com.mapbox.mapboxsdk.testapp/files/instant-run/dex/slice-gson-2.3.1_651b769da75570d6fe6fea4b54668b7c1b0fb88e-classes.dex", dex file "/data/data/com.mapbox.mapboxsdk.testapp/files/instant-run/dex/slice-converter-gson-2.0.0-beta2_b30b492565a0bc6149af8109e6247aaff6192e3b-classes.dex", dex file "/data/data/com.mapbox.mapboxsdk.testapp/files/instant-run/dex/slice-com.squareup.leakcanary-leakcanary-android-1.4-beta1_fc0ad17440db7f698ca34841d375276db7ee1ecc-classes.dex", dex file "/data/data/com.mapbox.mapboxsdk.testapp/files/instant-run/dex/slice-com.mapzen.android-lost-1.1.0_1681734e2f803ea170cef70ac97bc3a871b83d71-classes.dex", dex file "/data/data/com.mapbox.mapboxsdk.testapp/files/instant-run/dex/slice-com.mapbox.mapboxsdk-mapbox-android-geocoder-1.0.0_b8514593b8d16d99273d8ad0e651a812fbbe78a6-classes.dex", dex file "/data/data/com.mapbox.mapboxsdk.testapp/files/instant-run/dex/slice-com.mapbox.mapboxsdk-mapbox-android-directions-1.0.0_95e3e5412f1779d3534140fa00a0e5b54d957b9b-classes.dex", dex file "/data/data/com.mapbox.mapboxsdk.testapp/files/instant-run/dex/slice-com.android.support-support-vector-drawable-23.4.0_b1c8db43eab90b14ccc3301821d237b63a3ef419-classes.dex", dex file "/data/data/com.mapbox.mapboxsdk.testapp/files/instant-run/dex/slice-com.android.support-support-v4-23.4.0_f361c4dc5fef681e9606f7e93065437740fb89eb-classes.dex", dex file "/data/data/com.mapbox.mapboxsdk.testapp/files/instant-run/dex/slice
    05-25 16:53:01.274 15765-15765/com.mapbox.mapboxsdk.testapp D/Error: ERR: file=Runtime.java
    05-25 16:53:01.274 15765-15765/com.mapbox.mapboxsdk.testapp D/Error: ERR: class=java.lang.Runtime
    05-25 16:53:01.274 15765-15765/com.mapbox.mapboxsdk.testapp D/Error: ERR: method=loadLibrary line=366
    05-25 16:53:01.274 15765-15765/com.mapbox.mapboxsdk.testapp D/Error: ERR: stack=java.lang.UnsatisfiedLinkError: com.android.tools.fd.runtime.IncrementalClassLoader$DelegateClassLoader[DexPathList[[dex file "/data/data/com.mapbox.mapboxsdk.testapp/files/instant-run/dex/slice-support-annotations-23.4.0_04a2370ef5dcf6f091064d539cf534927f05a927-classes.dex", dex file "/data/data/com.mapbox.mapboxsdk.testapp/files/instant-run/dex/slice-slice_9-classes.dex", dex file "/data/data/com.mapbox.mapboxsdk.testapp/files/instant-run/dex/slice-slice_8-classes.dex", dex file "/data/data/com.mapbox.mapboxsdk.testapp/files/instant-run/dex/slice-slice_7-classes.dex", dex file "/data/data/com.mapbox.mapboxsdk.testapp/files/instant-run/dex/slice-slice_6-classes.dex", dex file "/data/data/com.mapbox.mapboxsdk.testapp/files/instant-run/dex/slice-slice_5-classes.dex", dex file "/data/data/com.mapbox.mapboxsdk.testapp/files/instant-run/dex/slice-slice_4-classes.dex", dex file "/data/data/com.mapbox.mapboxsdk.testapp/files/instant-run/dex/slice-slice_3-classes.dex", dex file "/data/data/com.mapbox.mapboxsdk.testapp/files/instant-run/dex/slice-slice_2-classes.dex", dex file "/data/data/com.mapbox.mapboxsdk.testapp/files/instant-run/dex/slice-slice_1-classes.dex", dex file "/data/data/com.mapbox.mapboxsdk.testapp/files/instant-run/dex/slice-slice_0-classes.dex", dex file "/data/data/com.mapbox.mapboxsdk.testapp/files/instant-run/dex/slice-retrofit-2.0.0-beta2_7d8e7e73bafe6095b4a84cb4938d2da678f45eb4-classes.dex", dex file "/data/data/com.mapbox.mapboxsdk.testapp/files/instant-run/dex/slice-okio-1.8.0_c5baa29f5fae5888a8665cf3edb4917ce0358d25-classes.dex", dex file "/data/data/com.mapbox.mapboxsdk.testapp/files/instant-run/dex/slice-okhttp-3.3.0_e1d36ca3045ebd118d4d00bd9ef96f353ce5e5c9-classes.dex", dex file "/data/data/com.mapbox.mapboxsdk.testapp/files/instant-run/dex/slice-okhttp-2.5.0_5dd158fe04709a67bb93b4a34bf476815cf80107-classes.dex", dex file "/data/data/com.mapbox.mapboxsdk.testapp/files/instant-run/dex/slice-leakcanary-watcher-1.4-beta1_5536cd189f0723fd037323832ef68ccf576465ba-classes.dex", dex file "/data/data/com.mapbox.mapboxsdk.testapp/files/instant-run/dex/slice-leakcanary-analyzer-1.4-beta1_474ae61f11fd29b610bb4a3fef3d7eead108deb0-classes.dex", dex file "/data/data/com.mapbox.mapboxsdk.testapp/files/instant-run/dex/slice-internal_impl-23.4.0_cc799c0d9487896bd46471b0f6e6db8c99931918-classes.dex", dex file "/data/data/com.mapbox.mapboxsdk.testapp/files/instant-run/dex/slice-haha-2.0.2_b5ac781814e730a0a53b4367cb98b60b154c9c12-classes.dex", dex file "/data/data/com.mapbox.mapboxsdk.testapp/files/instant-run/dex/slice-guava-18.0_a86682c32428cb91caa67be07f25205caeb390f1-classes.dex", dex file "/data/data/com.mapbox.mapboxsdk.testapp/files/instant-run/dex/slice-gson-2.3.1_651b769da75570d6fe6fea4b54668b7c1b0fb88e-classes.dex", dex file "/data/data/com.mapbox.mapboxsdk.testapp/files/instant-run/dex/slice-converter-gson-2.0.0-beta2_b30b492565a0bc6149af8109e6247aaff6192e3b-classes.dex", dex file "/data/data/com.mapbox.mapboxsdk.testapp/files/instant-run/dex/slice-com.squareup.leakcanary-leakcanary-android-1.4-beta1_fc0ad17440db7f698ca34841d375276db7ee1ecc-classes.dex", dex file "/data/data/com.mapbox.mapboxsdk.testapp/files/instant-run/dex/slice-com.mapzen.android-lost-1.1.0_1681734e2f803ea170cef70ac97bc3a871b83d71-classes.dex", dex file "/data/data/com.mapbox.mapboxsdk.testapp/files/instant-run/dex/slice-com.mapbox.mapboxsdk-mapbox-android-geocoder-1.0.0_b8514593b8d16d99273d8ad0e651a812fbbe78a6-classes.dex", dex file "/data/data/com.mapbox.mapboxsdk.testapp/files/instant-run/dex/slice-com.mapbox.mapboxsdk-mapbox-android-directions-1.0.0_95e3e5412f1779d3534140fa00a0e5b54d957b9b-classes.dex", dex file "/data/data/com.mapbox.mapboxsdk.testapp/files/instant-run/dex/slice-com.android.support-support-vector-drawable-23.4.0_b1c8db43eab90b14ccc3301821d237b63a3ef419-classes.dex", dex file "/data/data/com.mapbox.mapboxsdk.testapp/files/instant-run/dex/slice-com.android.support-support-v4-23.4.0_f361c4dc5fef681e9606f7e93065437740fb89eb-classes.dex", dex file "/data/data/com.mapbox.mapboxsdk.tes
    05-25 16:53:01.274 15765-15765/com.mapbox.mapboxsdk.testapp D/Error: ERR: TOTAL BYTES WRITTEN: 22448
  13. bleege commented on May 25, 2016

    @bleege
    Contributor

    Tested this on both Samsung S5 (API 21) and Nexus 5x (API 23) with both crashing with similar stacktraces. @cammace tested on a Samsung S6 and also had crashes. Next steps are to rebuild off of master from where the dev branch split to verify that it was starting at functioning spot.

  14. changed the title [-]MapboxMapOptions not using account manager[/-] [+]MapFragment and SupportMapFragment not using account manager[/+] on May 25, 2016
  15. bleege commented on May 25, 2016

    @bleege
    Contributor

    Ok, feeling a little better about this now. I just rebuilt from master at the place where the dev branch split from ( 6368403 ) found that both MapFragmentActivity and SupportMapFragmentActivity worked as expected on a Nexus 5x and the Samsung S5. That narrows the issue down to the dev branch and the 3 commits that I made.

  16. bleege commented on May 25, 2016

    @bleege
    Contributor

    I checked out the dev branch again, rebuilt, and got both MapFragmentActivity and SupportMapFragmentActivity to work on both the Nexus 5x and Samsung S5 on the first try. Something must have been cached in locally on my computer. Weird.

    After doing that I then re added the access token to both the MapFragmentActivity and SupportMapFragmentActivity and successfully ran them. This means that things are working now with both MapboxAccountManger and the now deprecated inline via MapboxMapOptions (see below). Should be ready to merge.

    options.accessToken(getString(R.string.mapbox_access_token));
  17. added 3 commits that reference this issue on May 26, 2016
  18. bleege commented on May 26, 2016

    @bleege
    Contributor

    Rebased and Merged!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Androidbug

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions