3

I updated to Android Studio 3.1 and as suggested by Android Studio also:

  • Updated the Android gradle plugin to 3.1.0 from 2.3.0 (also tried the new 3.1.1, the problem persists)
  • Updated the buildToolsVersion to 27.0.3
  • Downloaded the Android 8.1 API 27 with the SDK manager.

I am using the JDK 8.

My previous Android Studio build configuration "Core tests" which just ran all tests in one module now says:

Could not execute build using Gradle distribution 'https://services.gradle.org/distributions/gradle-4.5.1-all.zip'.

My set up: enter image description here

The exact exception as shown in the ide: enter image description here

My full source code: https://github.com/Leejjon/BluffPoker

Apparently the same Nullpointer occurs when running this on the command line: gradle :core:test This command will fail with the same NullPointer. Doing a test on the root project like gradle test will run fine. I can also deploy the app on my Android phone. This is probably not IntelliJ related but the Android gradle plugin 3.1.0 breaking the ability to run the gradle :core:test command.

TLDR: Running any gradle task in the core module like gradle :core:sometask seems to result in a null pointer since Android gradle plugin 3.1.0.

My workaround for now is to use the gradle test command to run all tests in all modules and study the generated html pages by junit (found in BluffPoker\core\build\reports\tests\test\index.html) to troubleshoot whether they are failing.

Leejjon
  • 680
  • 2
  • 7
  • 24
  • Try downgrading Gradle version in gradle.properties? https://developer.android.com/studio/releases/gradle-plugin.html#updating-gradle – OneCricketeer Mar 29 '18 at 11:13
  • I was already using this gradle version before this upgrade and it worked fine. I'd prefer finding a solution that gets Android Studio to work with it. – Leejjon Mar 29 '18 at 11:16
  • Well, your error is clearly complaining about that Gradle version. And the documentation says Gradle plugin 3.1 supports 4.4+, so just try it – OneCricketeer Mar 29 '18 at 11:24
  • `distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip` – IntelliJ Amiya Mar 29 '18 at 11:41
  • try [editing](https://stackoverflow.com/a/52462269/1008011) your gradle.properties and then re-enabling configure on demand. – chornge Sep 25 '18 at 00:57

3 Answers3

3

As this bug commenter pointed out: https://issuetracker.google.com/issues/77605097#comment7

disabling the "configure on demand" feature of Gradle (in Settings: Build, Execution, and Deployment: Compiler) is a viable workaround.

Since I did this my Unit tests are all working again.

David Pisoni
  • 3,317
  • 2
  • 25
  • 35
1

Solution from kekkou of the libgdx forums: http://www.badlogicgames.com/forum/viewtopic.php?f=11&t=27639&p=109249#p109249

His solution is: Move the project(':android') {} block in root build.gradle into android\build.gradle.

This makes all commands work again. I did not find any downsides.

The commit for this fix on my project: https://github.com/Leejjon/BluffPoker/commit/d10deb090c2d80e641d733efdaa85f99c0a9fe2f

Leejjon
  • 680
  • 2
  • 7
  • 24
0

in your gradle-wrapper.properties, try using:

distributionUrl=https://services.gradle.org/distributions/gradle-4.3-rc-2-all.zip

Whitebear
  • 1,761
  • 2
  • 12
  • 22
  • Why use an RC build, when actual later releases exist? – OneCricketeer Mar 29 '18 at 11:25
  • I am getting: Minimum supported Gradle version is 4.4. Current version is 4.3-rc-2. Please fix the project's Gradle settings. Fix Gradle wrapper and re-import project Gradle settings – Leejjon Mar 29 '18 at 11:38
  • @Leejjon click on it then and fix. – Whitebear Mar 29 '18 at 11:56
  • @Whitebear clicking it will change the gradle wrapper properties to 4.4 again, which will result in the same error as when I use 4.5.1 (as I added to the first post: https://i.imgur.com/oa4VH5F.png). – Leejjon Mar 29 '18 at 12:00