2

https://developer.android.com/training/testing/unit-testing/local-unit-tests clearly states

...adding the following configuration in your project's top-level build.gradle file:

android {
    ...
    testOptions {
        unitTests.returnDefaultValues = true
    }
}

But doing so results in an error:

Could not find method android() for arguments [...] on root project '...' of type org.gradle.api.Project.

Open File

When researching that error:

I find several existing StackOverflows that indicate it is wrong to add adroid{} to your top-level build.gradle file.

Could not find method android() for arguments in Android Studio project

In your top-level file, you can't define an android block.

Could not find method android() for arguments

In your top-level file you can't define an android block

Does that mean the Android documentation is wrong?

If not, please help me to understand.

Ioane Sharvadze
  • 2,118
  • 21
  • 35
Brian Davis
  • 345
  • 4
  • 9

1 Answers1

1

Good finding. Yes it's wrong, since there is no android method in lot level gradle file.

I guess they meant project wide gradle file, that should be app/build.gradle.

Also here in documentation you can see that top-level gradle file just configures all modules.

Ioane Sharvadze
  • 2,118
  • 21
  • 35