Mapbox-gl-native: Rendering Problems MapBoxAndroidDemo in Android Studio

Created on 28 Jun 2016  路  8Comments  路  Source: mapbox/mapbox-gl-native

Platform: Android
Mapbox SDK version: v4.0.0 and above

Steps to trigger behavior

  1. Download master zip from MapBoxAndroidDemo at https://github.com/mapbox/mapbox-android-demo.
  2. Open in Android Studio 2.1.2 or 2.1.1
  3. Open activity_annotation_basic_marker_view.xml in Design mode, or in Text mode with Preview open.
  4. See Rendering Problems info appear on screen.

    Expected behavior

No Rendering Problems.

Actual behavior

Rendering Problems in Android Studio Preview.

More info

Seems like the same issue that was mentioned in this issue https://github.com/mapbox/mapbox-gl-native/issues/5228

The project builds and runs on an Android Device with no issues, just this Rendering problem when I try to preview the XML in AndroidStudio. Not really sure why that would happen. Also occurs when I try to create my own sample project following instructions from here https://www.mapbox.com/help/first-steps-android-sdk/

Stack Info

 Rendering Problems The following classes could not be instantiated:
-聽com.mapbox.mapboxsdk.maps.widgets.MyLocationView (Open Class, Show Exception, Clear Cache)

 Tip: Use View.isInEditMode() in your custom views to skip code or show sample data when shown in the IDE  Exception Details

java.lang.UnsupportedOperationException: Unsupported Service: location
    at com.android.layoutlib.bridge.android.BridgeContext.getSystemService(BridgeContext.java:570)
    at com.mapzen.android.lost.internal.FusionEngine.<init>(FusionEngine.java:38)
    at com.mapzen.android.lost.internal.FusedLocationProviderApiImpl.<init>(FusedLocationProviderApiImpl.java:27)
    at com.mapzen.android.lost.internal.LostApiClientImpl.connect(LostApiClientImpl.java:21)
    at com.mapbox.mapboxsdk.location.LocationServices.toggleGPS(LocationServices.java:88)
    at com.mapbox.mapboxsdk.maps.widgets.MyLocationView.toggleGps(MyLocationView.java:388)
    at com.mapbox.mapboxsdk.maps.widgets.MyLocationView.setEnabled(MyLocationView.java:341)
    at com.mapbox.mapboxsdk.maps.widgets.MyLocationView.init(MyLocationView.java:123)
    at com.mapbox.mapboxsdk.maps.widgets.MyLocationView.<init>(MyLocationView.java:114)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at org.jetbrains.android.uipreview.ViewLoader.createNewInstance(ViewLoader.java:465)
    at org.jetbrains.android.uipreview.ViewLoader.loadClass(ViewLoader.java:172)
    at org.jetbrains.android.uipreview.ViewLoader.loadView(ViewLoader.java:105)
    at com.android.tools.idea.rendering.LayoutlibCallbackImpl.loadView(LayoutlibCallbackImpl.java:176)
    at android.view.BridgeInflater.loadCustomView(BridgeInflater.java:247)
    at android.view.BridgeInflater.createViewFromTag(BridgeInflater.java:171)
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727)
    at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:858)
    at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:70)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:834)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
    at android.view.BridgeInflater.inflate(BridgeInflater.java:225)
    at com.mapbox.mapboxsdk.maps.MapView.initialize(MapView.java:192)
    at com.mapbox.mapboxsdk.maps.MapView.<init>(MapView.java:170)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at org.jetbrains.android.uipreview.ViewLoader.createNewInstance(ViewLoader.java:465)
    at org.jetbrains.android.uipreview.ViewLoader.loadClass(ViewLoader.java:172)
    at org.jetbrains.android.uipreview.ViewLoader.loadView(ViewLoader.java:105)
    at com.android.tools.idea.rendering.LayoutlibCallbackImpl.loadView(LayoutlibCallbackImpl.java:176)
    at android.view.BridgeInflater.loadCustomView(BridgeInflater.java:247)
    at android.view.BridgeInflater.createViewFromTag(BridgeInflater.java:171)
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727)
    at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:858)
    at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:70)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:834)
    at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:518)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
    at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:317)
    at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:429)
    at com.android.ide.common.rendering.LayoutLibrary.createSession(LayoutLibrary.java:350)
    at com.android.tools.idea.rendering.RenderTask$2.compute(RenderTask.java:520)
    at com.android.tools.idea.rendering.RenderTask$2.compute(RenderTask.java:508)
    at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:967)
    at com.android.tools.idea.rendering.RenderTask.createRenderSession(RenderTask.java:508)
    at com.android.tools.idea.rendering.RenderTask.access$600(RenderTask.java:75)
    at com.android.tools.idea.rendering.RenderTask$3.call(RenderTask.java:620)
    at com.android.tools.idea.rendering.RenderTask$3.call(RenderTask.java:617)
    at com.android.tools.idea.rendering.RenderService.runRenderAction(RenderService.java:371)
    at com.android.tools.idea.rendering.RenderTask.render(RenderTask.java:617)
    at com.android.tools.idea.rendering.RenderTask.render(RenderTask.java:639)
    at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager.doRender(AndroidLayoutPreviewToolWindowManager.java:654)
    at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager.access$1700(AndroidLayoutPreviewToolWindowManager.java:82)
    at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager$7$1.run(AndroidLayoutPreviewToolWindowManager.java:596)
    at com.intellij.openapi.progress.impl.CoreProgressManager$2.run(CoreProgressManager.java:142)
    at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:446)
    at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:392)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:54)
    at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:127)
    at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager$7.run(AndroidLayoutPreviewToolWindowManager.java:591)
    at com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.java:337)
    at com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.java:327)
    at com.intellij.util.ui.update.MergingUpdateQueue$3.run(MergingUpdateQueue.java:271)
    at com.intellij.util.ui.update.MergingUpdateQueue.flush(MergingUpdateQueue.java:286)
    at com.intellij.util.ui.update.MergingUpdateQueue.flush(MergingUpdateQueue.java:244)
    at com.intellij.util.ui.update.MergingUpdateQueue.run(MergingUpdateQueue.java:234)
    at com.intellij.util.concurrency.QueueProcessor.runSafely(QueueProcessor.java:238)
    at com.intellij.util.Alarm$Request$1.run(Alarm.java:352)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
Android support

Most helpful comment

@cammace That is all well and fine, but whenever I need to make adjustments to that layout XML, maybe change margins/padding, or add a new UI element, the Rendering Problem screen will pop back up, blocking my preview, making it rather frustrating when I need to go in and edit the XML and eyeball some UI changes.

A real solution at some point would be appreciated. Thanks =)

All 8 comments

/cc @cammace

Hey thanks for opening an issue and giving us your feedback, it's much appreciated. Android Studio tends to behave this way when the map view is in an activities layout. The work around for now is to just exit out of the warning and the map view will display as a grayed out area.

screen_shot_2016-07-01_at_5_29_14_pm

@cammace That is all well and fine, but whenever I need to make adjustments to that layout XML, maybe change margins/padding, or add a new UI element, the Rendering Problem screen will pop back up, blocking my preview, making it rather frustrating when I need to go in and edit the XML and eyeball some UI changes.

A real solution at some point would be appreciated. Thanks =)

I'm with @tcolligan-ap on this one.
Closing the error window is not a solution, this window will popup on every xml change.

Please re-open this issue.

I was able to reproduce this issue:
screen shot 2016-07-26 at 14 23 35

Added the same construction to MyLocationView as we have for MapView resolves the issue:

    private void init(Context context) {
        if(isInEditMode()){
            return;
        }
        ...
     }

screen shot 2016-07-26 at 14 24 01

While #5800 resolves the issue of the error, I think we should look into having support for showing something more in the layout editor as above (black screen). iOS has support for manipulating options and directly showing that result in their visual layout editor.

While above would be a nice addition just showing an image of a map and having the overlain components in the correct location would be a nice start.

cc @zugaldia @ivovandongen

I think we should look into having support for showing something more in the layout editor as above (black screen).

Definitely. Timing on this will be interesting though as Google is about to ship the new Layout Editor with Constraint Layout in Android Studio 2.2 Final. Once that ships we'll have a better idea of what developer expectations are for working with the new Layout Editor (besides this need to render without error that @tobrun has got working again) as well the technical needs for making the Mapbox Android SDK work well with it.

Closing this in favor of #5968

Was this page helpful?
0 / 5 - 0 ratings