Osmdroid maps not loading on my device
Asked Answered
M

4

5

I have an Alcatel One Touch 7040, when i test my sample of osmdroid on it, the maps don't render. I have tested on other devices, the maps are rendering in them properly, only on this device they are not. I thought my device memory was low so I deleted some apps from my device, still nothing improved, can someone please tell me what could be the reason?

Following is my logcat(some parts of it has been removed because word limit exceeded) :

10-17 23:03:27.688 26424-26424/marine.com.osmsample I/OsmDroid: Using tile source: Mapnik
10-17 23:03:27.702 26424-26424/marine.com.osmsample E/OsmDroid: unable to create a nomedia file. downloaded tiles may be visible to the gallery. open failed: ENOENT (No such file or directory)
10-17 23:03:27.715 26424-26424/marine.com.osmsample E/SQLiteLog: (14) cannot open file at line 30202 of [00bb9c9ce4]
10-17 23:03:27.715 26424-26424/marine.com.osmsample E/SQLiteLog: (14) os_unix.c:30202: (2) open(/storage/sdcard0/osmdroid/tiles/cache.db) - 
10-17 23:03:27.729 26424-26424/marine.com.osmsample E/SQLiteDatabase: Failed to open database '/storage/sdcard0/osmdroid/tiles/cache.db'.
                                                                      android.database.sqlite.SQLiteCantOpenDatabaseException: unknown error (code 14): Could not open database
                                                                          at android.database.sqlite.SQLiteConnection.nativeOpen(Native Method)
                                                                          at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:209)
                                                                          at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:193)
                                                                          at android.database.sqlite.SQLiteConnectionPool.openConnectionLocked(SQLiteConnectionPool.java:463)
                                                                          at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:185)
                                                                          at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:177)
                                                                          at android.database.sqlite.SQLiteDatabase.openInner(SQLiteDatabase.java:804)
                                                                          at android.database.sqlite.SQLiteDatabase.open(SQLiteDatabase.java:789)
                                                                          at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:694)
                                                                          at android.database.sqlite.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase.java:709)
                                                                          at android.database.sqlite.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase.java:702)
                                                                          at org.osmdroid.tileprovider.modules.SqlTileWriter.<init>(SqlTileWriter.java:44)
                                                                          at org.osmdroid.tileprovider.MapTileProviderBasic.<init>(MapTileProviderBasic.java:76)
                                                                          at org.osmdroid.tileprovider.MapTileProviderBasic.<init>(MapTileProviderBasic.java:50)
                                                                          at org.osmdroid.views.MapView.<init>(MapView.java:170)
                                                                          at org.osmdroid.views.MapView.<init>(MapView.java:200)
                                                                          at java.lang.reflect.Constructor.constructNative(Native Method)
                                                                          at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
                                                                          at android.view.LayoutInflater.createView(LayoutInflater.java:587)
                                                                          at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:687)
                                                                          at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
                                                                          at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
                                                                          at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
                                                                          at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
                                                                          at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:285)
                                                                          at android.app.Activity.setContentView(Activity.java:1882)
                                                                          at marine.com.osmsample.MainActivity.onCreate(MainActivity.java:55)
                                                                          at android.app.Activity.performCreate(Activity.java:5121)
                                                                          at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1146)
                                                                          at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2358)
                                                                          at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2446)
                                                                          at android.app.ActivityThread.access$600(ActivityThread.java:165)
                                                                          at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1373)
                                                                          at android.os.Handler.dispatchMessage(Handler.java:107)
                                                                          at android.os.Looper.loop(Looper.java:194)
                                                                          at android.app.ActivityThread.main(ActivityThread.java:5434)
                                                                          at java.lang.reflect.Method.invokeNative(Native Method)
                                                                          at java.lang.reflect.Method.invoke(Method.java:525)
                                                                          at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:834)
                                                                          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
                                                                          at dalvik.system.NativeStart.main(Native Method)
10-17 23:03:27.731 26424-26424/marine.com.osmsample E/OsmDroid: Unable to start the sqlite tile writer. Check external storage availability.
                                                                android.database.sqlite.SQLiteCantOpenDatabaseException: unknown error (code 14): Could not open database
                                                                    at android.database.sqlite.SQLiteConnection.nativeOpen(Native Method)
                                                                    at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:209)
                                                                    at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:193)
                                                                    at android.database.sqlite.SQLiteConnectionPool.openConnectionLocked(SQLiteConnectionPool.java:463)
                                                                    at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:185)
                                                                    at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:177)
                                                                    at android.database.sqlite.SQLiteDatabase.openInner(SQLiteDatabase.java:804)
                                                                    at android.database.sqlite.SQLiteDatabase.open(SQLiteDatabase.java:789)
                                                                    at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:694)
                                                                    at android.database.sqlite.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase.java:709)
                                                                    at android.database.sqlite.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase.java:702)
                                                                    at org.osmdroid.tileprovider.modules.SqlTileWriter.<init>(SqlTileWriter.java:44)
                                                                    at org.osmdroid.tileprovider.MapTileProviderBasic.<init>(MapTileProviderBasic.java:76)
                                                                    at org.osmdroid.tileprovider.MapTileProviderBasic.<init>(MapTileProviderBasic.java:50)
                                                                    at org.osmdroid.views.MapView.<init>(MapView.java:170)
                                                                    at org.osmdroid.views.MapView.<init>(MapView.java:200)
                                                                    at java.lang.reflect.Constructor.constructNative(Native Method)
                                                                    at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
                                                                    at android.view.LayoutInflater.createView(LayoutInflater.java:587)
                                                                    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:687)
                                                                    at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
                                                                    at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
                                                                    at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
                                                                    at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
                                                                    at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:285)
                                                                    at android.app.Activity.setContentView(Activity.java:1882)
                                                                    at marine.com.osmsample.MainActivity.onCreate(MainActivity.java:55)
                                                                    at android.app.Activity.performCreate(Activity.java:5121)
                                                                    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1146)
                                                                    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2358)
                                                                    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2446)
                                                                    at android.app.ActivityThread.access$600(ActivityThread.java:165)
                                                                    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1373)
                                                                    at android.os.Handler.dispatchMessage(Handler.java:107)
                                                                    at android.os.Looper.loop(Looper.java:194)
                                                                    at android.app.ActivityThread.main(ActivityThread.java:5434)
                                                                    at java.lang.reflect.Method.invokeNative(Native Method)
                                                                    at java.lang.reflect.Method.invoke(Method.java:525)
                                                                    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:834)
                                                                    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
                                                                    at dalvik.system.NativeStart.main(Native Method)
10-17 23:03:27.732 26424-26424/marine.com.osmsample D/dalvikvm: create interp thread : stack size=128KB
10-17 23:03:27.732 26424-26424/marine.com.osmsample D/dalvikvm: create new thread
10-17 23:03:27.732 26424-26424/marine.com.osmsample D/dalvikvm: new thread created
10-17 23:03:27.732 26424-26424/marine.com.osmsample D/dalvikvm: update thread list
10-17 23:03:27.732 26424-26944/marine.com.osmsample D/dalvikvm: threadid=17: interp stack at 0x5f42b000
10-17 23:03:27.732 26424-26944/marine.com.osmsample D/dalvikvm: threadid=17: created from interp
10-17 23:03:27.732 26424-26424/marine.com.osmsample D/dalvikvm: start new thread
10-17 23:03:27.733 26424-26944/marine.com.osmsample D/dalvikvm: threadid=17: notify debugger
10-17 23:03:27.733 26424-26944/marine.com.osmsample D/dalvikvm: threadid=17 (Thread-2646): calling run()
10-17 23:03:27.733 26424-26944/marine.com.osmsample D/dalvikvm: threadid=17: exiting
10-17 23:03:27.733 26424-26944/marine.com.osmsample D/dalvikvm: threadid=17: bye!
10-17 23:03:27.739 26424-26424/marine.com.osmsample I/OsmDroid: sdcard state: mounted
10-17 23:03:27.745 26424-26424/marine.com.osmsample I/OsmDroid: sdcard state: mounted
10-17 23:03:27.746 26424-26424/marine.com.osmsample E/SQLiteLog: (14) cannot open file at line 30202 of [00bb9c9ce4]
10-17 23:03:27.746 26424-26424/marine.com.osmsample E/SQLiteLog: (14) os_unix.c:30202: (2) open(/storage/sdcard0/osmdroid/tiles/cache.db) - 
10-17 23:03:27.749 26424-26424/marine.com.osmsample E/SQLiteDatabase: Failed to open database '/storage/sdcard0/osmdroid/tiles/cache.db'.
                                                                      android.database.sqlite.SQLiteCantOpenDatabaseException: unknown error (code 14): Could not open database
                                                                          at android.database.sqlite.SQLiteConnection.nativeOpen(Native Method)
                                                                          at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:209)
                                                                          at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:193)
                                                                          at android.database.sqlite.SQLiteConnectionPool.openConnectionLocked(SQLiteConnectionPool.java:463)
                                                                          at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:185)
                                                                          at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:177)
                                                                          at android.database.sqlite.SQLiteDatabase.openInner(SQLiteDatabase.java:804)
                                                                          at android.database.sqlite.SQLiteDatabase.open(SQLiteDatabase.java:789)
                                                                          at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:694)
                                                                          at android.database.sqlite.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase.java:709)
                                                                          at android.database.sqlite.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase.java:702)
                                                                          at org.osmdroid.tileprovider.modules.SqlTileWriter.<init>(SqlTileWriter.java:44)
                                                                          at org.osmdroid.tileprovider.modules.MapTileSqlCacheProvider.<init>(MapTileSqlCacheProvider.java:57)
                                                                          at org.osmdroid.tileprovider.modules.MapTileSqlCacheProvider.<init>(MapTileSqlCacheProvider.java:63)
                                                                          at org.osmdroid.tileprovider.MapTileProviderBasic.<init>(MapTileProviderBasic.java:88)
                                                                          at org.osmdroid.tileprovider.MapTileProviderBasic.<init>(MapTileProviderBasic.java:50)
                                                                          at org.osmdroid.views.MapView.<init>(MapView.java:170)
                                                                          at org.osmdroid.views.MapView.<init>(MapView.java:200)
                                                                          at java.lang.reflect.Constructor.constructNative(Native Method)
                                                                          at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
                                                                          at android.view.LayoutInflater.createView(LayoutInflater.java:587)
                                                                          at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:687)
                                                                          at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
                                                                          at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
                                                                          at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
                                                                          at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
                                                                          at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:285)
                                                                          at android.app.Activity.setContentView(Activity.java:1882)
                                                                          at marine.com.osmsample.MainActivity.onCreate(MainActivity.java:55)
                                                                          at android.app.Activity.performCreate(Activity.java:5121)
                                                                          at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1146)
                                                                          at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2358)
                                                                          at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2446)
                                                                          at android.app.ActivityThread.access$600(ActivityThread.java:165)
                                                                          at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1373)
                                                                          at android.os.Handler.dispatchMessage(Handler.java:107)
                                                                          at android.os.Looper.loop(Looper.java:194)
                                                                          at android.app.ActivityThread.main(ActivityThread.java:5434)
                                                                          at java.lang.reflect.Method.invokeNative(Native Method)
                                                                          at java.lang.reflect.Method.invoke(Method.java:525)
                                                                          at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:834)
                                                                          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
                                                                          at dalvik.system.NativeStart.main(Native Method)
10-17 23:03:27.753 26424-26424/marine.com.osmsample E/OsmDroid: Unable to start the sqlite tile writer. Check external storage availability.
                                                                android.database.sqlite.SQLiteCantOpenDatabaseException: unknown error (code 14): Could not open database
                                                                    at android.database.sqlite.SQLiteConnection.nativeOpen(Native Method)
                                                                    at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:209)
                                                                    at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:193)
                                                                    at android.database.sqlite.SQLiteConnectionPool.openConnectionLocked(SQLiteConnectionPool.java:463)
                                                                    at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:185)
                                                                    at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:177)
                                                                    at android.database.sqlite.SQLiteDatabase.openInner(SQLiteDatabase.java:804)
                                                                    at android.database.sqlite.SQLiteDatabase.open(SQLiteDatabase.java:789)
                                                                    at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:694)
                                                                    at android.database.sqlite.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase.java:709)
                                                                    at android.database.sqlite.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase.java:702)
                                                                    at org.osmdroid.tileprovider.modules.SqlTileWriter.<init>(SqlTileWriter.java:44)
                                                                    at org.osmdroid.tileprovider.modules.MapTileSqlCacheProvider.<init>(MapTileSqlCacheProvider.java:57)
                                                                    at org.osmdroid.tileprovider.modules.MapTileSqlCacheProvider.<init>(MapTileSqlCacheProvider.java:63)
                                                                    at org.osmdroid.tileprovider.MapTileProviderBasic.<init>(MapTileProviderBasic.java:88)
                                                                    at org.osmdroid.tileprovider.MapTileProviderBasic.<init>(MapTileProviderBasic.java:50)
                                                                    at org.osmdroid.views.MapView.<init>(MapView.java:170)
                                                                    at org.osmdroid.views.MapView.<init>(MapView.java:200)
                                                                    at java.lang.reflect.Constructor.constructNative(Native Method)
                                                                    at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
                                                                    at android.view.LayoutInflater.createView(LayoutInflater.java:587)
                                                                    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:687)
                                                                    at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
                                                                    at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
                                                                    at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
                                                                    at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
                                                                    at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:285)
                                                                    at android.app.Activity.setContentView(Activity.java:1882)
                                                                    at marine.com.osmsample.MainActivity.onCreate(MainActivity.java:55)
                                                                    at android.app.Activity.performCreate(Activity.java:5121)
                                                                    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1146)
                                                                    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2358)
                                                                    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2446)
                                                                    at android.app.ActivityThread.access$600(ActivityThread.java:165)
                                                                    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1373)
                                                                    at android.os.Handler.dispatchMessage(Handler.java:107)
                                                                    at android.os.Looper.loop(Looper.java:194)
                                                                    at android.app.ActivityThread.main(ActivityThread.java:5434)
                                                                    at java.lang.reflect.Method.invokeNative(Native Method)
                                                                    at java.lang.reflect.Method.invoke(Method.java:525)
                                                                    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:834)
                                                                    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
                                                                    at dalvik.system.NativeStart.main(Native Method)  
10-17 23:03:39.774 26424-27015/marine.com.osmsample D/OsmDroid: Unable to store cached tile from Mapnik /14/9291/6359, database not available.
10-17 23:03:39.792 26424-27015/marine.com.osmsample I/System.out: [CDS]rx timeout:0
10-17 23:03:39.819 26424-27003/marine.com.osmsample D/OsmDroid: Unable to store cached tile from Mapnik /14/9292/6359, database not available.
10-17 23:03:39.823 26424-27003/marine.com.osmsample I/System.out: [CDS]rx timeout:0
10-17 23:03:39.846 26424-27015/marine.com.osmsample D/OsmDroid: Unable to store cached tile from Mapnik /14/9290/6359, database not available.
10-17 23:03:39.852 26424-27015/marine.com.osmsample I/System.out: [CDS]rx timeout:0
Molding answered 18/10, 2016 at 5:18 Comment(1)
Just based on the error log I would say either you have run out of microSD card space - perhaps even during install. Clear out space on microSD card and then delete and install your app. Also try using a different microSD card.Harbird
T
6

What API level is the device? It could be a permissions issues. Sometimes android also mounts Environment.getExternalStorageDir() as read only, which is wrong. One of these days I'm going to fix this with a work around.

Does the example application provided by osmdroid work? Not only do you have to start it, you have to zoom in a bit. The sample app comes with a few cached tiles.

Looking at the stack trace, Environment.getExternalStorageDir() is returning a read only mount point. So the only reasonable solution would be to tell osmdroid to use a different location for the cache on that type of device. It can be done easily but it must be BEFORE the mapview is created. This link has the API calls to make with osmdroid

Using osmdroid without getting access to external storage

This answer https://mcmap.net/q/125227/-find-location-of-a-removable-sd-card has some great code to return a list of mount points/paths that are writable. It might be a good idea to prompt the user to ask where to store the cache

Edit: Added in osmdroid 5.6, the workaround i discussed was added, along with a samples in the samples app "Open Map" that shows you how to use it. Default cache location with osmdroid 5.6 and up is the largest writable storage partition. This will then be saved as a preference (again see the sample app)

Tatia answered 18/10, 2016 at 22:25 Comment(6)
the example application we downloaded from play store works fine, but when i follow the tutorial and make my own app, it doesn't. The device is api 19(Android 4.4)Molding
can you please take a look at another query i posted regarding compass, i need help, thanks!Molding
i just updated osmdroid to include a similar function along with examples on how to control itTatia
i have tried the solution which you have merged into osmdriod github, still maps not showing on alcatel, here is screenshots of the folder created after adding the new code form solution on github screenshot1,screenshot2, screenshot3Molding
does the app have internet connectivity? is it api23 with permissions granted?Tatia
https://mcmap.net/q/268910/-android-database-sqlite-sqlitecantopendatabaseexception-unknown-error-code-14-could-not-open-database think that could fix it? I'm really not sureTatia
C
2

If you have already asked for permission and still weren't able to show map, Here's how I was able to fix it, from this answer

val osmConfig = Configuration.getInstance()
osmConfig.userAgentValue = packageName
val basePath = File(cacheDir.absolutePath, "osmdroid")
osmConfig.osmdroidBasePath = basePath
val tileCache  = File(osmConfig.osmdroidBasePath, "tile")
osmConfig.osmdroidTileCache = tileCache
Chalk answered 8/6, 2019 at 9:51 Comment(0)
J
1

Guys android 6 given new way assigning permission of external storage so i have given:

ActivityCompat.requestPermissions(LoginActivity.this,
 new String[{Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.ACCESS_FINE_LOCATION}, 1);

or else goto

settings->Applications->Application Manager->choose your app->permission

and on permissions so that problem will solve.

Jointworm answered 2/6, 2018 at 13:51 Comment(0)
V
0

For kotlin

ActivityCompat.requestPermissions(this,
 arrayOf(Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.ACCESS_FINE_LOCATION), 1)

Vuong answered 17/5, 2019 at 15:4 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.