Im very novice at java programming. Running into an error message while trying to make a browser using locally stored GECKOVIEW library. The build does complete but the app crashes. Help would be greatly appreciated because i'm very stuck and it's proven difficult to find information about problems arising with GeckoView.
Error message:
FATAL EXCEPTION: main Process: com.example.browser, PID: 12465
java.lang.NoClassDefFoundError: Failed resolution of:
Lorg/yaml/snakeyaml /constructor/Constructor;**strong text**
Caused by: java.lang.ClassNotFoundException: Didn't find class
"org.yaml.snakeyaml.constructor.Constructor" on path: DexPathList[[zip file
"/data/app/com.example.browser-REepjBL5JVM2lFFcNMNHJA==
/base.apk"],nativeLibraryDirectories=[/data/app/com.example.browser-
REepjBL5JVM2lFFcNMNHJA==/lib/arm64, /data/app/com.example.browser-
REepjBL5JVM2lFFcNMNHJA==/base.apk!/lib/arm64-v8a, /system/lib64, /product /lib64]]
(Full error message at the bottom)
Build Gradle:APP:
apply plugin: 'com.android.application'
android {
compileSdkVersion 29
buildToolsVersion "29.0.3"
defaultConfig {
applicationId "com.example.browser"
minSdkVersion 29
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation(name:'gclib',ext:'aar')
}
The GeckoView library was copy pasted into the projects library folder.
Build Gradle Project:
// Top-level build file where you can add configuration options common to
all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.6.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
flatDir{
dirs 'libs'
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
MAIN ACTIVITY:
public class MainActivity extends AppCompatActivity {
private GeckoView geckoview;
private GeckoSession geckoSession;
private GeckoRuntime geckoRuntime;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
geckoview = findViewById(R.id.geckoView);
geckoSession = new GeckoSession();
geckoSession.getSettings().setUseTrackingProtection(true);
geckoSession.getSettings().getUsePrivateMode();
geckoSession.getSettings().setUserAgentMode(0);
GeckoRuntimeSettings.Builder builder = new GeckoRuntimeSettings.Builder()
.aboutConfigEnabled(true)
.useMultiprocess(false)
.forceUserScalableEnabled(true)
.javaScriptEnabled(true);
geckoRuntime = GeckoRuntime.create(MainActivity.this,builder.build());
geckoSession.open(geckoRuntime);
geckoview.setSession(geckoSession);
geckoSession.loadUri("Https://duckduckgo.com");
}
}
The complete error message:
2020-04-25 01:11:44.403 12465-12465/com.example.browser E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.browser, PID: 12465
java.lang.NoClassDefFoundError: Failed resolution of: Lorg/yaml/snakeyaml/constructor/Constructor;
at org.mozilla.gecko.util.DebugConfig.fromFile(DebugConfig.java:40)
at org.mozilla.geckoview.GeckoRuntime.init(GeckoRuntime.java:362)
at org.mozilla.geckoview.GeckoRuntime.create(GeckoRuntime.java:546)
at com.example.browser.MainActivity.onCreate(MainActivity.java:32)
at android.app.Activity.performCreate(Activity.java:7955)
at android.app.Activity.performCreate(Activity.java:7944)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1307)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3423)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3595)
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:2147)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:237)
at android.app.ActivityThread.main(ActivityThread.java:7814)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1047)
Caused by: java.lang.ClassNotFoundException: Didn't find class
"org.yaml.snakeyaml.constructor.Constructor" on path: DexPathList[[zip file
"/data/app/com.example.browser-REepjBL5JVM2lFFcNMNHJA==
/base.apk"],nativeLibraryDirectories=[/data/app/com.example.browser-
REepjBL5JVM2lFFcNMNHJA==/lib/arm64, /data/app/com.example.browser-
REepjBL5JVM2lFFcNMNHJA==/base.apk!/lib/arm64-v8a, /system/lib64, /product
/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:196)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at org.mozilla.gecko.util.DebugConfig.fromFile(DebugConfig.java:40)
at org.mozilla.geckoview.GeckoRuntime.init(GeckoRuntime.java:362)
at org.mozilla.geckoview.GeckoRuntime.create(GeckoRuntime.java:546)
at com.example.browser.MainActivity.onCreate(MainActivity.java:32)
at android.app.Activity.performCreate(Activity.java:7955)
at android.app.Activity.performCreate(Activity.java:7944)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1307)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3423)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3595)
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:2147)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:237)
at android.app.ActivityThread.main(ActivityThread.java:7814)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1047)
2020-04-25 01:11:44.420 12465-12465/com.example.browser I/Process: Sending signal. PID: 12465 SIG: 9
Issues Resolved.
Bij adding the mentioned dependencies in the geckoview pom file to the dependencies block in build gradle app, the original problem was fixed.
A new problem arose when sqlite libraries failed to load. Apparently the new version of android studio defaults to extractnativelibs=false. By adding android:extractNativeLibs="true" to the androidmanifest.xml the issue was solved.