question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Not clear checkModules instruction: Gradle Plugin fails with NPE

See original GitHub issue

Describe the bug I found out very interesting feature — checkModules Gradle plugin from Koin. But unfortunately executing Gradle task “checkModules” leads to NPE. I’m sure the guide is not clear.

That’s the error:

C:\Development\Projects\Pet\Ubily>gradlew checkModules
Configuration on demand is an incubating feature.

FAILURE: Build failed with an exception.

* What went wrong:
Could not determine the dependencies of task ':checkModules'.
> java.lang.NullPointerException (no error message)

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 693ms

To Reproduce

  1. Define multimodule Android project.
  2. Define Koin modules for each one.
  3. Make sure it works correctly.
  4. Apply next build.gradle file:
apply plugin: 'koin'

buildscript {
    ext.kotlin_version = '1.3.71'

    repositories {
        google ()
        jcenter()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.6.2'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath "org.koin:koin-gradle-plugin:2.1.5"
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}
  1. Write JUnit Test:
@Category(CheckModuleTest::class)
class KoinModulesTest : KoinTest {

    @Test
    fun checkAllModules() = checkModules {
        modules(koinModules) // there are all modules of the project
    }

}
  1. Then run command from Android Studio terminal: gradlew checkModules

Expected behavior Correct work of the command “checkModules”, without NPE.

Koin project used and used version (please complete the following information):

  •   org.koin:koin-gradle-plugin:2.1.5
    
  •   implementation "org.koin:koin-androidx-scope:2.1.5"
      implementation "org.koin:koin-androidx-viewmodel:2.1.5"
      testImplementation "org.koin:koin-test:2.1.5"

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:8
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
kirich1409commented, Apr 8, 2020

For Android projects to proper check DI graph, you need to run the test using Robolectric or run it on an Android device

0reactions
fmatosqgcommented, Aug 7, 2020

I think I found the reason, it may be because I have flavors on my sample module.

./gradlew checkAndroidModules . . . What went wrong: Could not determine the dependencies of task ‘:sample:checkAndroidModules’. Task with path ‘testDebugUnitTest’ not found in project ‘:sample’.

Sounds like a candidate for a separate issue, right?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Dealing with validation problems - Gradle User Manual
This error occurs whenever a task or artifact transform is cacheable and that a file or file collection input property isn't declaring how...
Read more >
java.lang.NullPointerException (no error message)
I've deleted .gradle folder from the project and was able to rebuild it again. N.B: Make a backup, just in case.
Read more >
gradle-pitest-plugin: Gradle plugin for PIT Mutation Testing
Otherwise Gradle will resolve pitest to the configuration and not the task. Generic approach. “The plugins way” has some limitations. As the primary...
Read more >
The Google Services Gradle Plugin
gradle file matches the package name you entered when creating the google-services.json file. If you are not sure, run through the getting started...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found