5

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)
buzzer
  • 51
  • 3
  • `the app crashes, without any information.` – a_local_nobody Jan 25 '21 at 09:29
  • 1
    Does this answer your question? [Unfortunately MyApp has stopped. How can I solve this?](https://stackoverflow.com/questions/23353173/unfortunately-myapp-has-stopped-how-can-i-solve-this) – a_local_nobody Jan 25 '21 at 09:29
  • Thanks mate, one step forward :) No i am at "java.lang.Exception: Error loading sqlite libraries". I am looking at it. – buzzer Jan 25 '21 at 09:47
  • I don't wanted to be rude, sorry for that. I only wasn't clever enough to understand your help, but i was after reading the first letters of the page, that's why i wrote "Oh no, ok, i read this". This means "Sorry mate, now i understand, what you wanted to say to me, thank you!". – buzzer Jan 25 '21 at 09:50
  • no worries :) stack overflow gets a bad reputation at times that people are rude here (which can true) but i never have any intentions of being rude, so my post was meant to help. you should get your stacktrace and add it into your question by using [edit](https://stackoverflow.com/review/suggested-edits/28160814), i have no experience with this technology so i can't help you further than that – a_local_nobody Jan 25 '21 at 09:52

3 Answers3

3

This looks like issue 116 https://github.com/mozilla/geckoview/issues/116

Go to your manifest and add this under the application area:

android:extractNativeLibs="true"
DAG
  • 867
  • 10
  • 16
0

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:

-keep class org.mozilla.** {*;}

Maybe that's not the best way, but I haven't found a better solution.

M_droid
  • 2,447
  • 2
  • 25
  • 35
0

I added android:extractNativeLibs="true" to the manifest, and according to this comment, I also added:

android.bundle.enableUncompressedNativeLibs=false

to gradle.properties, which fixed my issue locally. I don't know what will happen when I upload to Google Play.

Raslanove
  • 649
  • 9
  • 16