Problems getting started with Android project

I’m a new user to DiffBlue, testing it out with a trial license. My team is developing a product using Android. I haven’t found anything on your site that says whether or not Android projects are supported, but I thought I’d give it a shot. This is a multi-project setup.

I’m having issues with both the IntelliJ (2021.3.1) plugin and the Windows CLI. With the IntelliJ plugin, I right-clicked on a production class and selected “Write Tests”. The output shows this:

17:00:43 Diffblue Cover indexing in progress: Tests will be automatically written when the Diffblue Cover indexes are updated
17:00:49 Indexing complete
17:00:49 JDK not found: Diffblue Cover requires a JDK to run. A JRE is not sufficient.
A valid JDK is not installed at JAVA_HOME=‘D:\Android\sdk’
None of the following paths were found to be valid:
‘D:\Android\sdk\bin\javac’
‘D:\Android\sdk\bin\javac.exe’
‘D:\Android\sdk\jbr\bin\javac’
‘D:\Android\sdk\jbr\bin\javac.exe’
‘D:\Android\sdk\jbr\Contents\Home\bin\javac’
Make sure JDK 8, 11 or 17 is installed and JAVA_HOME is set to its installation location.
See https://diff.blue/E056 to resolve this issue.

Note that ‘D:\Android\sdk’ is not the value of JAVA_HOME, but it is the value of ANDROID_SDK_ROOT. Following the suggestion at https://diff.blue/E056, I added both RT_JAR_PATH and JMODS_PATH to my environment, restarted IntelliJ, and tried again. I got exactly the same result. (A Google search doesn’t turn up any useful documentation for RT_JAR_PATH and JMODS_PATH; is that suggestion even relevant here?)

Here are some key environment variables, using a Terminal window in IntelliJ:

ANDROID_SDK_ROOT=D:/Android/sdk
RT_JAR_PATH=D:\java\jdk-17.0.1
JAVA_HOME=D:\java\jdk-17.0.1
JMODS_PATH=D:\java\jdk-17.0.1

Using the CLI, I CD’d in a Windows CMD shell to the root directory of my project, and tried to create a test for the same class. Here’s the log file (D:\my\project\dir.diffblue\log\cover-cli-20220505T173626.log) :

17:36:29.845 [INFO][main][c.d.c.u.c.Root] Running dcover create --verbose my.java.package.ClassName
17:36:34.442 [INFO][main][c.d.c.u.c.k] Diffblue Cover 2022.04.02-f570be8
17:36:34.443 [INFO][main][c.d.c.u.c.k]
17:36:34.443 [INFO][main][c.d.c.u.c.k] Detecting environment:
17:36:34.443 [INFO][main][c.d.c.u.c.k] ----------------------
17:36:34.444 [INFO][main][c.d.c.u.c.k] Java version 17.0.1
17:36:34.444 [INFO][main][c.d.c.u.c.k] Operating System: Windows 10 amd64 10.0
17:36:34.444 [INFO][main][c.d.c.u.c.k] Default charset: windows-1252
17:36:34.444 [INFO][main][c.d.c.u.c.k] Default locale: en_US
17:36:34.444 [INFO][main][c.d.c.u.c.k] Default time zone: America/New_York
17:36:34.444 [INFO][main][c.d.c.u.c.k] Detecting classpath…
17:36:36.640 [INFO][main][c.d.d.g.b.c] Getting project information from gradle
17:36:37.535 [ERROR][main][c.d.c.u.c.k] D:\my\project\dir__diffblue_build.gradle
Creating tests failed.
17:36:37.540 [INFO][main][c.d.cover.ui.c.f] Check log file at D:\my\project\dir.diffblue\log\cover-cli-20220505T173626.log for more details or run dcover with --verbose option.

  • I noticed that Dcover created copies of the build.gradle and settings.gradle files. But we use TFS, not git, so those files are read-only by default – and Dcover did not make the copied files writeable. So I checked them out of TFS to make them writeable, deleted Dcover’s copies of the files, and tried again. The log file now looks like this:

18:12:45.875 [INFO][main][c.d.c.u.c.Root] Running dcover create --verbose my.java.package.ClassName
18:12:50.865 [INFO][main][c.d.c.u.c.k] Diffblue Cover 2022.04.02-f570be8
18:12:50.866 [INFO][main][c.d.c.u.c.k]
18:12:50.866 [INFO][main][c.d.c.u.c.k] Detecting environment:
18:12:50.866 [INFO][main][c.d.c.u.c.k] ----------------------
18:12:50.867 [INFO][main][c.d.c.u.c.k] Java version 17.0.1
18:12:50.867 [INFO][main][c.d.c.u.c.k] Operating System: Windows 10 amd64 10.0
18:12:50.867 [INFO][main][c.d.c.u.c.k] Default charset: windows-1252
18:12:50.867 [INFO][main][c.d.c.u.c.k] Default locale: en_US
18:12:50.867 [INFO][main][c.d.c.u.c.k] Default time zone: America/New_York
18:12:50.867 [INFO][main][c.d.c.u.c.k] Detecting classpath…
18:12:53.269 [INFO][main][c.d.d.g.b.c] Getting project information from gradle
18:12:56.705 [INFO][main][c.d.d.g.b.c] Using Gradle 7.4
18:12:56.709 [ERROR][main][c.d.c.u.c.k] Found a Gradle project but no Java source sets are available. Perhaps run dcover in a subproject?: [:List :Of :Our :Subproject :Names]
Creating tests failed.
18:12:56.711 [INFO][main][c.d.cover.ui.c.f] Check log file at D:\my\project\dir.diffblue\log\cover-cli-20220505T181241.log for more details or run dcover with --verbose option.

The suggestion to “Perhaps run dcover in a subproject?” isn’t very helpful, because it doesn’t say how to do this. I don’t see anything in dcover’s help text that lets me pass a subproject name. Maybe it means I should cd to the subproject directory and run dcover there, but that doesn’t make sense to me, and as expected, it doesn’t work. (The build.gradle files in our subprojects aren’t intended to be used as standalone build.gradle files; we only run gradle from the root directory.) The log file from this attempt is:

18:16:31.782 [INFO][main][c.d.c.u.c.Root] Running dcover create --verbose my.java.package.ClassName
18:16:36.591 [INFO][main][c.d.c.u.c.k] Diffblue Cover 2022.04.02-f570be8
18:16:36.592 [INFO][main][c.d.c.u.c.k]
18:16:36.592 [INFO][main][c.d.c.u.c.k] Detecting environment:
18:16:36.593 [INFO][main][c.d.c.u.c.k] ----------------------
18:16:36.593 [INFO][main][c.d.c.u.c.k] Java version 17.0.1
18:16:36.593 [INFO][main][c.d.c.u.c.k] Operating System: Windows 10 amd64 10.0
18:16:36.593 [INFO][main][c.d.c.u.c.k] Default charset: windows-1252
18:16:36.593 [INFO][main][c.d.c.u.c.k] Default locale: en_US
18:16:36.593 [INFO][main][c.d.c.u.c.k] Default time zone: America/New_York
18:16:36.593 [INFO][main][c.d.c.u.c.k] Detecting classpath…
18:16:38.755 [INFO][main][c.d.d.g.b.c] Getting project information from gradle
18:16:40.662 [INFO][main][c.d.d.g.b.c] Using Gradle 7.4
18:16:40.668 [ERROR][main][c.d.c.u.c.k] Found a Gradle project but no Java source sets are available – please check configuration
Creating tests failed.
18:16:40.671 [INFO][main][c.d.cover.ui.c.f] Check log file at D:\my\project\dir.diffblue\log\cover-cli-20220505T181628.log for more details or run dcover with --verbose option.

Hi @dbreslau ,
Thanks for this in depth post and sorry for the delayed response.
Currently Diffblue cover does not support Android and we will improve our documentation to make this clearer.
We have not yet encountered TFS as most of our customers use git so thank you for informing us of this as we will make an internal engineering ticket to have a look at this.
For the last point yes we do mean for you to cd into a module. This is quite standard for both maven and gradle projects so I would be curious to know more about why this is not possible in your project. We do also have a option --working-directory: User Manual | Diffblue Docs but this will still not help if you are unable to build and run your modules from their own directories.
Thanks, Thomas