Skip to content

Improve error reporting of gradle build when sbg fail #1474

@vtrifonov

Description

@vtrifonov

Currently when Static Binding Generator or Meta Data Generator fail the result log look something like:

Gradle build...
         + setting applicationId
         + applying user-defined configuration from /Users/trifonov/Work/tmp/test/app/App_Resources/Android/app.gradle
         + using android X library androidx.legacy:legacy-support-v4:1.0.0
         + adding nativescript runtime package dependency: nativescript-optimized-with-inspector
         + adding aar plugin dependency: /Users/trifonov/Work/tmp/test/node_modules/tns-core-modules-widgets/platforms/android/widgets-release.aar
Exception in thread "main" java.lang.RuntimeException: Class not found OnNavigationItemReselectedListener
        at org.nativescript.staticbindinggenerator.Generator.getClass(Generator.java:549)
        at org.nativescript.staticbindinggenerator.Generator.getInterfacesFromCache(Generator.java:532)
        at org.nativescript.staticbindinggenerator.Generator.writeBinding(Generator.java:283)
        at org.nativescript.staticbindinggenerator.Generator.generateBinding(Generator.java:171)
        at org.nativescript.staticbindinggenerator.Generator.processRows(Generator.java:234)
        at org.nativescript.staticbindinggenerator.Generator.generateBindings(Generator.java:121)
        at org.nativescript.staticbindinggenerator.Generator.writeBindings(Generator.java:97)
        at org.nativescript.staticbindinggenerator.Main.main(Main.java:53)

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:runSbg'.
> Process 'command '/Library/Java/JavaVirtualMachines/jdk1.8.0_141.jdk/Contents/Home/bin/java'' finished with non-zero exit value 1

* 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 17s
Command ./gradlew failed with exit code 1

Although it contains the real error in the SBG is not obvious enough what exactly has failed and where because of the sbg stack trace(which doesn't mean a lot to the end-user) and the result log at the bottom coming from the gradle build.
To improve this we should hide the stackTrace and the gradle result (showing Process 'command '/Library/Java/JavaVirtualMachines/jdk1.8.0_141.jdk/Contents/Home/bin/java'' finished with non-zero exit value 1) and point the real problem, which in our case is Error executing Static Binding Generator: Class not found OnNavigationItemReselectedListener
So here's the proposed output:

Gradle build...
         + setting applicationId
         + applying user-defined configuration from /Users/trifonov/Work/tmp/test/app/App_Resources/Android/app.gradle
         + using android X library androidx.legacy:legacy-support-v4:1.0.0
         + adding nativescript runtime package dependency: nativescript-optimized-with-inspector
         + adding aar plugin dependency: /Users/trifonov/Work/tmp/test/node_modules/tns-core-modules-widgets/platforms/android/widgets-release.aar

Error executing Static Binding Generator: Class not found OnNavigationItemReselectedListener
Detailed log here: /Users/trifonov/Work/tmp/test/platforms/android/build-tools/runSbg.log

Command ./gradlew failed with exit code 1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions