mapbox / mapbox/mapbox-navigation-android

InstructionView not being rendered in LayoutPreview

Open
#3,555 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

UI
Dominant language
Kotlin
Stars
651
Forks
321
PR merge metrics
No merged PRs in 30d

Description

**Android API:**
**Mapbox Navigation SDK version:** 1.0.0-rc7 of both normal and ui sdk.

### Steps to trigger behavior

1. Include `com.mapbox.navigation.ui.instruction.InstructionView` in a layout
2. Build project
3. Layout Preview fails to render layout, as somewhere something uses `ConnectionPool`, which shouldn't be done when `isInEditMode()`.

### Expected behavior
InstructionView preview renders with static/sample data, showing the customized colors

### Actual behavior
Class can not be instantiated and therefore can't be previewed.

```
java.lang.NoClassDefFoundError: Could not initialize class okhttp3.internal.concurrent.TaskRunner
at okhttp3.ConnectionPool.(ConnectionPool.kt:41)
at okhttp3.ConnectionPool.(ConnectionPool.kt:47)
at okhttp3.OkHttpClient$Builder.(OkHttpClient.kt:445)
at com.mapbox.navigation.ui.instruction.GuidanceViewImageProvider.(GuidanceViewImageProvider.kt:36)
at com.mapbox.navigation.ui.instruction.InstructionView.(InstructionView.java:130)
at com.mapbox.navigation.ui.instruction.InstructionView.(InstructionView.java:180)
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:403)
at org.jetbrains.android.uipreview.ViewLoader.loadClass(ViewLoader.java:186)
at org.jetbrains.android.uipreview.ViewLoader.loadView(ViewLoader.java:144)
at com.android.tools.idea.rendering.LayoutlibCallbackImpl.loadView(LayoutlibCallbackImpl.java:309)
at android.view.BridgeInflater.loadCustomView(BridgeInflater.java:416)
at android.view.BridgeInflater.loadCustomView(BridgeInflater.java:427)
at android.view.BridgeInflater.createViewFromTag(BridgeInflater.java:331)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:961)
at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:1123)
at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:72)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:1097)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1084)
at android.view.LayoutInflater.inflate(LayoutInflater.java:682)
at android.view.LayoutInflater.inflate(LayoutInflater.java:501)
at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:348)
at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:404)
at com.android.tools.idea.layoutlib.LayoutLibrary.createSession(LayoutLibrary.java:141)
at com.android.tools.idea.rendering.RenderTask.createRenderSession(RenderTask.java:678)
at com.android.tools.idea.rendering.RenderTask.lambda$inflate$8(RenderTask.java:809)
at java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1604)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
```

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the InstructionView constructors and the GuidanceViewImageProvider initialization shown in the stack trace, then trace where ConnectionPool is created during layout preview. Check the isInEditMode path and verify that Layout Preview renders InstructionView with static or sample data and customized colors without the exception.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, kotlin
Domain
mobile
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.