skrapeit / skrape.it

A Kotlin-based testing/scraping/parsing library providing the ability to analyze and extract data from HTML (server & client-side rendered). It places particular emphasis on ease of use and a high level of readability by providing an intuitive DSL. It aims to be a testing lib, but can also be used to scrape websites in a convenient fashion.
https://docs.skrape.it
MIT License
813 stars 59 forks source link

[BUG] Error on Android: api data not showing in release version but works fine in the debug mode #216

Open CMFerrer opened 1 year ago

CMFerrer commented 1 year ago

Describe the bug I get an exception when I run my application in release mode. Here is the stacktrace: Code Sample

java.lang.ExceptionInInitializerError
    at c5.u2.a(Unknown Source:9)
    at ga.f.a(Unknown Source:2)
    at ga.n.a(Unknown Source:60)
    at i5.x2.l(Unknown Source:48)
    at ra.a.o(Unknown Source:8)
    at od.l0.run(Unknown Source:100)
    at kotlinx.coroutines.internal.f.run(Unknown Source:11)
    at kotlinx.coroutines.scheduling.j.run(Unknown Source:2)
    at kotlinx.coroutines.scheduling.a$a.run(Unknown Source:78)
Caused by: ue.b: java.lang.ClassNotFoundException: Didn't find class "org.apache.commons.logging.impl.LogFactoryImpl" on path: DexPathList[[zip file "/data/app/com.cmf.medi-DeziiMx52ejXRoEFNnQ2Pw==/base.apk"],nativeLibraryDirectories=[/data/app/com.cmf.medi-DeziiMx52ejXRoEFNnQ2Pw==/lib/arm64, /system/lib64, /hw_product/lib64, /system/product/lib64, /prets/lib64]] (Caused by java.lang.ClassNotFoundException: Didn't find class "org.apache.commons.logging.impl.LogFactoryImpl" on path: DexPathList[[zip file "/data/app/com.cmf.medi-DeziiMx52ejXRoEFNnQ2Pw==/base.apk"],nativeLibraryDirectories=[/data/app/com.cmf.medi-DeziiMx52ejXRoEFNnQ2Pw==/lib/arm64, /system/lib64, /hw_product/lib64, /system/product/lib64, /prets/lib64]])
    at ue.d.run(Unknown Source:410)
    at java.security.AccessController.doPrivileged(AccessController.java:43)
    at ue.h.j(Unknown Source:5)
    at ue.h.c(Unknown Source:839)
    at ue.h.e(Unknown Source:0)
    at y5.e0.<clinit>(Unknown Source:2)
    at c5.u2.a(Unknown Source:9) 
    at ga.f.a(Unknown Source:2) 
    at ga.n.a(Unknown Source:60) 
    at i5.x2.l(Unknown Source:48) 
    at ra.a.o(Unknown Source:8) 
    at od.l0.run(Unknown Source:100) 
    at kotlinx.coroutines.internal.f.run(Unknown Source:11) 
    at kotlinx.coroutines.scheduling.j.run(Unknown Source:2) 
    at kotlinx.coroutines.scheduling.a$a.run(Unknown Source:78) 
Caused by: java.lang.ClassNotFoundException: Didn't find class "org.apache.commons.logging.impl.LogFactoryImpl" on path: DexPathList[[zip file "/data/app/com.cmf.medi-DeziiMx52ejXRoEFNnQ2Pw==/base.apk"],nativeLibraryDirectories=[/data/app/com.cmf.medi-DeziiMx52ejXRoEFNnQ2Pw==/lib/arm64, /system/lib64, /hw_product/lib64, /system/product/lib64, /prets/lib64]]
    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:209)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
    at ue.d.run(Unknown Source:27)
    at java.security.AccessController.doPrivileged(AccessController.java:43) 
    at ue.h.j(Unknown Source:5) 
    at ue.h.c(Unknown Source:839) 
    at ue.h.e(Unknown Source:0) 
    at y5.e0.<clinit>(Unknown Source:2) 
    at c5.u2.a(Unknown Source:9) 
    at ga.f.a(Unknown Source:2) 
    at ga.n.a(Unknown Source:60) 
    at i5.x2.l(Unknown Source:48) 
    at ra.a.o(Unknown Source:8) 
    at od.l0.run(Unknown Source:100) 
    at kotlinx.coroutines.internal.f.run(Unknown Source:11) 
    at kotlinx.coroutines.scheduling.j.run(Unknown Source:2) 
    at kotlinx.coroutines.scheduling.a$a.run(Unknown Source:78) 

Expected behavior skrape works like in Android Studio debug mode

Additional context Version skrape it: 1.2.2

Sal7one commented 1 year ago

@CMFerrer Try this

https://stackoverflow.com/a/60150323/6151564

CMFerrer commented 1 year ago

No luck, I tried to test it but now I get this:

2023-03-02 09:00:20.277 14679-14679 ExampleViewModel com.chiksmedina.desaparecidosper I dj.b: The chosen LogFactory implementation does not extend LogFactory. Please check your configuration. (Caused by java.lang.ClassCastException: The application has specified that a custom LogFactory implementation should be used but Class 'org.apache.commons.logging.impl.LogFactoryImpl' cannot be converted to 'dj.i'. Please check the custom implementation. Help can be found @http://commons.apache.org/logging/troubleshooting.html.) 2023-03-02 09:00:20.278 14679-14679 ExampleViewModel com.chiksmedina.desaparecidosper I java.lang.ExceptionInInitializerError at c1.a.a(Unknown Source:9) at oe.f.a(Unknown Source:2) at oe.n.a(Unknown Source:60) at l6.v2.l(Unknown Source:60) at ze.a.t(Unknown Source:8) at xh.i0.run(Unknown Source:100) at kotlinx.coroutines.internal.f.run(Unknown Source:11) at kotlinx.coroutines.scheduling.i.run(Unknown Source:2) at kotlinx.coroutines.scheduling.a$a.run(Unknown Source:78) Caused by: dj.b: The chosen LogFactory implementation does not extend LogFactory. Please check your configuration. (Caused by java.lang.ClassCastException: The application has specified that a custom LogFactory implementation should be used but Class 'org.apache.commons.logging.impl.LogFactoryImpl' cannot be converted to 'dj.i'. Please check the custom implementation. Help can be found @http://commons.apache.org/logging/troubleshooting.html.) at dj.d.run(Unknown Source:400) at java.security.AccessController.doPrivileged(AccessController.java:43) at dj.i.j(Unknown Source:5) at dj.i.c(Unknown Source:838) at dj.i.e(Unknown Source:0) at e7.g0.(Unknown Source:2) at c1.a.a(Unknown Source:9)  at oe.f.a(Unknown Source:2)  at oe.n.a(Unknown Source:60)  at l6.v2.l(Unknown Source:60)  at ze.a.t(Unknown Source:8)  at xh.i0.run(Unknown Source:100)  at kotlinx.coroutines.internal.f.run(Unknown Source:11)  at kotlinx.coroutines.scheduling.i.run(Unknown Source:2)  at kotlinx.coroutines.scheduling.a$a.run(Unknown Source:78)  Caused by: java.lang.ClassCastException: The application has specified that a custom LogFactory implementation should be used but Class 'org.apache.commons.logging.impl.LogFactoryImpl' cannot be converted to 'dj.i'. Please check the custom implementation. Help can be found @http://commons.apache.org/logging/troubleshooting.html. at dj.d.run(Unknown Source:242) at java.security.AccessController.doPrivileged(AccessController.java:43)  at dj.i.j(Unknown Source:5)  at dj.i.c(Unknown Source:838)  at dj.i.e(Unknown Source:0)  at e7.g0.(Unknown Source:2)  at c1.a.a(Unknown Source:9)  at oe.f.a(Unknown Source:2)  at oe.n.a(Unknown Source:60)  at l6.v2.l(Unknown Source:60)  at ze.a.t(Unknown Source:8)  at xh.i0.run(Unknown Source:100)  at kotlinx.coroutines.internal.f.run(Unknown Source:11)  at kotlinx.coroutines.scheduling.i.run(Unknown Source:2)  at kotlinx.coroutines.scheduling.a$a.run(Unknown Source:78) 

christian-draeger commented 1 year ago

Hey, not sure if that is a skrapeit bug or if we can avoid an error like this coming up while using skrapeit in release mode. But if you are able to find a way I would be interested to have the fox included as part of the library or at least adding a solution to the android example / readme

Do you think this is related to #212 And #205?

Both stack traces also complaining about apache commons stuff

CMFerrer commented 1 year ago

205 works for me, i put these lines on proguard file

-keep class com.gargoylesoftware.** { *; }
-keep class javax.xml.** { *; }
-keep class net.sourceforge.htmlunit.** { *; }
-keep class netscape.** { *; }
-keep class org.apache.** { *; }
-keep class org.htmlunit.org.apache.** { *; }
-keep class org.w3c.dom.** { *; }
-keep class org.xml.sax.** { *; }
xVemu commented 9 months ago

Hey, not sure if that is a skrapeit bug or if we can avoid an error like this coming up while using skrapeit in release mode. But if you are able to find a way I would be interested to have the fox included as part of the library or at least adding a solution to the android example / readme

I think you can create a proguard file in library with lines listed by CMFerrer.