Skip to content

When using kotlin sometimes the metadata is not existing in the result apk #1476

@vtrifonov

Description

@vtrifonov

Environment
Provide version numbers for the following components (information can be retrieved by running tns info in your project folder or by inspecting the package.json of the project):

  • CLI: 6.1.0
  • Cross-platform modules: 6.1.0
  • Android Runtime: 6.1.0

Describe the bug
When using Kotlin jar file included in the App_Resources/Android/libs folder and App_Resources/Android/gradle.properties is added with the following content:

useKotlin=true

It may cause the app to crash when you run tns run android with:

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

This is happening not on every machine, seems that it more often happens on machines with more CPU cores.

The cause of the problem above is that for some reason the buildMetadata task is executed after the mergeDebugAssets task and thus the generated metadata files will be missing in the result apk file and this will cause the application to crash.

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