Android: no `com.wix.detox.config` package

See original GitHub issue

Describe the bug Hi, I’m having trouble setting up Detox with a brand new RN project (bootstrapped with npx react-native init example).

I’ve created a minimal example: https://github.com/Tommos0/detox-example . After setting up the new project and following the Detox docs, when I try to build:

$ ./gradlew assembleDebug assembleAndroidTest -DtestBuildType=debug

> Task :app:stripDebugDebugSymbols UP-TO-DATE
Compatible side by side NDK version was not found.

> Task :app:compileDebugAndroidTestJavaWithJavac FAILED
/p/example/android/app/src/androidTest/java/com/example/DetoxTest.java:5: error: package com.wix.detox.config does not exist
import com.wix.detox.config.DetoxConfig;
                           ^
/p/example/android/app/src/androidTest/java/com/example/DetoxTest.java:25: error: cannot find symbol
        DetoxConfig detoxConfig = new DetoxConfig();
        ^
  symbol:   class DetoxConfig
  location: class DetoxTest
/p/example/android/app/src/androidTest/java/com/example/DetoxTest.java:25: error: cannot find symbol
        DetoxConfig detoxConfig = new DetoxConfig();
                                      ^
  symbol:   class DetoxConfig
  location: class DetoxTest
3 errors

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:compileDebugAndroidTestJavaWithJavac'.
> Compilation failed; see the compiler error output for details.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.2/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 1s
36 actionable tasks: 2 executed, 34 up-to-date

To Reproduce

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

Steps to reproduce:

  1. npx react-native init example
  2. yarn add detox
  3. follow steps at https://github.com/wix/Detox/blob/master/docs/Introduction.Android.md
  4. ./gradlew assembleDebug assembleAndroidTest -DtestBuildType=debug

Expected behavior It should build

Environment (please complete the following information):

  • Detox: 17.3.1
  • React Native: 0.63.2
  • Java: openjdk version “1.8.0_252”
  • OS: Linux Manjaro

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:11

github_iconTop GitHub Comments

3reactions
whalemarecommented, Sep 7, 2021

In my case, I should change order in build.gradle for searching Detox lib localy and after that in other places. So my config looks like that:

allprojects {
    repositories {
        mavenLocal()
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url("$rootDir/../node_modules/react-native/android")
        }
        maven {
            // Android JSC is installed from npm
            url("$rootDir/../node_modules/jsc-android/dist")
        }
        
        // Detox
        maven {
          url "$rootDir/../node_modules/detox/Detox-android"
        }

        google()
        jcenter()
        maven { url 'https://www.jitpack.io' }
    }
}
2reactions
Tommos0commented, Jul 29, 2020

Recipe to reproduce:

docker run -it ubuntu:20.04

apt-get update
DEBIAN_FRONTEND=noninteractive apt-get install -y git openjdk-8-jdk nodejs npm wget unzip

mkdir -p /opt/android-sdk/cmdline-tools
cd $_
wget https://dl.google.com/android/repository/commandlinetools-linux-6609375_latest.zip
unzip commandlinetools-linux-6609375_latest.zip
export ANDROID_HOME=/opt/android-sdk
export PATH=/opt/android-sdk/cmdline-tools/tools/bin:$PATH
yes | sdkmanager "build-tools;30.0.1"

cd /root
git clone https://github.com/wix/Detox.git --depth=1
cd Detox/examples/demo-react-native
npm install
npm install -g detox-cli

detox build --configuration android.emu.debug

Result:

> Task :app:compileDebugAndroidTestJavaWithJavac FAILED
/root/Detox/examples/demo-react-native/android/app/src/androidTest/java/com/example/DetoxTest.java:5: error: package com.wix.detox.config does not exist
import com.wix.detox.config.DetoxConfig;
                           ^
/root/Detox/examples/demo-react-native/android/app/src/androidTest/java/com/example/DetoxTest.java:25: error: cannot find symbol
        DetoxConfig detoxConfig = new DetoxConfig();
        ^
  symbol:   class DetoxConfig
  location: class DetoxTest
/root/Detox/examples/demo-react-native/android/app/src/androidTest/java/com/example/DetoxTest.java:25: error: cannot find symbol
        DetoxConfig detoxConfig = new DetoxConfig();
                                      ^
  symbol:   class DetoxConfig
  location: class DetoxTest
3 errors
Read more comments on GitHub >

github_iconTop Results From Across the Web

Dealing With Problems With Building the App & Detox
This page is about issues related to building the app, typically triggered when running detox build (and not detox test, for example).
Read more >
Could not find any matches for com.wix:detox:+ - Stack Overflow
Have you tried adding this to android/build.gradle? // Note: add the 'allproject' section if it doesn't exist allprojects { repositories ...
Read more >
React Native development tools - Part 3: Testing tools - Pusher
In this part, look at testing with Jest and Detox. Configure Sublime Text Editor for debugging, and write tests for a sample app....
Read more >
Detox - NativeScript Docs
Configure Detox #. Detox must be configued to know the location of the iOS and Android app binary as well as what emulator/simulator...
Read more >
Setting Up Detox - ReactNativeTesting.io
First, let's install the global Detox CLI tool: $ xcode-select --install $ brew tap wix/brew $ brew install applesimutils $ npm install -g...
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