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

Android: '-androidTest.apk' seems to get appended to a valid apk path #830

Closed
yamiscott opened this issue Jul 15, 2018 · 6 comments
Closed

Comments

@yamiscott
Copy link

Description

Using Detox 8, if I set up an android build and get the detox build to successfully create the apk I need. Then set package json configuration for the android test to point at this apk and run detox test. Detox errors looking for the apk as it adds '-androidTest.apk' to the end of the path (stripping the existing .apk extension), resulting in never being able to run tests against that file.

apk file path (excluding personal path elements):

/Users/[**REDACTED**]/android/app/build/outputs/apk/androidTest/debug/app-debug-androidTest.apk

package.json config:

"android.emu.debug": {
    "binaryPath": "android/app/build/outputs/apk/androidTest/debug/app-debug-androidTest.apk",
    "build": "cd android && ./gradlew assembleAndroidTest -DtestBuildType=debug && cd ..",
    "type": "android.emulator",
    "name": "Nexus_4_Tester_"
  }

error:

'/Users/[**REDACTED**]/android/app/build/outputs/apk/androidTest/debug/androidTest/app-debug-androidTest-androidTest.apk' could not be found, did you run './gradlew assembleAndroidTest' ?

The problem is inside APKPath.js line 23

const testApkPath = path.join(tempPath.join(path.sep), 'androidTest', flavorDimensionsPath, buildType, `${originalApkPathObj.name}-androidTest${originalApkPathObj.ext}`);

As you can see (well you can if you head into the file), it splits on the last '-' and grabs the extension, then drops the 'variant' assuming it to be '-debug' or '-release', but without flavours, this isn't the case with a standard project.

It then rebuilds the path assuming the path is a flavoured build. Then finally it blanket adds a -androidTest on the end. Resulting in the error I'm seeing.

Steps to Reproduce

Basically follow the tutorial.

  • install detox 8
  • update gradle tools to 3+
  • setup your android project with the androidTest flavour

Detox, Node, Device, Xcode and macOS Versions

  • Detox: 8.0.x
  • React Native: 0.55.4
  • Node: 9.8.0
  • Device: N/A
  • Xcode: N/A
  • macOS: 10.13.5

Device and verbose Detox logs

 : /Users/scott.ewart/Library/Android/sdk/platform-tools/adb -s emulator-5554 shell getprop dev.bootcomplete
3: stdout: 1
 
 : /Users/scott.ewart/Library/Android/sdk/platform-tools/adb -s emulator-5554 shell input keyevent 82
 : /Users/scott.ewart/Library/Android/sdk/platform-tools/adb -s emulator-5554 uninstall [REDACTED-BINARY-NAME].test
5: stdout: Success
 
 : /Users/scott.ewart/Library/Android/sdk/platform-tools/adb -s emulator-5554 uninstall [REDACTED-BINARY-NAME].test.test
 : /Users/scott.ewart/Library/Android/sdk/platform-tools/adb -s emulator-5554 shell getprop ro.build.version.sdk
7: stdout: 25
 
8: /Users/scott.ewart/Library/Android/sdk/platform-tools/adb -s emulator-5554 install -r -g /Users/[REDACTED-REPO-PATH]/android/app/build/outputs/apk/androidTest/debu /app-debug-androidTest.apk
8: stdout: Success
 
 finalized artifacts successfully
 FAIL  e2e/Home.spec.js
  Home
    ✕ should show the login page (5ms)

  ● Home › should show the login page

    '/Users/[REDACTED-REPO-PATH]/android/app/build/outputs/apk/androidTest/debug/androidTest/app-debug-androidTest-androidTest.apk' could not be found, did you run './gradlew assembleAndroidTest' ?

at EmulatorDriver.getTestApkPath (../node_modules/detox/src/devices/AndroidDriver.js:62:13)
at EmulatorDriver.installApp (../node_modules/detox/src/devices/AndroidDriver.js:55:43)
@neerajkumar-lad
Copy link

Hi

Run this and try :
cd android && ./gradlew assembleDebug assembleAndroidTest -DtestBuildType=debug && cd ..

once succeed then check apk at android/app/build/outputs/apk/debug/app-debug.apk

Then run following
detox build --configuration android.emu.debug && detox test --configuration android.emu.debug

Node : this is for debug build

Following is my version:
xcode : 9.4.0
node: v10.6.0
Detox: v8.0.0
react-native-cli: 2.0.1
react-native: 0.53.3
Gradle : 3+

@neerajkumar-lad
Copy link

Hi Team,

When you want to test on debug build which is not placed under androidTest folder then Detox search by default under androidTest folder rather than given binary path. This is an issue I am facing.

Error :

'/Users/user.kumar/Projects/demoProject/demo-mobile/android/app/build/outputs/androidTest/6.93Universal/debug/my.project-universal-debug-androidTest.apk' could not be found, did you run './gradlew assembleAndroidTest' ?

package.json entry:
"binaryPath": "android/app/build/outputs/apk/debug/my.project-6.93-universal-debug.apk",

@neerajkumar-lad
Copy link

@yamiscott Any workaround till this get fix?

@neerajkumar-lad
Copy link

neerajkumar-lad commented Jul 17, 2018

Hi

Just want to update you that I have changed following in APKPath.js at line no 22

const testApkPath = path.join(tempPath.join(path.sep), "apk", buildType, ${originalApkPathObj.name}${originalApkPathObj.ext});`

And following is the binarypath in package.json

"binaryPath": "android/app/build/outputs/apk/debug/my.project-universal-debug.apk",

@stale
Copy link

stale bot commented Aug 31, 2018

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.

@stale stale bot added the 🏚 stale label Aug 31, 2018
@stale
Copy link

stale bot commented Sep 7, 2018

The issue has been closed for inactivity.

@stale stale bot closed this as completed Sep 7, 2018
@lock lock bot locked as resolved and limited conversation to collaborators Sep 10, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants