Skip to content
This repository has been archived by the owner on Jun 1, 2022. It is now read-only.

java.lang.UnsatisfiedLinkError slice-sqlite-jdbc-3.8.7 #1

Closed
thijssmudde opened this issue Jan 6, 2017 · 6 comments
Closed

java.lang.UnsatisfiedLinkError slice-sqlite-jdbc-3.8.7 #1

thijssmudde opened this issue Jan 6, 2017 · 6 comments

Comments

@thijssmudde
Copy link

thijssmudde commented Jan 6, 2017

Hi, im using the writer inside an Android App to create a new .mbtiles file in an AsyncTask class.

Here is my java code:

private class FetchData extends AsyncTask<String, Void, String> {
  private Exception exception;

  @Override
  protected String doInBackground(String... routeSelected) {
    MBTilesWriter w = null;
    String filePath = Environment.getExternalStorageDirectory().getAbsolutePath() + "/MyRoutes/" + routeSelected;
    try {
      outputFile = new File(filePath);
      w = new MBTilesWriter(outputFile);
      new File(Environment.getExternalStorageDirectory().getAbsolutePath() + "/MyRoutes").mkdirs();
    } catch (MBTilesWriteException e) {
      this.exception = e;
      System.out.println("exception: " + e);
      return "";
    }

    //Irrelevant code removed here...

    return filePath;
  }
}

It cannot instantiate a new MBTilesWriter

Full error report on windows 10 x64 bit.
http://pastebin.com/raw/fhSH8qJr

build.gradle looks as follows

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    //compile 'org.imintel:mbtiles4j:1.0.5'
    compile 'org.xerial:sqlite-jdbc:3.8.7'
    compile 'commons-io:commons-io:2.5'

mbtiles4j is actually included inside my project: see screensot. There were other problems with including it through build.gradle, so I managed to workaround it like this. The mbtilesreader works fine!

unsatisfiedlinkerror

@ghost
Copy link

ghost commented Jan 6, 2017

Hi there

I believe your issue may be with your IntelliJ setup or something specific to Android's JVM. UnsatisifiedLinkErrors are typically due to some library attempting to load a native C library and failing to find/load said C library.

See if this related error helps you: http://stackoverflow.com/questions/35792459/java-lang-unsatisfiedlinkerror-com-android-tools-fd-runtime-incrementalclassloa

@thijssmudde
Copy link
Author

@ccook thanks. I've disabled instant run in Android studio, now the error is:

couldn't find "libsqlitejdbc.so"

So like you said, a library could not be found. Do you have any resources on how to use sqllite properly in android studio?

@ghost
Copy link

ghost commented Jan 6, 2017

No problem.

According to this stackoverflow (http://stackoverflow.com/questions/27067400/using-libraries-in-android-project), you'll require the sqlite libraries specifically compiled for android. This makes some sense since the jdbc driver I'm using in this project is probably expecting x86_64 sqlite. Android c libraries are compiled using ARM architecture.

I fear that the JDBC driver in this project is hard-coded to use the x86_64 version. You may have to fork the project to allow the JDBC Driver to use SQLDroid. You'd have to modify SQLHelper (https://github.com/imintel/mbtiles4j/blob/master/src/main/java/org/imintel/mbtiles4j/SQLHelper.java).

When creating the library, I had the opposite problem (every java implementation was just a reader made specifically for android), so I never envisioned the project being used in android projects.

@thijssmudde
Copy link
Author

thijssmudde commented Jan 6, 2017

Awesome, I think I can work from here. If you'd like you can post your answer on this stackoverflow:
http://stackoverflow.com/questions/41509607/mbtileswriter-java-lang-unsatisfiedlinkerror-slice-sqlite-jdbc-3-8-7 and I'll accept it!

Thanks so much.

@thijssmudde
Copy link
Author

hi @ccook, the android implementation is here: https://github.com/fullhdpixel/mbtiles4j

If you'd like to help me make this available through build.gradle, that would be awesome. I haven't done that before

@carlos-mg89
Copy link

@fullhdpixel did you finally made the library compatible with Gradle? I was so excited to see that you had done all this work of porting the MBTiles4J library to be Android compatible, but would like to use it as a Gradle dependency.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants