Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Detox Build Failed #4371

Open
1 of 2 tasks
moatasemyakhni opened this issue Feb 13, 2024 · 11 comments
Open
1 of 2 tasks

Detox Build Failed #4371

moatasemyakhni opened this issue Feb 13, 2024 · 11 comments

Comments

@moatasemyakhni
Copy link

moatasemyakhni commented Feb 13, 2024

What happened?

while running

detox build --configuration android.emu.debug

The build failed while executing with two main errors

Error One

ERROR:/Users/.../.gradle/caches/transforms-3/451c281cfc9988f536f87fdd216516b0/transformed/jetified-detox-20.18.1-runtime.jar: D8: com.android.tools.r8.internal.Jc: Sealed classes are not supported as program classes

Error Two

What went wrong:
Execution failed for task ':app:mergeExtDexDebugAndroidTest'.
Could not resolve all files for configuration ':app:debugAndroidTestRuntimeClasspath'.
Failed to transform detox-20.18.1.aar (com.wix:detox:20.18.1) to match attributes {artifactType=android-dex, asm-transformed-variant=NONE, dexing-enable-desugaring=true, dexing-enable-jacoco-instrumentation=false, dexing-is-debuggable=true, dexing-min-sdk=23, org.gradle.category=library, org.gradle.libraryelements=jar, org.gradle.status=release, org.gradle.usage=java-runtime}.

What was the expected behaviour?

To have a successful build like ios

Was it tested on latest Detox?

  • I have tested this issue on the latest Detox release and it still reproduces.

Did your test throw out a timeout?

Help us reproduce this issue!

in ./android/build.gradle

allprojects { repositories { google() maven { url("$rootDir/../node_modules/detox/Detox-android") } } }

in ./android/app/build.gradle

`dependencies {
implementation 'androidx.appcompat:appcompat:1.6.1'
// stuff

androidTestImplementation('com.wix:detox:+') {
transitive = true
exclude group: 'org.jetbrains.kotlin', module: 'kotlin-stdlib-jdk8'
// exclude module: "protobuf-lite"
}
`

in ./android/app/src/androidTest/org/my/package/DetoxText.java

`package org.my.package; // (1)

import com.wix.detox.Detox;
import com.wix.detox.config.DetoxConfig;

import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;

import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.LargeTest;
import androidx.test.rule.ActivityTestRule;

@RunWith(AndroidJUnit4.class)
@LargeTest
public class DetoxTest {
@rule // (2)
public ActivityTestRule mActivityRule = new ActivityTestRule<>(MainActivity.class, false, false);

@Test
public void runDetoxTests() {
    DetoxConfig detoxConfig = new DetoxConfig();
    detoxConfig.idlePolicyConfig.masterTimeoutSec = 90;
    detoxConfig.idlePolicyConfig.idleResourceTimeoutSec = 60;
    detoxConfig.rnContextLoadTimeoutSec = (BuildConfig.DEBUG ? 180 : 60);

    Detox.runTests(mActivityRule, detoxConfig);
    Detox.runTests(mActivityRule);
}

}`

I added the network security xml file and generally what detox wanted...

In what environment did this happen?

Detox version: ^20.18.1
React Native version: 0.71.13
Has Fabric (React Native's new rendering system) enabled: no
Node version: .node-version file is 18 and npm -v is 20.10.0
Device model: Android_10_Pixel_5_API_29
Android version: 10
Test-runner (select one): jest

Detox logs

Detox logs
I added these in .detoxrc.js and ran "detox build --configuration android.emu.debug --loglevel trace" but nothing happened

artifacts: {
    "rootDir": ".artifacts",
    "pathBuilder": "./e2e/config/pathbuilder.js",
    "plugins": {
      "instruments": {"enabled": false},
      "log": {"enabled": true},
      "uiHierarchy": "enabled",
      "screenshot": {
        "shouldTakeAutomaticSnapshots": true,
        "keepOnlyFailedTestsArtifacts": true,
        "takeWhen": {
          "testStart": false,
          "testDone": true
        }
      },
      "video": {
        "android": {
          "bitRate": 4000000
        },
        "simulator": {
          "codec": "hevc"
        }
      }
    }
  },
configurations: {
'android.emu.debug': {
      device: 'emulator',
      app: 'android.debug',
      artifacts: true
    },
}

Device logs

Device logs
I added these in .detoxrc.js and ran "detox build --configuration android.emu.debug --record-logs all" but nothing happened

artifacts: {
    "rootDir": ".artifacts",
    "pathBuilder": "./e2e/config/pathbuilder.js",
    "plugins": {
      "instruments": {"enabled": false},
      "log": {"enabled": true},
      "uiHierarchy": "enabled",
      "screenshot": {
        "shouldTakeAutomaticSnapshots": true,
        "keepOnlyFailedTestsArtifacts": true,
        "takeWhen": {
          "testStart": false,
          "testDone": true
        }
      },
      "video": {
        "android": {
          "bitRate": 4000000
        },
        "simulator": {
          "codec": "hevc"
        }
      }
    }
  },
configurations: {
'android.emu.debug': {
      device: 'emulator',
      app: 'android.debug',
      artifacts: true
    },
}

More data, please!

approaches I did in ./android/app/build.gradle file

approach1:
I am using java17 so I added these, but it did not work. So I rolled back.

compileOptions {
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}
kotlinOptions {
jvmTarget = '11'
}
kotlin {
jvmToolchain(11)
}

approach2:
I tried changing wix version in dependencies
androidTestImplementation('com.wix:detox:0.1.1') // and other versions like 0.0.0, 0.01, ...

and added this outside the dependencies
configurations.all {
resolutionStrategy {
force 'androidx.test:core:1.5.0'
}
}

but did not work
@victor-chan-groundswell

I ran into this as well... I followed this link and updated my build.gradle accordingly and it worked afterwards
image

https://stackoverflow.com/questions/73453524/what-is-causing-this-error-com-android-tools-r8-internal-nc-sealed-classes-are

@moatasemyakhni
Copy link
Author

Thanks @victor-chan-groundswell ! This made the build succeed

But unfortunately, while testing, the app kept crashing.

detox test --configuration android.emu.debug
00:38:01.629 detox[64019] B jest --config e2e/jest.config.js
FAIL e2e/starter.test.js
● Test suite failed to run

ChildProcessError: `/Users/.../Library/Android/sdk/platform-tools/adb -s emulator-5552 shell pm install -r -g -t /data/local/tmp/detox/Application.apk` failed with code 1

  at ChildProcess.<anonymous> (node_modules/child-process-promise/lib/index.js:132:23)

May I ask if it happened with you afterwards?

Copy link

stale bot commented Mar 17, 2024

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
If you believe the issue is still relevant, please test on the latest Detox and report back.

Thank you for your contributions!

For more information on bots in this repository, read this discussion.

@stale stale bot added the 🏚 stale label Mar 17, 2024
@raldred
Copy link

raldred commented Mar 22, 2024

We're getting this same building android, ios builds fine.

Detox 20.19.3
React native: 0.71.13
Android Gradle Plugin 7.3.1
Gradle: 7.5.1
Fabric: no
Node version: 18.17.1
Device model: Pixel_3a_API_31
Android version: 12
Test-runner: jest

> Could not resolve all files for configuration ':app:releaseAndroidTestRuntimeClasspath'.
   > Failed to transform detox-20.19.3.aar (com.wix:detox:20.19.3) to match attributes {artifactType=android-dex, asm-transformed-variant=NONE, dexing-enable-desugaring=true, dexing-enable-jacoco-instrumentation=false, dexing-is-debuggable=false, dexing-min-sdk=24, org.gradle.category=library, org.gradle.libraryelements=jar, org.gradle.status=release, org.gradle.usage=java-runtime}.
      > Execution failed for DexingNoClasspathTransform: /Users/residently/.gradle/caches/transforms-3/486fcf2c7e321aff2dd1c1548f3d8d02/transformed/jetified-detox-20.19.3-runtime.jar.
         > Error while dexing.

@stale stale bot removed the 🏚 stale label Mar 22, 2024
@raldred
Copy link

raldred commented Mar 22, 2024

@moatasemyakhni
Found this in the release notes for Detox 20.18.5

Replace the standard Detox dependency in your build.gradle file with the Detox Java11-compatible version:

-    androidTestImplementation('com.wix:detox:+')
+    androidTestImplementation('com.wix:detox-legacy:+')

This fixed build issues for us and test run as normal.

@moatasemyakhni
Copy link
Author

We're getting this same building android, ios builds fine.

Detox 20.19.3 React native: 0.71.13 Android Gradle Plugin 7.3.1 Gradle: 7.5.1 Fabric: no Node version: 18.17.1 Device model: Pixel_3a_API_31 Android version: 12 Test-runner: jest

> Could not resolve all files for configuration ':app:releaseAndroidTestRuntimeClasspath'.
   > Failed to transform detox-20.19.3.aar (com.wix:detox:20.19.3) to match attributes {artifactType=android-dex, asm-transformed-variant=NONE, dexing-enable-desugaring=true, dexing-enable-jacoco-instrumentation=false, dexing-is-debuggable=false, dexing-min-sdk=24, org.gradle.category=library, org.gradle.libraryelements=jar, org.gradle.status=release, org.gradle.usage=java-runtime}.
      > Execution failed for DexingNoClasspathTransform: /Users/residently/.gradle/caches/transforms-3/486fcf2c7e321aff2dd1c1548f3d8d02/transformed/jetified-detox-20.19.3-runtime.jar.
         > Error while dexing.

Hello @raldred, have you tried adding in
./android/build.geadle
inside the dependencies

dependencies { classpath("com.android.tools:r8:8.2.24") }

and add at the top level of this file

allprojects { repositories { maven { url("$rootDir/../node_modules/detox/Detox-android") } } afterEvaluate { if (it.hasProperty('android')) { android { defaultConfig { minSdkVersion 21 } } } } }

@moatasemyakhni
Copy link
Author

@moatasemyakhni Found this in the release notes for Detox 20.18.5

Replace the standard Detox dependency in your build.gradle file with the Detox Java11-compatible version:

-    androidTestImplementation('com.wix:detox:+')
+    androidTestImplementation('com.wix:detox-legacy:+')

This fixed build issues for us and test run as normal.

Thanks for the link, I was trying java 11 as a last solution. By default I have java 17. The solution provided by @victor-chan-groundswell kept me using java 17.

@nicoleRss
Copy link

nicoleRss commented May 8, 2024

Hi @moatasemyakhni , do you fix the error ?
Im facing the same error when trying to test

ChildProcessError: `/Users/.../Library/Android/sdk/platform-tools/adb -s emulator-5552 shell pm install -r -g -t /data/local/tmp/detox/Application.apk` failed with code 1

  at ChildProcess.<anonymous> (node_modules/child-process-promise/lib/index.js:132:23)

@moatasemyakhni
Copy link
Author

moatasemyakhni commented May 8, 2024

Hello @nicoleRss, turns out the binaryPath I chose runs app-arm64-v8a-debug.apk while my emulator runs app-armeabi-v7a-debug.apk. This is why it was failing. To know what your emulator cpu is, follow the below steps in the command line:

  • emulator -list-avds (this will get all your emulators)
  • emulator -avd Pixel_6_API_33 (start the emulator you have in my case its pixel 6)
  • adb devices (get the id of your running device)
  • adb -s <device_id> shell getprop ro.product.cpu.abi ( substitute <device_id> with the id you got from the latter command for example 123456)

my .detoxrc.js file have this binaryPath I was talking about.

'android.debug': {
      type: 'android.apk',
      binaryPath: 'android/app/build/outputs/apk/debug/app-armeabi-v7a-debug.apk',
      build: 'cd android ; ./gradlew assembleDebug assembleAndroidTest -DtestBuildType=debug ; cd -',
      testBinaryPath: 'android/app/build/outputs/apk/androidTest/debug/app-debug-androidTest.apk',
      reversePorts: [
        8081
      ]
    },

note: if you are using windows instead of mac. replace the ";" with "&"

@abdullahsuhaisk
Copy link

androidTestImplementation('com.wix:detox-legacy:+')

This one is solved my issue, thanks.

@aditiaprasetio
Copy link

 androidTestImplementation('com.wix:detox-legacy:+')

This work for me, thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants