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.

Plugin errors in Android Studio 4.2 beta1

See original GitHub issue

Using de.mannodermaus.gradle.plugins:android-junit5:1.6.2.0 in Android Studio 4.2 beta1 in a multi-module project with:

  • Gradle 6.7.1
  • kotlin 1.4.20
  • JUnit 5.7.0
  • com.android.tools.build:gradle:4.2.0-beta01
  • androidx.test🏃1.3.0
  • de.mannodermaus.junit5:android-test-core:1.2.0
  • de.mannodermaus.junit5:android-test-runner:1.2.0

I’m seeing two issues:

  1. Running an individual instrumented test works, but @BeforeAll function not invoked
  2. in the android block of build.gradle.kts, attempting this testOptions block:
    testOptions {
        junitPlatform {
            instrumentationTests {
                // Whether or not to validate configuration of instrumentation tests in this build
                integrityCheckEnabled = true
            }
        }
    }

The junitPlatform block shows as a syntax error even though the de.mannodermaus.android-junit5 is present and working in the plugins block.

Without the testOptions block, and manually invoking the @BeforeAll function, the instrumented test runs fine, and debugs fine using JUnit5 as far as I can tell. I know AS 4.2 beta 1 is brand new (and a beta), as is the android gradle plugin, so issues are not surprising. If there is anything additional I can do to help diagnose this, let me know.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
mannodermauscommented, Dec 10, 2020

I’ve had a similar experience with a different plugin before, where the provided DSL was not recognized at all and I had to use a different means to configure it. Might be a Kotlin DSL/Android Studio issue, rather than something within android-junit5.

As a workaround, you can forego the DSL sugar and access the extension directly with Kotlin DSL’s the method:


android {
  testOptions {
    with(the<AndroidJUnitPlatformExtension>()) {
      instrumentationTests {
        // Whether or not to validate configuration of instrumentation tests in this build
        integrityCheckEnabled = true
      }
    }
  }
}
0reactions
mannodermauscommented, Jul 27, 2021

This was resolved with the 1.7.1.1 release of the plugin, which moved the location of the extension to the Project rather than the TestOptions block of the Android plugin. After updating to that version, either of the following will work (though the first version is more canonical):

junitPlatform {
  // Configure
}
android {
  testOptions {
    junitPlatform {
      // Configure
    }
  }
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Known issues with Android Studio and Android Gradle Plugin
This update causes an underlying behavior change related to signing keys. To work around this issue, enter the same password for both the...
Read more >
Gradle build failed after updating android studio to 4.2 Beta1
I've just updated android studio and can't build my previous project. I've encountered these errors: class jdk.internal.loader.
Read more >
Cannot build signed APK on Android studio 4.2 beta 1 ...
When building Signed APK receive error with message. Missing class: org.conscrypt.ConscryptHostnameVerifier. Missing class: java.lang.instrument.
Read more >
Fix Android Studio error: Missing essential plugin - YouTube
Just update Android Studio 4.2.1, but fail to run with error of: Missing essential plugin : org.jetbrains.android Please reinstall Android ...
Read more >
Android Studio 4.2 Canary 3 available
General Fixes ; Android Gradle Plugin. Issue #158545411: Non-shrunk desugared library should only be packaged in the app APK ; Build Analyzer.
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