question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] Android Studio Project crashes after adding library dependency

See original GitHub issue

Hi! Im trying to use the library in an Android project. As suggested here https://github.com/skrapeit/skrape.it/issues/89 I added this to my build.gradle to avoid having problems with the methods containing space in its names and so.

repositories {
    maven { url "https://jitpack.io" }
}
dependencies {
      testImplementation("com.github.skrapeit:skrape.it:master-SNAPSHOT")
}

And I was able to run this Unit Test successfully

import it.skrape.core.htmlDocument
import it.skrape.matchers.toBe
import it.skrape.matchers.toContain
import it.skrape.selects.html5.h1
import it.skrape.selects.html5.p
import org.junit.Test

import org.junit.Assert.*

/**
 * Example local unit test, which will execute on the development machine (host).
 *
 * See [testing documentation](http://d.android.com/tools/testing).
 */
class ExampleUnitTest {

    @Test
    internal fun `can read and return html from String`() {
        htmlDocument(
            """
        <html>
            <body>
                <h1>welcome</h1>
                <div>
                    <p>first p-element</p>
                    <p class="foo">some p-element</p>
                    <p class="foo">last p-element</p>
                </div>
            </body>
        </html>"""
        ) {

            h1 {
                findFirst {
                    text toBe "welcome"
                }
            }
            p {
                withClass = "foo"
                findFirst {
                    text toBe "some p-element"
                    className toBe "foo"
                }
            }
            p {
                findAll {
                    this@htmlDocument.text toContain "p-element"
                }
                findLast {
                    text toBe "last p-element"
                }
            }

        }
    }
}

image

No problem so far, I guess because the Unit Tests run inside JVM.

After that I tried to add the dependency to use it from my Android Project adding this to my build.gradle

implementation("com.github.skrapeit:skrape.it:master-SNAPSHOT")

And received this error:

More than one file was found with OS independent path ‘META-INF/DEPENDENCIES’

After a little google search I found this to be the possible solution, so I added this to my build.gradle

android {
    packagingOptions {
        pickFirst "META-INF/DEPENDENCIES"
    }
}

After adding that Im gettin more errors, so I think this might not be the solution Here is the StackTrace when I try to run the app

2020-05-19 01:26:30.841 14644-14644/? I/webscrappertes: Late-enabling -Xcheck:jni
2020-05-19 01:26:30.879 14644-14644/? E/webscrappertes: Unknown bits set in runtime_flags: 0x8000
2020-05-19 01:26:31.299 14644-14644/? W/webscrappertes: Bad encoded_array value: Failure to verify dex file '/data/app/cu.neosoft.webscrappertest-hy3VhMUfmFw2eV1pLwg5LQ==/base.apk': Bad encoded_value method type size 7
2020-05-19 01:26:31.306 14644-14644/? E/LoadedApk: Unable to instantiate appComponentFactory
    java.lang.ClassNotFoundException: Didn't find class "androidx.core.app.CoreComponentFactory" on path: DexPathList[[zip file "/data/app/cu.neosoft.webscrappertest-hy3VhMUfmFw2eV1pLwg5LQ==/base.apk"],nativeLibraryDirectories=[/data/app/cu.neosoft.webscrappertest-hy3VhMUfmFw2eV1pLwg5LQ==/lib/arm64, /system/lib64, /vendor/lib64, /system/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 android.app.LoadedApk.createAppFactory(LoadedApk.java:256)
        at android.app.LoadedApk.createOrUpdateClassLoaderLocked(LoadedApk.java:855)
        at android.app.LoadedApk.getClassLoader(LoadedApk.java:950)
        at android.app.LoadedApk.getResources(LoadedApk.java:1188)
        at android.app.ContextImpl.createAppContext(ContextImpl.java:2462)
        at android.app.ContextImpl.createAppContext(ContextImpl.java:2454)
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6353)
        at android.app.ActivityThread.access$1300(ActivityThread.java:220)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1860)
        at android.os.Handler.dispatchMessage(Handler.java:107)
        at android.os.Looper.loop(Looper.java:214)
        at android.app.ActivityThread.main(ActivityThread.java:7397)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:935)
    	Suppressed: java.io.IOException: Failed to open dex files from /data/app/cu.neosoft.webscrappertest-hy3VhMUfmFw2eV1pLwg5LQ==/base.apk because: Bad encoded_array value: Failure to verify dex file '/data/app/cu.neosoft.webscrappertest-hy3VhMUfmFw2eV1pLwg5LQ==/base.apk': Bad encoded_value method type size 7
        at dalvik.system.DexFile.openDexFileNative(Native Method)
        at dalvik.system.DexFile.openDexFile(DexFile.java:365)
        at dalvik.system.DexFile.<init>(DexFile.java:107)
        at dalvik.system.DexFile.<init>(DexFile.java:80)
        at dalvik.system.DexPathList.loadDexFile(DexPathList.java:444)
        at dalvik.system.DexPathList.makeDexElements(DexPathList.java:403)
        at dalvik.system.DexPathList.<init>(DexPathList.java:164)
        at dalvik.system.BaseDexClassLoader.<init>(BaseDexClassLoader.java:126)
        at dalvik.system.BaseDexClassLoader.<init>(BaseDexClassLoader.java:101)
        at dalvik.system.PathClassLoader.<init>(PathClassLoader.java:74)
        at com.android.internal.os.ClassLoaderFactory.createClassLoader(ClassLoaderFactory.java:87)
        at com.android.internal.os.ClassLoaderFactory.createClassLoader(ClassLoaderFactory.java:116)
        at android.app.ApplicationLoaders.getClassLoader(ApplicationLoaders.java:114)
        at android.app.ApplicationLoaders.getClassLoaderWithSharedLibraries(ApplicationLoaders.java:60)
        at android.app.LoadedApk.createOrUpdateClassLoaderLocked(LoadedApk.java:851)
        		... 13 more
2020-05-19 01:26:31.330 14644-14644/? I/Perf: Connecting to perf service.
2020-05-19 01:26:31.342 14644-14679/? E/Perf: Fail to get file list cu.neosoft.webscrappertest
2020-05-19 01:26:31.342 14644-14679/? E/Perf: getFolderSize() : Exception_1 = java.lang.NullPointerException: Attempt to get length of null array
2020-05-19 01:26:31.342 14644-14679/? E/Perf: Fail to get file list cu.neosoft.webscrappertest
2020-05-19 01:26:31.343 14644-14679/? E/Perf: getFolderSize() : Exception_1 = java.lang.NullPointerException: Attempt to get length of null array
2020-05-19 01:26:31.396 14644-14644/? D/AndroidRuntime: Shutting down VM
    
    
    --------- beginning of crash
2020-05-19 01:26:31.400 14644-14644/? E/AndroidRuntime: FATAL EXCEPTION: main
    Process: cu.neosoft.webscrappertest, PID: 14644
    java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{cu.neosoft.webscrappertest/cu.neosoft.webscrappertest.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "cu.neosoft.webscrappertest.MainActivity" on path: DexPathList[[zip file "/data/app/cu.neosoft.webscrappertest-hy3VhMUfmFw2eV1pLwg5LQ==/base.apk"],nativeLibraryDirectories=[/data/app/cu.neosoft.webscrappertest-hy3VhMUfmFw2eV1pLwg5LQ==/lib/arm64, /system/lib64, /vendor/lib64, /system/product/lib64]]
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3195)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3410)
        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:2017)
        at android.os.Handler.dispatchMessage(Handler.java:107)
        at android.os.Looper.loop(Looper.java:214)
        at android.app.ActivityThread.main(ActivityThread.java:7397)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:935)
     Caused by: java.lang.ClassNotFoundException: Didn't find class "cu.neosoft.webscrappertest.MainActivity" on path: DexPathList[[zip file "/data/app/cu.neosoft.webscrappertest-hy3VhMUfmFw2eV1pLwg5LQ==/base.apk"],nativeLibraryDirectories=[/data/app/cu.neosoft.webscrappertest-hy3VhMUfmFw2eV1pLwg5LQ==/lib/arm64, /system/lib64, /vendor/lib64, /system/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 android.app.AppComponentFactory.instantiateActivity(AppComponentFactory.java:95)
        at android.app.Instrumentation.newActivity(Instrumentation.java:1251)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3183)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3410) 
        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:2017) 
        at android.os.Handler.dispatchMessage(Handler.java:107) 
        at android.os.Looper.loop(Looper.java:214) 
        at android.app.ActivityThread.main(ActivityThread.java:7397) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:935) 
    	Suppressed: java.io.IOException: Failed to open dex files from /data/app/cu.neosoft.webscrappertest-hy3VhMUfmFw2eV1pLwg5LQ==/base.apk because: Bad encoded_array value: Failure to verify dex file '/data/app/cu.neosoft.webscrappertest-hy3VhMUfmFw2eV1pLwg5LQ==/base.apk': Bad encoded_value method type size 7
        at dalvik.system.DexFile.openDexFileNative(Native Method)
        at dalvik.system.DexFile.openDexFile(DexFile.java:365)
        at dalvik.system.DexFile.<init>(DexFile.java:107)
        at dalvik.system.DexFile.<init>(DexFile.java:80)
        at dalvik.system.DexPathList.loadDexFile(DexPathList.java:444)
        at dalvik.system.DexPathList.makeDexElements(DexPathList.java:403)
        at dalvik.system.DexPathList.<init>(DexPathList.java:164)
        at dalvik.system.BaseDexClassLoader.<init>(BaseDexClassLoader.java:126)
        at dalvik.system.BaseDexClassLoader.<init>(BaseDexClassLoader.java:101)
        at dalvik.system.PathClassLoader.<init>(PathClassLoader.java:74)
        at com.android.internal.os.ClassLoaderFactory.createClassLoader(ClassLoaderFactory.java:87)
        at com.android.internal.os.ClassLoaderFactory.createClassLoader(ClassLoaderFactory.java:116)
        at android.app.ApplicationLoaders.getClassLoader(ApplicationLoaders.java:114)
        at android.app.ApplicationLoaders.getClassLoaderWithSharedLibraries(ApplicationLoaders.java:60)
        at android.app.LoadedApk.createOrUpdateClassLoaderLocked(LoadedApk.java:851)
        at android.app.LoadedApk.getClassLoader(LoadedApk.java:950)
        at android.app.LoadedApk.getResources(LoadedApk.java:1188)
        at android.app.ContextImpl.createAppContext(ContextImpl.java:2462)
        at android.app.ContextImpl.createAppContext(ContextImpl.java:2454)
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6353)
2020-05-19 01:26:31.400 14644-14644/? E/AndroidRuntime:     at android.app.ActivityThread.access$1300(ActivityThread.java:220)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1860)
        		... 6 more

If there is any need for more info I’ll be happy to provide it. Thanks in advance !

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:14 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
christian-draegercommented, Oct 9, 2020

Thx to @faogustavo and we have a working android example over here: https://github.com/skrapeit/skrape-android-sample

1reaction
nolomancommented, Sep 1, 2020

i just kicked all functions that contains spaces in its names in commit ecbec25 since i’am not into android development, could someone please verify if it helped to avoid the errors regarding dex?

the version including the change is available via jitpack:

repositories {
    jcenter()
    maven {
        url = uri("https://jitpack.io")
    }
}

implementation("com.github.skrapeit:skrape.it:ecbec25908")

if it hopefully helped i will release it to maven central as well Hi,

Unfortunately I still get an error here:

Execution failed for task ':app:mergeExtDexDebug'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
   > Failed to transform jetty-util-9.4.30.v20200611.jar (org.eclipse.jetty:jetty-util:9.4.30.v20200611) to match attributes {artifactType=android-dex, dexing-enable-desugaring=true, dexing-incremental-transform=false, dexing-is-debuggable=true, dexing-min-sdk=21, org.gradle.category=library, org.gradle.libraryelements=jar, org.gradle.status=release, org.gradle.usage=java-runtime}.
      > Execution failed for DexingWithClasspathTransform: /Users/myuser/.gradle/caches/modules-2/files-2.1/org.eclipse.jetty/jetty-util/9.4.30.v20200611/39ec6aa4745952077f5407cb1394d8ba2db88b13/jetty-util-9.4.30.v20200611.jar.
         > Error while dexing.

I thought it could be some dependency, and it is actually the skrape{it} library. This is the output when running ./gradlew app:dependencies:

+--- com.github.skrapeit:skrape.it:ecbec25908
|    +--- org.jsoup:jsoup:1.13.1
|    +--- net.sourceforge.htmlunit:htmlunit:2.42.0
|    |    +--- xalan:xalan:2.7.2
|    |    |    \--- xalan:serializer:2.7.2
|    |    +--- org.apache.commons:commons-lang3:3.10
|    |    +--- org.apache.commons:commons-text:1.8
|    |    +--- org.apache.httpcomponents:httpmime:4.5.12
|    |    |    \--- org.apache.httpcomponents:httpclient:4.5.12
|    |    |         +--- org.apache.httpcomponents:httpcore:4.4.13
|    |    |         +--- commons-logging:commons-logging:1.2
|    |    |         \--- commons-codec:commons-codec:1.11
|    |    +--- net.sourceforge.htmlunit:htmlunit-core-js:2.42.0
|    |    +--- net.sourceforge.htmlunit:neko-htmlunit:2.42.0
|    |    |    \--- xerces:xercesImpl:2.12.0
|    |    |         \--- xml-apis:xml-apis:1.4.01
|    |    +--- net.sourceforge.htmlunit:htmlunit-cssparser:1.5.0
|    |    +--- commons-io:commons-io:2.7
|    |    +--- commons-logging:commons-logging:1.2
|    |    +--- commons-net:commons-net:3.6
|    |    +--- org.brotli:dec:0.1.2
|    |    +--- com.shapesecurity:salvation:2.7.2
|    |    \--- org.eclipse.jetty.websocket:websocket-client:9.4.30.v20200611
|    |         +--- org.eclipse.jetty:jetty-client:9.4.30.v20200611
|    |         |    +--- org.eclipse.jetty:jetty-http:9.4.30.v20200611
|    |         |    |    +--- org.eclipse.jetty:jetty-util:9.4.30.v20200611
|    |         |    |    \--- org.eclipse.jetty:jetty-io:9.4.30.v20200611
|    |         |    |         \--- org.eclipse.jetty:jetty-util:9.4.30.v20200611
|    |         |    \--- org.eclipse.jetty:jetty-io:9.4.30.v20200611 (*)
|    |         +--- org.eclipse.jetty:jetty-xml:9.4.30.v20200611
|    |         |    \--- org.eclipse.jetty:jetty-util:9.4.30.v20200611
|    |         +--- org.eclipse.jetty:jetty-util:9.4.30.v20200611
|    |         +--- org.eclipse.jetty:jetty-io:9.4.30.v20200611 (*)
|    |         \--- org.eclipse.jetty.websocket:websocket-common:9.4.30.v20200611
|    |              +--- org.eclipse.jetty.websocket:websocket-api:9.4.30.v20200611
|    |              +--- org.eclipse.jetty:jetty-util:9.4.30.v20200611
|    |              \--- org.eclipse.jetty:jetty-io:9.4.30.v20200611 (*)

You can see that jetty is a dependency of skrape{it}.

Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

App crashes due to module library dependency - Stack Overflow
I have module in Android app. This module uses the Airship library. I have imported this module in my project and used it....
Read more >
Known issues with Android Studio and Android Gradle Plugin
To fix the issue for the current project, click Run > Edit Configurations and change the default JUnit configuration to only include the...
Read more >
Bugsnag docs › Platforms › Android
The Bugsnag Android integration detects and reports crashes from uncaught ... Add the Bugsnag Gradle plugin dependency to your Project Gradle Settings in ......
Read more >
Android Studio repeatedly crashing while loading project ...
Found library resource at jar:file:/home/gero/Downloads/android-studio/lib/jna.jar!/com ... A fatal error has been detected by the Java Runtime Environment:
Read more >
Get started with Firebase Crashlytics - Google
In your module (app-level) Gradle file (usually <project>/<app-module>/build.gradle ), add the dependency for the Crashlytics Android library.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found