1

I want to generate test coverage report for espresso and ui automation test cases.For which I am following this link I have added testCoverageEnabled = true in my android studio but when i am running ./gradlew createDebugCoverageReport getting error . is not recognized as an internal or external command, operable program or batch file. and if i remove . then /gradlew is not recognized as an internal or external command,operable program or batch file. Please help me. Maybe i am running command on wrong path.

Output of gradle wrapper

C:\Users\Shivam\Desktop\gradle\gradle-3.4.1-all\gradle-3.4.1\bin>gradle wrapper
Starting a Gradle Daemon (subsequent builds will be faster)
:wrapper FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Some problems were found with the configuration of task ':wrapper'.
> Cannot write to file 'C:\Users\Shivam\Desktop\gradle\gradle-3.4.1-all\gradle-3.4.1\bin\gradle\wrapper\gradle-wrapper.properties' specified for property 'propertiesFile', as ancestor 'C:\Users\Shivam\Desktop\gradle\gradle-3.4.1-all\gradle-3.4.1\bin\gradle' is not a directory.
> Cannot write to file 'C:\Users\Shivam\Desktop\gradle\gradle-3.4.1-all\gradle-3.4.1\bin\gradle\wrapper\gradle-wrapper.jar' specified for property 'jarFile', as ancestor 'C:\Users\Shivam\Desktop\gradle\gradle-3.4.1-all\gradle-3.4.1\bin\gradle' is not a directory.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
Shivam Kapoor
  • 117
  • 1
  • 13

1 Answers1

1

You are following a tutorial which does not match your OS.

./

is Unix based and you are windows based. If gradlew is in the current directory, then you can run.

.\gradlew createDebugCoverageReport

else, run just

gradlew createDebugCoverageReport

from command line, but that is if gradlew is in the system PATH.

else do

cd \
dir /S gradlew

it will display the path to gradlew, you then just need to cd to it, so let's say it is in C:\Program Files\Gradlew\ you just do

cd "C:\Program Files\Gradlew\"

and run gradlew createDebugCoverageReport from there.

  • The program files does not contain Gradlew, now what should i do? – Shivam Kapoor Mar 29 '17 at 06:52
  • I am not saying it is there, Program Files was just an example. So please do 'cd\' and then `dir /S gradlew` and see what it returns, post the results. –  Mar 29 '17 at 06:55
  • Result is very long,few lines i m showing u. Directory of C:\$Recycle.Bin\S-1-5-21-3724520574-1689724993-185700522-1002\$RLBQLWO 03/10/2016 02:45 PM 4,971 gradlew 1 File(s) 4,971 bytes – Shivam Kapoor Mar 29 '17 at 07:00
  • you deleted gradlew? go to recycle bin and undelete or reinstall the application. –  Mar 29 '17 at 07:02
  • which application?Recylerbin does not contain gradlew, so how to install this? – Shivam Kapoor Mar 29 '17 at 07:04
  • you need to generate `gradlew.bat` from cmd just run `gradle wrapper` –  Mar 29 '17 at 07:18
  • Like this,C:\Users\Aman>gradlew.bat 'gradlew.bat' is not recognized as an internal or external command, operable program or batch file. C:\Users\Shivam>gradle wrapper 'gradle' is not recognized as an internal or external command, operable program or batch file. – Shivam Kapoor Mar 29 '17 at 07:25
  • is Gradle not installed? –  Mar 29 '17 at 07:29
  • I think you need to start here. https://docs.gradle.org/current/userguide/installation.html –  Mar 29 '17 at 07:29
  • hey i search gradle in c,and found in C:\Program Files\Android\Android Studio\plugins\android\lib\templates\gradle\wrapper. Is this what u are saying? – Shivam Kapoor Mar 29 '17 at 07:40
  • I hope you have the full install still, but yes, just `cd C:\Program Files\Android\Android Studio\plugins\android\lib\templates\gradle` and then try `gradle wrapper` again –  Mar 29 '17 at 07:50
  • Check this output, C:\Program Files\Android\Android Studio\plugins\android\lib\templates\gradle>gradle wrapper 'gradle' is not recognized as an internal or external command, operable program or batch file. – Shivam Kapoor Mar 29 '17 at 07:52
  • please send me the output off `dir "c:\Program Files (x86)"` and `dir "c:\Program Files"` –  Mar 29 '17 at 08:01
  • please also do not post that output in the comments, edit your question and add to the bottom. –  Mar 29 '17 at 08:03
  • `dir "c:\Program Files (x86)"` and `dir "c:\Program Files"` –  Mar 29 '17 at 08:46
  • plz check the edit,this is what u r asking or something different. – Shivam Kapoor Mar 29 '17 at 08:48
  • What did you install to get Gradle on the device? I do not see anything that shows that gradle is installed. Please refer to the install doc again mentioned earlier. We are not going to get far if the relevant executables are not installed. –  Mar 29 '17 at 09:08
  • install latest release, complete. –  Mar 29 '17 at 09:21
  • Did you exctract the zip file? if so where did you extract it? –  Mar 29 '17 at 09:26
  • on my desktop,in gradle folder. – Shivam Kapoor Mar 29 '17 at 09:27
  • now cd to that directory, then cd to bin then try `gradle wrapper` –  Mar 29 '17 at 09:54
  • cd C:\Users\Shivam\Desktop\gradle\gradle-3.4.1-all\gradle-3.4.1\bin for bin and cd C:\Users\Shivam\Desktop\gradle for gradle. – Shivam Kapoor Mar 29 '17 at 09:56
  • `cd C:\Users\Shivam\Desktop\gradle\gradle-3.4.1-all\gradle-3.4.1‌​\bin` then run `gradle wrapper` –  Mar 29 '17 at 09:59
  • `mv .gradle gradle` –  Mar 29 '17 at 10:11
  • showing an error :- 'mv' is not recognized as an internal or external command, operable program or batch file. – Shivam Kapoor Mar 29 '17 at 10:20
  • I have run only gradle then gradle wrapper.But showing same error FAILURE: Build failed with an exception. – Shivam Kapoor Mar 29 '17 at 10:22
  • then use `move gradle gradle.unix` and then `move .gradle gradle` then `gradle wrapper` –  Mar 29 '17 at 10:24
  • C:\Users\Aman\Desktop\gradle\gradle-3.4.1-all\gradle-3.4.1\bin>move gradle gradle.unix 1 file(s) moved. C:\Users\Aman\Desktop\gradle\gradle-3.4.1-all\gradle-3.4.1\bin>move .gradle gradle 1 dir(s) moved. C:\Users\Aman\Desktop\gradle\gradle-3.4.1-all\gradle-3.4.1\bin>gradle wrapper :wrapper BUILD SUCCESSFUL – Shivam Kapoor Mar 29 '17 at 10:25
  • so now you will see that you have gradlew.bat –  Mar 29 '17 at 10:27
  • Now what should i do – Shivam Kapoor Mar 29 '17 at 10:28
  • so now you can use `cradlew` as per the turorial.Follow your tutorial and do what they say, keep away from using `./` rather just cd to your directory and run `cradlew` from there. If you are happy that I answered the question, then please mark the question as correct. –  Mar 29 '17 at 10:29
  • Build successfull for gradlew.bat , now ? – Shivam Kapoor Mar 29 '17 at 10:29
  • No follow the turorial in the link you posted. Remember that this question was about you having errors when running `gradlew` now you have `gradlew` working, if you have any other questions please post a new question as this one is then answered :) –  Mar 29 '17 at 10:32
  • Yes u deserve,but gradlew createDebugCoverageReport this gives error. – Shivam Kapoor Mar 29 '17 at 10:34
  • Then there are procedures you are not following. I suggest you first read this page, then you follow the tutorial again. There is alow about `gradlew` Read this thoroughly, especially around `gradle wrapper` https://docs.gradle.org/3.4.1/userguide/userguide.html –  Mar 29 '17 at 10:40
  • I am following each step,do u have any idea?Why the gradle createDebugCoverageReport is not working – Shivam Kapoor Mar 30 '17 at 04:03
  • @ShivamKapoor I suggest you create a new question around that issue. –  Mar 30 '17 at 06:57
  • I have already created plz check link http://stackoverflow.com/questions/43094105/getting-error-while-generating-test-cases-for-espresso-android – Shivam Kapoor Mar 30 '17 at 07:08