I already read lots of articles and howtos here and elsewhere concerning geckoview, but i didn't find any help for my problem. I integrated geckoview in my android app (as an replacement for webview). I did everything as explained in howtos, but in the moment, the activity wants to show up, the app crashes, with the error "java.lang.Exception: Error loading sqlite libraries". Could anybody help me?
build.gradle (module)
ext {
geckoviewChannel = "nightly"
geckoviewVersion = "86.0.20210124091450"
}
repositories {
maven {
url "https://maven.mozilla.org/maven2/"
}
}
activity xml
<org.mozilla.geckoview.GeckoView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/geckoview"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
activity top
import org.mozilla.geckoview.GeckoRuntime;
import org.mozilla.geckoview.GeckoSession;
import org.mozilla.geckoview.GeckoView;
activity onCreate
boolean doGecko=true;
myGeckoView = findViewById(R.id.geckoview);
if (doGecko) {
Log.d(logTag, "starting GeckoView: "+myGeckoView);
try {
if (myGeckoSession==null) {
Log.d(logTag, "myGeckoSession = new GeckoSession()");
myGeckoSession = new GeckoSession();
}
Log.d(logTag, "GeckoSession: "+myGeckoSession);
if (myGeckoRuntime==null ) {
myGeckoRuntime = GeckoRuntime.create(this);
Log.d(logTag, "created GeckoRuntime: "+myGeckoRuntime );
} else {
myGeckoRuntime = GeckoRuntime.getDefault(this);
Log.d(logTag, "getting default GeckoRuntime: "+myGeckoRuntime );
}
Log.d(logTag, "myGeckoSession.open(myGeckoRuntime)");
myGeckoSession.open(myGeckoRuntime);
Log.d(logTag, "myGeckoview.setSession(myGeckoSession)");
myGeckoView.setSession(myGeckoSession);
Log.d(logTag, "loading url");
myGeckoSession.loadUri("http://www.google.de");
} catch (Exception e) {
Log.d(logTag, "error "+e.toString() );
}
} else {
myGeckoView.setVisibility(View.INVISIBLE);
}
stack trace
2021-01-25 11:14:18.011 4815-4883/com.test.de.browseme E/GeckoLibLoad: Load sqlite start
2021-01-25 11:14:18.011 4815-4883/com.test.de.browseme E/GeckoLibLoad: Couldn't get a handle to libnss3!
2021-01-25 11:14:18.011 4815-4883/com.test.de.browseme E/GeckoLibLoad: Throw
2021-01-25 11:14:18.011 4815-4883/com.test.de.browseme E/GeckoLibLoad: Load sqlite done
2021-01-25 11:14:18.013 4815-4883/com.test.de.browseme E/AndroidRuntime: FATAL EXCEPTION: Gecko
Process: com.test.de.browseme, PID: 4815
java.lang.Exception: Error loading sqlite libraries
at org.mozilla.gecko.mozglue.GeckoLoader.loadSQLiteLibsNative(Native Method)
at org.mozilla.gecko.mozglue.GeckoLoader.loadSQLiteLibs(GeckoLoader.java:204)
at org.mozilla.gecko.GeckoThread.loadGeckoLibs(GeckoThread.java:247)
at org.mozilla.gecko.GeckoThread.initGeckoEnvironment(GeckoThread.java:267)
at org.mozilla.gecko.GeckoThread.run(GeckoThread.java:430)
In my case this crash occurred only in release mode. So I sat on this problem for a whole day until I got the idea to exclude the lib from proguard - et voila that was the problem. Proguard obfuscated parts it shouldn't obfuscate. Just add this to your
proguard-rules.pro
:Maybe that's not the best way, but I haven't found a better solution.