Search code examples
androidkotlinandroid-gradle-plugingradlew

Android project in koltin fails when execute ./gradlew build in terminal but works when run from menu


I'm trying to work with Travis CI, and previously I have try to build my project in the Android Studio's terminal with ./gradlew build or with ./gradlew clean build but both throws "Execution failed for task ':presentation:compileReleaseKotlin'." however when I build my project from the Android Studio's toolbar it works perfectly.

You can see the whole stacktrace and all the information here gradle stacktrace

Thanks in advance,

Javi


Solution

  • Check your Constants class for errors.

    e: /Users/jcamarero/AndroidStudioProjects/boton/presentation/src/main/java/com/b4motion/boton/utils/Constants.kt: (48, 31): Const 'val' initializer should be a constant value
    e: /Users/jcamarero/AndroidStudioProjects/boton/presentation/src/main/java/com/b4motion/boton/utils/Constants.kt: (48, 46): Unresolved reference: URL_WEB_VIEW
    e: /Users/jcamarero/AndroidStudioProjects/boton/presentation/src/main/java/com/b4motion/boton/utils/Constants.kt: (49, 29): Const 'val' initializer should be a constant value
    e: /Users/jcamarero/AndroidStudioProjects/boton/presentation/src/main/java/com/b4motion/boton/utils/Constants.kt: (49, 44): Unresolved reference: URL_WEB_VIEW
    

    This error says that you have a const val in your Constants class defined but it is not constant at compile time. Also, it cannot find reference to URL_WEB_VIEW.