4

I'm new using calabash to test Android applications.

I implemented some tests to validate an apk implemented with Android Studio 3.0.1 and Gradle version 2.3.3 and that works fine. The problem appears when i try to execute the tests to validate a new app created with Gradle version 3.0.1 and Kotlin (same AS). Executing the command:

bundle exec calabash-android run app-release.apk

i'm getting this:

adb: failed to install /Users/sonia/Documents/calabash-test-android/app-release.apk: Failure [INSTALL_FAILED_TEST_ONLY: installPackageLI]
  Scenario: As a valid user I can log into my app #features/my_first.feature:3
  undefined method `chomp' for nil:NilClass (NoMethodError)
  ./features/support/app_installation_hooks.rb:18:in `Before'
  Will not start test server because of previous failures. (RuntimeError)
  ./features/support/app_life_cycle_hooks.rb:5:in `Before'
    When I press "Login"                          # calabash-android-0.9.2/lib/calabash-android/steps/press_button_steps.rb:17
    Then I see "Welcome to coolest app ever"      # calabash-android-0.9.2/lib/calabash-android/steps/assert_steps.rb:5

Failing Scenarios:
cucumber features/my_first.feature:3 # Scenario: As a valid user I can log into my app

1 scenario (1 failed)
2 steps (2 skipped)
0m4.553s

All the other settings defined in AS in the new app are the same as the old app.

Someone knows if there is a problem with the Gradle version?

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
Andrews
  • 41
  • 1
  • 1
  • 2

7 Answers7

19

The Official docs say this

Note: The Run button builds an APK with testOnly="true", which means the APK can only be installed via adb (which Android Studio uses). If you want a debuggable APK that people can install without adb, select your debug variant and click Build > Build APK(s).

Even I force to adding below line to application tag in AndroidManifest.xml

android:testOnly="false"

The Android Studio Run button overrides my setting of it.

I find a working method to stop Android Studio from injecting the testOnly property to application tag.

Add the below line:

android.injected.testOnly=false

to gradle.properties gradle config file in your project.

Tshunglee
  • 337
  • 2
  • 11
2

I was also facing the same problem and tried with android.injected.testOnly=false also in manifest android:testOnly="false". But it does not work.

So simple solution which work for me is- Click on Build option and select Build APK(s). click on locate apk on dialog which appears on right bottom . It will locate your unsigned debug APK .

PPD
  • 5,660
  • 12
  • 52
  • 86
1

Just did:

  1. Build -> Build Bundle(s) / APKs -> Build APKs
  2. Navigate to the directory build/outputs/apk/release
  3. adb install -r your_app.apk

It appears hitting run will still add the flag even if android:testOnly="false" is in your AndroidManifest.xml file.

Suhail Doshi
  • 716
  • 1
  • 10
  • 23
1

Edit the run configuration, change the deploy option from "Default APK" to "APK from app bundle".

Even though not setting the android.injected.testOnly=false and android:testOnly="false", it still working.

司南啦
  • 11
  • 1
0

Try changing android:testOnly="true" to android:testOnly="false" in your AndroidManifest.xml. You can also just remove it, should work both way.

Katia
  • 619
  • 6
  • 15
0

If use preview version of SDK, it forces testOnly to be TRUE. Only can skip this error by adb -t. That prevents app with preview SDK releasing on end user.

Kislingk
  • 1,427
  • 14
  • 23
0

Remember to add the following line:

android.injected.testOnly=false

in the gradle.properties file which is located

in [ROOT_PROJECT]/app/gradle.properties (or you main app gradle module) and NOT the [ROOT_PROJECT]/gradle.properties file. Otherwise it will not work.