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

cannot find symbol "Detox" on Android RN 0.70 #3973

Closed
1 of 2 tasks
arcln opened this issue Mar 7, 2023 · 7 comments
Closed
1 of 2 tasks

cannot find symbol "Detox" on Android RN 0.70 #3973

arcln opened this issue Mar 7, 2023 · 7 comments

Comments

@arcln
Copy link

arcln commented Mar 7, 2023

What happened?

$ ./gradlew assembleAndroidTest -DtestBuildType=debug

[...]

> Task :app:compileDebugAndroidTestJavaWithJavac FAILED
/Users/arthur/Code/Mobile/temp/Sample/android/app/src/androidTest/java/com/sample/DetoxTest.java:3: error: cannot find symbol
import com.wix.detox.Detox;
                    ^
  symbol:   class Detox
  location: package com.wix.detox
/Users/arthur/Code/Mobile/temp/Sample/android/app/src/androidTest/java/com/sample/DetoxTest.java:4: error: package com.wix.detox.config does not exist
import com.wix.detox.config.DetoxConfig;
                           ^
/Users/arthur/Code/Mobile/temp/Sample/android/app/src/androidTest/java/com/sample/DetoxTest.java:22: error: cannot find symbol
        DetoxConfig detoxConfig = new DetoxConfig();
        ^
  symbol:   class DetoxConfig
  location: class DetoxTest
/Users/arthur/Code/Mobile/temp/Sample/android/app/src/androidTest/java/com/sample/DetoxTest.java:22: error: cannot find symbol
        DetoxConfig detoxConfig = new DetoxConfig();
                                      ^
  symbol:   class DetoxConfig
  location: class DetoxTest
/Users/arthur/Code/Mobile/temp/Sample/android/app/src/androidTest/java/com/sample/DetoxTest.java:27: error: cannot find symbol
        Detox.runTests(mActivityRule, detoxConfig);
        ^
  symbol:   variable Detox
  location: class DetoxTest
5 errors

What was the expected behaviour?

The test APK builds successfully.

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!

# create 0.70.7 project / this also occurs on 0.71.3
npx [email protected] init Sample --version 0.70.7
cd Sample

# add detox
npm i detox

# follow step 4 of https://wix.github.io/Detox/docs/introduction/project-setup#step-4-additional-android-configuration

# build test apk
cd android
./gradlew assembleAndroidTest -DtestBuildType=debug

Then you will run into #3867, which you can workaround using this solution.

After applying the workaround build again and notice the error above.

In what environment did this happen?

Detox version: 20.5.0
React Native version: 0.70.7 / 0.71.3
Has Fabric (React Native's new rendering system) enabled: (yes/no) no
Node version: v16.13.0
Device model:
Android version:
Test-runner (select one):

Detox logs

Detox logs
paste logs here!

Device logs

Device logs
paste your device.log here!

More data, please!

No response

@arcln
Copy link
Author

arcln commented Mar 7, 2023

node_modules/detox/Detox-android/com/wix/detox/20.5.0/detox-20.5.0.aar contains the specified symbols.

However node_modules/detox/Detox-android/com/wix/detox/20.5.0/detox-20.5.0-sources.jar does not.

Symbols
Archive:  /path/to/app/node_modules/detox/Detox-android/com/wix/detox/20.5.0/detox-20.5.0-sources.jar
   creating: META-INF/
  inflating: META-INF/MANIFEST.MF
   creating: org/
   creating: org/joor/
  inflating: org/joor/Reflect.java
  inflating: org/joor/ReflectException.java
   creating: com/
   creating: com/wix/
   creating: com/wix/detox/
   creating: com/wix/detox/common/
   creating: com/wix/detox/common/collect/
  inflating: com/wix/detox/common/collect/PairsIterator.kt
  inflating: com/wix/detox/common/UIThread.kt
  inflating: com/wix/detox/common/TextFileReader.kt
   creating: com/wix/detox/common/proxy/
  inflating: com/wix/detox/common/proxy/SpyingInvocationHandler.kt
  inflating: com/wix/detox/common/proxy/MethodsSpy.kt
  inflating: com/wix/detox/common/ErrorUtils.kt
  inflating: com/wix/detox/common/DetoxLog.kt
  inflating: com/wix/detox/common/DetoxErrors.java
  inflating: com/wix/detox/common/JsonConverter.kt
   creating: com/wix/detox/action/
   creating: com/wix/detox/action/common/
  inflating: com/wix/detox/action/common/MotionDefs.kt
   creating: com/wix/detox/espresso/
   creating: com/wix/detox/espresso/scroll/
  inflating: com/wix/detox/espresso/scroll/FlinglessSwiper.kt
  inflating: com/wix/detox/espresso/scroll/DetoxSwiper.kt
  inflating: com/wix/detox/espresso/scroll/ScrollHelper.java
  inflating: com/wix/detox/espresso/scroll/ScrollEdgeException.kt
  inflating: com/wix/detox/espresso/scroll/DetoxScrollActions.kt
  inflating: com/wix/detox/espresso/scroll/SwipeHelper.kt
  inflating: com/wix/detox/espresso/scroll/DetoxSwipe.kt
  inflating: com/wix/detox/espresso/scroll/ScrollProbes.kt
  inflating: com/wix/detox/espresso/ViewActionWithResult.kt
  inflating: com/wix/detox/espresso/UiControllerSpy.kt
  inflating: com/wix/detox/espresso/DeviceDisplay.kt
   creating: com/wix/detox/espresso/utils/
  inflating: com/wix/detox/espresso/utils/Vector2D.kt
   creating: com/wix/detox/espresso/action/
  inflating: com/wix/detox/espresso/action/TakeViewScreenshotAction.kt
  inflating: com/wix/detox/espresso/action/DetoxMultiTap.kt
  inflating: com/wix/detox/espresso/action/ScrollToIndexAction.kt
   creating: com/wix/detox/espresso/action/common/
  inflating: com/wix/detox/espresso/action/common/MotionEvents.kt
   creating: com/wix/detox/espresso/action/common/utils/
  inflating: com/wix/detox/espresso/action/common/utils/UiControllerUtils.kt
  inflating: com/wix/detox/espresso/action/common/DetoxViewConfiguration.kt
  inflating: com/wix/detox/espresso/action/common/TapEvents.kt
  inflating: com/wix/detox/espresso/action/common/ReflectUtils.kt
  inflating: com/wix/detox/espresso/action/DetoxSingleTap.kt
  inflating: com/wix/detox/espresso/action/ViewScreenshot.kt

I am not familiar with the java ecosystem, I don't know if that helps.

@arcln
Copy link
Author

arcln commented Mar 7, 2023

I have seen #1367 which looks very similar however my test is properly placed at android/app/src/androidTest/java/com/sample/DetoxTest.java.

@arcln
Copy link
Author

arcln commented Mar 8, 2023

My bad this was caused by wrong placement of the maven repository source.

I had to put it in "allprojects" section as stated in the docs, not "buildscript" section.

Change :

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

To :

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

@arcln arcln closed this as completed Mar 8, 2023
@redpanda-bit
Copy link

New react native projects don't have the allprojects section which makes this easy to be missed. I think the docs should make it more explicit on step 4.

// Full android/build.gradle from a fresh react-native init
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    ext {
        buildToolsVersion = "33.0.0"
        minSdkVersion = 21 // (1)
        compileSdkVersion = 33
        targetSdkVersion = 33
        kotlinVersion = '1.7.21' // (2)

        // We use NDK 23 which has both M1 support and is the side-by-side NDK version from AGP.
        ndkVersion = "23.1.7779620"
    }
    repositories {
        google()
        mavenCentral()

    }
    dependencies {
        classpath("com.android.tools.build:gradle:7.3.1")
        classpath("com.facebook.react:react-native-gradle-plugin")
        classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion") // (3)
    }
}

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

@bruteforks
Copy link
Contributor

bruteforks commented Mar 23, 2023

@carlosalmonte04 I totally agree the docs should be more clear. Struggled with this for longer than I care to admit! Gonna submit PR for the docs

edit: I believe the label can be changed to something other than bug/triage or closed, as it's user error. Though very easy to make if you're speeding through the docs like I was.

bruteforks added a commit to bruteforks/Detox that referenced this issue Mar 23, 2023
To clarify setup, as currently it's very easy for your eyes to just see the google() portion and put it in the wrong place. Spent 2 days struggling with this, and others have too. wix#3973
d4vidi pushed a commit that referenced this issue Mar 28, 2023
To clarify setup, as currently it's very easy for your eyes to just see the google() portion and put it in the wrong place. Spent 2 days struggling with this, and others have too. #3973
@ShivamJoker
Copy link

thanks I also missed this step.

stianjensen pushed a commit to stianjensen/Detox that referenced this issue Apr 21, 2023
To clarify setup, as currently it's very easy for your eyes to just see the google() portion and put it in the wrong place. Spent 2 days struggling with this, and others have too. wix#3973
@dids-reyes
Copy link

Thanks for this! the closing curly brace was collapsed on the docs that's why i missed it

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

5 participants