jeudi 7 décembre 2017

Cannot unit test in Kotlin (ExecutionException, Aapt2Exception)

A simple test...

import org.junit.Test

class KotlinUnitTest {

    @Test
    fun test() {
        assert(true)
    }
}

... results in the following...

Information:Gradle: Executing tasks: [:app:assembleDebug, :app:assembleDebugUnitTest]
Information:Kotlin: Kotlin JPS plugin is disabled
Information:Module "app" was fully rebuilt due to project configuration/dependencies changes
Information:06/12/2017 5:08 PM - Compilation completed with 3 errors and 0 warnings in 19s 962ms
Error:Gradle: java.util.concurrent.ExecutionException: java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
Error:Gradle: java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
Error:Gradle: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details

Adding android.enableAapt2=false to gradle.properties (or also gradle-wrapper.properties) made Android Studio halt indefinitely every time I ran the test.

This is weird because I'm able to...

  • Run my production app (filled with Kotlin files)
  • Unit test in Java

But, for whatever reason, I can't test in Kotlin

Aucun commentaire:

Enregistrer un commentaire