Mapbox-gl-native: [Android] Error inflating class Android API < 21 with current snapshot

Created on 2 May 2016  路  13Comments  路  Source: mapbox/mapbox-gl-native

Platform:
Android 4.4.2 on a Sony Xperia P
Mapbox SDK version:
4.1.0-Snapshot

Steps to trigger behavior

  1. use current snapshot at demo app
  2. App will crash at start

    Expected behavior

App starting (Android API >= 21), tried it on a LG L90 with Android 5.0.2. Snapshot was working fine until recent changes concerning the location view (that i don't even use in my own project yet)

Actual behavior

App crashing at setContentView(R.layout.activity_main); 'Error inflating class com.mapbox.mapboxsdk.maps.MapView' because of 'res/drawable/ic_mylocationview_background.xml from drawable resource ID #0x7f020056' as 'Can't convert to color: type=0x2'. Quick use of google suggested that there is an issue with the use of use attrs to color in xml drawable on API < 21 that you do in ic_mylocationview_background.xml:
<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="oval"> <solid android:color="?attr/colorPrimaryDark" /> <size android:width="@dimen/my_locationview_outer_circle" android:height="@dimen/my_locationview_outer_circle" /> </shape>

Android bug

Most helpful comment

@mpuchala @Schumi09
We are currently thinking of releasing a intermediate bugfix release in 4.0.1 which is unrelated to this issue since the 4.0.0 version did not include code mentioned above. I'm going to kickoff a 4.1.0 on our CI so you can work with 4.1.0 and be unblocked from this issue. I will later put that scheduled build back on the bugfix release.

All 13 comments

Thank you for reaching out and reporting your issue, will patch this up asap

@bleege decided that the default color should be white and that we will not use automatic tinting in https://github.com/mapbox/mapbox-gl-native/issues/4878#issuecomment-215521105. I'm going to change ic_mylocationview_background.xml to relfect these changes and revert the change of Color.WHITE/Color.TRANSPARENT from https://github.com/mapbox/mapbox-gl-native/commit/2c3e1372600f875d717957c2a10708d1d1937e09.

@tobrun Can you provide more context as to why White would cause this issue but Transparent does not?

@bleege decided that the default color should be white

Some clarification is needed on this. The User dot default of blue with a white circle has been a Mapbox design decision that's been implemented on both iOS and Android going back to the original releases of both SDKs. That's not to say that this can't change in future iterations, but it'll involve a discussion across the entire @mapbox/mobile team instead of just an arbitrary decision.

The iOS SDK uses the application鈥檚 tint color. The tint color just happens to be blue by default on iOS.

Thanks for clarifying the original iOS decision @1ec5. That makes a lot of sense and now knowing that iOS was following platform integration pattern instead of a wider "Mapbox Style" concept that totally makes sense to do so on Android too.

Can you provide more context as to why White would cause this issue but Transparent does not?

The source of this issue is using ?attr/colorPrimaryDark in ic_mylocationview_background.xml and not optimising the resource folders by placing it in drawable-v21 and providing an alternative for prior versions.

The reason why I switched from white to transparent is documented here.

@bleege @tobrun @1ec5 This makes sense to me. For project consistency, let's follow the platform design guidelines and use material design colors (primary, primary dark, accent...) whenever possible.

@tobrun @bleege When we can expect new snapshot release? As far as I can see the last one is from 02.05 and this fix is not available.

Hi, thank you for fixing this. Like @mpuchala I'm currently also a bit confused about the snapshots. I noticed that there is a 4.0.1 snapshot now, but it does not seem to include the 4.1.0 fixes.

@mpuchala @Schumi09
We are currently thinking of releasing a intermediate bugfix release in 4.0.1 which is unrelated to this issue since the 4.0.0 version did not include code mentioned above. I'm going to kickoff a 4.1.0 on our CI so you can work with 4.1.0 and be unblocked from this issue. I will later put that scheduled build back on the bugfix release.

@tobrun Hi, sorry for jumping into the thread after it's been closed, but I wanted to ask , will this fix be available in 4.1.0 snapshot, or otherwise when will be the 4.1.0 released into production. Thanks

@mpuchala @Schumi09 @zztimerobber
Small update, I just verified that the SNAPSHOT-4.1.0 has been build and if it's available for download.
Feel free to reopen this issue in case the issue isn't resolved.

Note: It could be that you need to invalidate your gradle cache to fetch the latest version.

Source: Mapbox SDK on maven

Great, thx!

Was this page helpful?
0 / 5 - 0 ratings