Closed zanechua closed 3 years ago
Okay, if I get it right — you managed to fix your problem. If so, I wonder do you have any idea how to incorporate that into Detox documentation (e.g. Troubleshooting section), or maybe you see a different way to make it helpful?
Yup. Don't have any issues using Detox with Jest 26 once I applied the proguard line to keep the kotlin classes.
I think perhaps we could have a troubleshooting section anyone who faces anything along the lines of
java.lang.ClassNotFoundException: kotlin.*
then we could suggest them by creating their own proguard rules and applying that along with the proguard rules that come with detox.
I'm looking into the option of adding these rules to Detox' application rules-set.
@zanechua Thanks for reporting this in spite of having it solved! As explained - I do wish to have this solved across the board via Detox itself. A piece of info that could help for that, is to know whether your app uses Kotlin at all (i.e. has the kotlin std-lib defined as its dependency + has the classpath defined), or that it is in fact java-only (more info).
As far as i know, we only have the classpath defined in the project like you see above in the build.gradle
that I provided.
There are only 3 references to the keyword kotlin
in the project, this is excluding node_modules.
kotlinVersion = "1.5.10"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
-keep class kotlin.** { *; }
I have nothing else in my react-native project that uses kotlin.
A cursory look at kotlin in the node_modules folder seems to be pointing mainly to detox-native
and jetifier
@zanechua please upgrade to Detox 18.18.1
and try to remove your custom minification rule - and report back (or close the issue if it just works! 🤞🏻).
Thanks for the additional info 🙏🏻
Just upgraded to 18.18.1
and unfortunately not...
Now the error has just changed to:
Native stacktrace dump: java.lang.NoClassDefFoundError: Failed resolution of: Lkotlin/jvm/internal/Lambda;
Not sure if you guys are comfortable with using the wildcard rule for kotlin instead of just the individual function calls
@d4vidi - This has worked for me, thank you.
@zanechua Truly interested in finding out what it is about your project that poses such a challenge to Detox' proguard rules files 😂 We're fairly comfortable with wildcards - I believe we could sort that out easily.
@d4vidi I would like to know too. hahaha. If I get some free time, I'll go see if I can find which package is being the annoying one but the proguard rule with wildcards will have to do for now. 😆
@zanechua I don't mind, in particular, to include all of Kotlin's internals - the overhead would be very small. It's more about being able to understand this better, obviously.
@zanechua In https://github.com/wix/Detox/pull/2909/files, I've expanded the minification exemption rule with respect to kotlin.jvm.**
. Please try again with Detox 18.20.x
🙏🏻
@zanechua Thank you man! You saved me additional hours spent wondering why my tests are failing.
@d4vidi Is it possible to describe more precisely in the docs the required changes in the configuration if someone wants to use an additional build type solution with flavors 7-proguard-minification-obfuscation or can we add the link to this issue at the end of the note Note: if your app contains flavors -- that makes things a bit trickier, but the approach can generally be adjusted to support that as well.
?
The non described changes that were crucial in my case:
In the detox config (build command):
assembleAndroidTest
-> assembleProductionReleaseE2EAndroidTest
-DtestBuildType=release
-> -DtestBuildType=releaseE2E
Additionally, if someone has enabled Hermes the following line should be added to build.gradle
file (below the releaseImplementation files(hermesPath + "hermes-release.aar")
):
releaseE2EImplementation files(hermesPath + "hermes-release.aar")
@zanechua Thank you man! You saved me additional hours spent wondering why my tests are failing.
@d4vidi Is it possible to describe more precisely in the docs the required changes in the configuration if someone wants to use an additional build type solution with flavors 7-proguard-minification-obfuscation or can we add the link to this issue at the end of the note
Note: if your app contains flavors -- that makes things a bit trickier, but the approach can generally be adjusted to support that as well.
?The non described changes that were crucial in my case: In the detox config (build command):
assembleAndroidTest
->assembleProductionReleaseE2EAndroidTest
-DtestBuildType=release
->-DtestBuildType=releaseE2E
Additionally, if someone has enabled Hermes the following line should be added to
build.gradle
file (below thereleaseImplementation files(hermesPath + "hermes-release.aar")
):releaseE2EImplementation files(hermesPath + "hermes-release.aar")
assembleProductionReleaseE2EAndroidTest
this gradle task is not found in the project. Any idea how to add this task to gradle ?
@arjun1194 that gradle task isn't something wide-spread, you probably shouldn't be looking for it in your own project. Rather, you probably need something like aseembleAndroidTest
.
Describe the bug
I don't particularly need help since I've resolved it but just opening it incase someone runs into the issue too.
Unable to launch release app via detox as app fails with:
This seems similar to https://github.com/wix/Detox/issues/1994 and the fix for me was found here by applying the
-keep class kotlin.** { *; }
proguard rule for a releaseE2E build type. I can see that one of the maintainers asked if that would help and I can confirm it does for me.Steps To Reproduce
./gradlew assembleDevReleaseE2E assembleDevReleaseE2EAndroidTest -DtestBuildType=releaseE2E
yarn detox test -c android.emu.release
build.gradle
app/build.gradle
proguard-rules-e2e.pro
Expected behavior
App to launch, tests to run and complete
Detox Trace-Logs
Device logs (adb logcat)
Screenshots
N/A
Environment (please complete the following information):
jest-circus