title: crash when i try to create a path between two points in osmdroid
body: <p>I have recently started studying android and kotlin programming, I'm trying to create an application that allows you to create one or more routes on a map, save it and then retrieve it when necessary. I chose to use osmDroid and osmBonusPack because open source but I don't find much documentation online, I'm trying to visualize a path between two Markers, I was able to visualize two markers and draw a straight line between two other points, now I'm trying to make the path but I don't understand how to proceed. Following the tutorial:</p>
  <p><a href="https://github.com/MKergall/osmbonuspack/wiki/Tutorial_1" rel="nofollow noreferrer">https://github.com/MKergall/osmbonuspack/wiki/Tutorial_1</a></p>
  <p>trying to put some println(&quot;check&quot;) i understand that the app crashes when it gets to the line:</p>
  <pre><code>val road: Road = roadManager.getRoad(waypoints)
  </code></pre>
  <p>what's my problem? what is the error:</p>
  <p>E/AndroidRuntime: FATAL EXCEPTION: main
  Process: uk.co.lorenzopulcinelli.trackapp, PID: 28815
  java.lang.NoClassDefFoundError: Failed resolution of: Lokhttp3/Request$Builder;</p>
  <p>?</p>
  <pre><code>    package uk.co.lorenzopulcinelli.trackapp
      
      import android.Manifest
      import android.content.pm.PackageManager
      import android.os.Bundle
      import android.util.DisplayMetrics
      import androidx.appcompat.app.AppCompatActivity
      import androidx.core.app.ActivityCompat
      import androidx.preference.PreferenceManager
      import org.osmdroid.api.IMapController
      import org.osmdroid.bonuspack.routing.OSRMRoadManager
      import org.osmdroid.bonuspack.routing.Road
      import org.osmdroid.bonuspack.routing.RoadManager
      import org.osmdroid.config.Configuration
      import org.osmdroid.config.Configuration.*
      import org.osmdroid.tileprovider.tilesource.TileSourceFactory
      import org.osmdroid.util.GeoPoint
      import org.osmdroid.views.CustomZoomButtonsController
      import org.osmdroid.views.MapView
      import org.osmdroid.views.overlay.compass.CompassOverlay
      import org.osmdroid.views.overlay.compass.InternalCompassOrientationProvider
      import org.osmdroid.views.overlay.*
      import org.osmdroid.views.overlay.gestures.RotationGestureOverlay
      import org.osmdroid.views.overlay.mylocation.GpsMyLocationProvider
      import org.osmdroid.views.overlay.mylocation.MyLocationNewOverlay
      
      import org.osmdroid.views.overlay.Marker
      
      
      
      
      class MainActivity : AppCompatActivity() {
          private lateinit var mapView : MapView
          private lateinit var myLocationNewOverlay: MyLocationNewOverlay
          private lateinit var compassOverlay: CompassOverlay
          private lateinit var mapController: IMapController
          private lateinit var userAgent: String
      
          override fun onCreate(savedInstanceState: Bundle?) {
              super.onCreate(savedInstanceState)
      
              
              requestPermission()
      
              
              getInstance().load(this, PreferenceManager.getDefaultSharedPreferences(this))
      
      
              
              setContentView(R.layout.activity_main)
              mapView = findViewById&lt;MapView&gt;(R.id.map)
              mapView.setTileSource(TileSourceFactory.MAPNIK)
              mapView.zoomController.setVisibility(CustomZoomButtonsController.Visibility.NEVER)
      
      
              
              mapController = mapView.controller
              
              myLocationNewOverlay = MyLocationNewOverlay(GpsMyLocationProvider(this), mapView)
              myLocationNewOverlay.enableMyLocation()
              myLocationNewOverlay.enableMyLocation()
              myLocationNewOverlay.isDrawAccuracyEnabled = true
              myLocationNewOverlay.runOnFirstFix { runOnUiThread {
                  mapController.animateTo(myLocationNewOverlay.myLocation)
                  mapController.setZoom(9.5)
                  }
              }
              mapView.overlays.add(myLocationNewOverlay)
      
              
              Configuration.getInstance().userAgentValue = &quot;lolloMaps&quot;
      
              
              println(myLocationNewOverlay.myLocation)
              println(&quot;creato&quot;)
      
      
              
              compassOverlay = CompassOverlay(this, InternalCompassOrientationProvider(this), mapView)
              compassOverlay.enableCompass()
              mapView.overlays.add(compassOverlay)
      
      
              // val overlay = LatLonGridlineOverlay2()
              // mapView.overlays.add(overlay)
      
              
              val rotationGestureOverlay = RotationGestureOverlay(mapView)
              rotationGestureOverlay.isEnabled
              mapView.setMultiTouchControls(true)
              mapView.overlays.add(rotationGestureOverlay)
      
              
              myLocationNewOverlay = MyLocationNewOverlay(GpsMyLocationProvider(this), mapView)
              myLocationNewOverlay.enableMyLocation()
              mapView.overlays.add(myLocationNewOverlay)
      
              
              val dm : DisplayMetrics = resources.displayMetrics
              val scaleBarOverlay = ScaleBarOverlay(mapView)
              scaleBarOverlay.setCentred(true)
              scaleBarOverlay.setScaleBarOffset(dm.widthPixels / 2, 10)
              mapView.overlays.add(scaleBarOverlay)
      
      
              mioMarker(55.45, 22.48, 1)
              mioMarker(47.22, 15.48, 2)
      
      
              val pnt1: GeoPoint = GeoPoint(52.50, 13.40)
              val pnt2: GeoPoint = GeoPoint(42.54, 27.40)
              val polyline: Polyline = Polyline(mapView)
              polyline.addPoint(pnt1)
              polyline.addPoint(pnt2)
              mapView.overlays.add(polyline)
              mapView.invalidate()
      
      
              val roadManager:RoadManager = OSRMRoadManager(this, )
              val waypoints = ArrayList&lt;GeoPoint&gt;()
              val startPoint: GeoPoint = GeoPoint(66.7, -14.6)
              waypoints.add(startPoint)
              val endPoint: GeoPoint = GeoPoint(48.4, -1.9)
              waypoints.add(endPoint)
              val road: Road = roadManager.getRoad(waypoints)
              val roadOverlay: Polyline = RoadManager.buildRoadOverlay(road)
              mapView.overlays.add(roadOverlay)
              mapView.invalidate()
      
          }
      
          override fun onResume() {
              super.onResume()
              mapView.onResume()
          }
      
          override fun onPause() {
              super.onPause()
              mapView.onPause()
          }
      
          
          private fun hasPermission() : Boolean {
              
              return ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED
          }
      
      
      
          private fun requestPermission() {
      
              val permission = mutableListOf&lt;String&gt;()
      
              if (!hasPermission()) {
      
                  permission.add(Manifest.permission.ACCESS_FINE_LOCATION)
              }
      
              if (permission.isNotEmpty()) {
                  ActivityCompat.requestPermissions(this, permission.toTypedArray(), 0)
              }
          }
      
          // fun add Marker
          private fun mioMarker(lati: Double, longi: Double, i: Int) {
              val pinMarker = Marker(mapView)
              val geoPoint = GeoPoint(lati, longi)
              pinMarker.position = geoPoint
              pinMarker.setAnchor(Marker.ANCHOR_CENTER, Marker.ANCHOR_CENTER)
              pinMarker.title = &quot;Title&quot;
              pinMarker.subDescription = &quot;i'm pin #$i, my coordinate $lati, $longi.&quot;
              pinMarker.isDraggable = true
              mapView.overlays.add(pinMarker)
              mapView.invalidate()
      
          }
      }
  </code></pre>
  <p>this is my manifest:</p>
  <pre><code>    &lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
  &lt;manifest xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
      xmlns:tools=&quot;http://schemas.android.com/tools&quot;
      package=&quot;uk.co.lorenzopulcinelli.trackapp&quot;&gt;
  
      &lt;uses-permission android:name=&quot;android.permission.ACCESS_FINE_LOCATION&quot;/&gt;
      &lt;uses-permission android:name=&quot;android.permission.ACCESS_COARSE_LOCATION&quot;/&gt;
      &lt;uses-permission android:name=&quot;android.permission.ACCESS_BACKGROUND_LOCATION&quot; /&gt;
      &lt;uses-permission android:name=&quot;android.permission.ACCESS_WIFI_STATE&quot; /&gt;
      &lt;uses-permission android:name=&quot;android.permission.ACCESS_NETWORK_STATE&quot; /&gt;
      &lt;uses-permission android:name=&quot;android.permission.INTERNET&quot; /&gt;
      &lt;uses-permission android:name=&quot;android.permission.WRITE_EXTERNAL_STORAGE&quot; /&gt;
  
      &lt;uses-feature android:name=&quot;android.hardware.location.network&quot; android:required=&quot;false&quot; /&gt;
      &lt;uses-feature android:name=&quot;android.hardware.location.gps&quot; android:required=&quot;false&quot; /&gt;
      &lt;uses-feature android:name=&quot;android.hardware.telephony&quot; android:required=&quot;false&quot; /&gt;
      &lt;uses-feature android:name=&quot;android.hardware.wifi&quot; android:required=&quot;false&quot; /&gt;
  
  
      &lt;application
          android:allowBackup=&quot;true&quot;
          android:dataExtractionRules=&quot;@xml/data_extraction_rules&quot;
          android:fullBackupContent=&quot;@xml/backup_rules&quot;
          android:icon=&quot;@mipmap/ic_launcher&quot;
          android:label=&quot;@string/app_name&quot;
          android:roundIcon=&quot;@mipmap/ic_launcher_round&quot;
          android:supportsRtl=&quot;true&quot;
          android:theme=&quot;@style/Theme.TrackApp&quot;
          tools:targetApi=&quot;31&quot;&gt;
  
  
  
          &lt;activity
              android:name=&quot;.MainActivity&quot;
              android:exported=&quot;true&quot;&gt;
              &lt;intent-filter&gt;
                  &lt;action android:name=&quot;android.intent.action.MAIN&quot; /&gt;
  
                  &lt;category android:name=&quot;android.intent.category.LAUNCHER&quot; /&gt;
              &lt;/intent-filter&gt;
          &lt;/activity&gt;
      &lt;/application&gt;
  
  &lt;/manifest&gt;
  </code></pre>
  <p>and this is my buil.gradle:</p>
  <pre><code>        plugins {
          id 'com.android.application'
          id 'org.jetbrains.kotlin.android'
      }
      
      android {
          compileSdk 32
      
          defaultConfig {
              applicationId &quot;uk.co.lorenzopulcinelli.trackapp&quot;
              minSdk 21
              targetSdk 32
              versionCode 1
              versionName &quot;1.0&quot;
      
              testInstrumentationRunner &quot;androidx.test.runner.AndroidJUnitRunner&quot;
          }
      
          buildTypes {
              release {
                  minifyEnabled false
                  proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
              }
          }
          compileOptions {
              sourceCompatibility JavaVersion.VERSION_1_8
              targetCompatibility JavaVersion.VERSION_1_8
          }
          kotlinOptions {
              jvmTarget = '1.8'
          }
      }
      
      dependencies {
          implementation 'androidx.preference:preference:1.2.0' //aggiunta per utilizzare import androidx.preference.PreferenceManager
          implementation 'com.google.android.gms:play-services-location:20.0.0' //aggiunta per richiedere permessi localizzazione
      
          implementation 'androidx.core:core-ktx:1.8.0'
          implementation 'androidx.appcompat:appcompat:1.4.2'
          implementation 'com.google.android.material:material:1.6.1'
          implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
          implementation files('/home/acer/AndroidStudioProjects/TrackApp/app/libs/osmbonuspack_6.9.0.aar')
          implementation files('/home/acer/AndroidStudioProjects/TrackApp/app/libs/osmdroid-android-6.1.13.aar')
          androidTestImplementation 'androidx.test.ext:junit:1.1.3'
          androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
      }
  </code></pre>
  <p>below my Logcat:</p>
  <pre><code>07/01 17:42:05: Launching 'app' on Xiaomi Redmi Note 7.
  Install successfully finished in 4 s 662 ms.
  $ adb shell am start -n &quot;uk.co.lorenzopulcinelli.trackapp/uk.co.lorenzopulcinelli.trackapp.MainActivity&quot; -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
  Connected to process 28815 on device 'xiaomi-redmi_note_7-16dccaa4'.
  Capturing and displaying logcat messages from application. This behavior can be disabled in the &quot;Logcat output&quot; section of the &quot;Debugger&quot; settings page.
  I/Perf: Connecting to perf service.
  I/FeatureParser: can't find lavender.xml in assets/device_features/,it may be in /system/etc/device_features
  E/libc: Access denied finding property &quot;ro.vendor.df.effect.conflict&quot;
  W/inelli.trackapp: type=1400 audit(0.0:93235): avc: denied { read } for name=&quot;u:object_r:vendor_displayfeature_prop:s0&quot; dev=&quot;tmpfs&quot; ino=17716 scontext=u:r:untrusted_app:s0:c168,c257,c512,c768 tcontext=u:object_r:vendor_displayfeature_prop:s0 tclass=file permissive=0
  E/Perf: Fail to get file list uk.co.lorenzopulcinelli.trackapp
  E/Perf: getFolderSize() : Exception_1 = java.lang.NullPointerException: Attempt to get length of null array
  I/StorageUtils: /data/user/0/uk.co.lorenzopulcinelli.trackapp/files is writable
  I/StorageUtils: /storage/emulated/0/Android/data/uk.co.lorenzopulcinelli.trackapp/files is writable
  I/StorageUtils: /storage/4A6A-676E/Android/data/uk.co.lorenzopulcinelli.trackapp/files is writable
  I/StorageUtils: /data/user/0/uk.co.lorenzopulcinelli.trackapp/files is writable
  I/StorageUtils: /storage/emulated/0/Android/data/uk.co.lorenzopulcinelli.trackapp/files is writable
  I/StorageUtils: /storage/4A6A-676E/Android/data/uk.co.lorenzopulcinelli.trackapp/files is writable
  D/ForceDarkHelper: updateByCheckExcludeList: pkg: uk.co.lorenzopulcinelli.trackapp activity: uk.co.lorenzopulcinelli.trackapp.MainActivity@148f695
  D/ForceDarkHelper: updateByCheckExcludeList: pkg: uk.co.lorenzopulcinelli.trackapp activity: uk.co.lorenzopulcinelli.trackapp.MainActivity@148f695
  W/inelli.trackap: Accessing hidden method Landroid/view/View;-&gt;computeFitSystemWindows(Landroid/graphics/Rect;Landroid/graphics/Rect;)Z (greylist, reflection, allowed)
  W/inelli.trackap: Accessing hidden method Landroid/view/ViewGroup;-&gt;makeOptionalFitsSystemWindows()V (greylist, reflection, allowed)
  D/ForceDarkHelper: updateByCheckExcludeList: pkg: uk.co.lorenzopulcinelli.trackapp activity: uk.co.lorenzopulcinelli.trackapp.MainActivity@148f695
  D/ForceDarkHelper: updateByCheckExcludeList: pkg: uk.co.lorenzopulcinelli.trackapp activity: uk.co.lorenzopulcinelli.trackapp.MainActivity@148f695
  I/OsmDroid: Using tile source specified in layout attributes: Mapnik
  I/OsmDroid: Using tile source: Mapnik
  I/OsmDroid: Tile cache increased from 0 to 9
  I/System.out: null
  I/System.out: creato
  D/ForceDarkHelper: updateByCheckExcludeList: pkg: uk.co.lorenzopulcinelli.trackapp activity: uk.co.lorenzopulcinelli.trackapp.MainActivity@148f695
  D/ForceDarkHelper: updateByCheckExcludeList: pkg: uk.co.lorenzopulcinelli.trackapp activity: uk.co.lorenzopulcinelli.trackapp.MainActivity@148f695
  I/chatty: uid=10424(uk.co.lorenzopulcinelli.trackapp) identical 5 lines
  D/ForceDarkHelper: updateByCheckExcludeList: pkg: uk.co.lorenzopulcinelli.trackapp activity: uk.co.lorenzopulcinelli.trackapp.MainActivity@148f695
  D/ForceDarkHelper: updateByCheckExcludeList: pkg: uk.co.lorenzopulcinelli.trackapp activity: uk.co.lorenzopulcinelli.trackapp.MainActivity@148f695
  I/chatty: uid=10424(uk.co.lorenzopulcinelli.trackapp) identical 6 lines
  D/ForceDarkHelper: updateByCheckExcludeList: pkg: uk.co.lorenzopulcinelli.trackapp activity: uk.co.lorenzopulcinelli.trackapp.MainActivity@148f695
  I/System.out: inizio
  I/System.out: passo1 - creoArrayList
  I/System.out: passo2 - CreoPuntiEAggiungoInArrayList
  I/System.out: passo3 - CreoStrada
  D/BONUSPACK: OSRMRoadManager.getRoads:https://routing.openstreetmap.de/routed-car/route/v1/driving/-14.6000000000,66.7000000000;-1.9000000000,48.4000000000?alternatives=false&amp;overview=full&amp;steps=true
  D/AndroidRuntime: Shutting down VM
  E/AndroidRuntime: FATAL EXCEPTION: main
      Process: uk.co.lorenzopulcinelli.trackapp, PID: 28815
      java.lang.NoClassDefFoundError: Failed resolution of: Lokhttp3/Request$Builder;
          at org.osmdroid.bonuspack.utils.HttpConnection.doGet(HttpConnection.java:65)
          at org.osmdroid.bonuspack.utils.BonusPackHelper.requestStringFromUrl(BonusPackHelper.java:59)
          at org.osmdroid.bonuspack.routing.OSRMRoadManager.getRoads(OSRMRoadManager.java:194)
          at org.osmdroid.bonuspack.routing.OSRMRoadManager.getRoad(OSRMRoadManager.java:286)
          at uk.co.lorenzopulcinelli.trackapp.MainActivity.onCreate(MainActivity.kt:132)
          at android.app.Activity.performCreate(Activity.java:7893)
          at android.app.Activity.performCreate(Activity.java:7880)
          at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1307)
          at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3286)
          at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3460)
          at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
          at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
          at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
          at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2047)
          at android.os.Handler.dispatchMessage(Handler.java:107)
          at android.os.Looper.loop(Looper.java:224)
          at android.app.ActivityThread.main(ActivityThread.java:7590)
          at java.lang.reflect.Method.invoke(Native Method)
          at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:539)
          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)
       Caused by: java.lang.ClassNotFoundException: Didn't find class &quot;okhttp3.Request$Builder&quot; on path: DexPathList[[zip file &quot;/data/app/uk.co.lorenzopulcinelli.trackapp-jx1_0YR4HzgrzlHgIcGy8w==/base.apk&quot;],nativeLibraryDirectories=[/data/app/uk.co.lorenzopulcinelli.trackapp-jx1_0YR4HzgrzlHgIcGy8w==/lib/arm64, /system/lib64, /system/product/lib64]]
          at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:230)
          at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
          at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
          at org.osmdroid.bonuspack.utils.HttpConnection.doGet(HttpConnection.java:65) 
          at org.osmdroid.bonuspack.utils.BonusPackHelper.requestStringFromUrl(BonusPackHelper.java:59) 
          at org.osmdroid.bonuspack.routing.OSRMRoadManager.getRoads(OSRMRoadManager.java:194) 
          at org.osmdroid.bonuspack.routing.OSRMRoadManager.getRoad(OSRMRoadManager.java:286) 
          at uk.co.lorenzopulcinelli.trackapp.MainActivity.onCreate(MainActivity.kt:132) 
          at android.app.Activity.performCreate(Activity.java:7893) 
          at android.app.Activity.performCreate(Activity.java:7880) 
          at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1307) 
          at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3286) 
          at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3460) 
          at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83) 
          at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135) 
          at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95) 
          at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2047) 
          at android.os.Handler.dispatchMessage(Handler.java:107) 
          at android.os.Looper.loop(Looper.java:224) 
          at android.app.ActivityThread.main(ActivityThread.java:7590) 
          at java.lang.reflect.Method.invoke(Native Method) 
          at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:539) 
          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950) 
  I/Process: Sending signal. PID: 28815 SIG: 9
  
  </code></pre>