NativeScript: [MacOS] build android failed on app:mergeDebugAssets (unable to create new native thread)

Did you verify this is a real problem by searching the NativeScript Forum and the other open issues in this repo?

Yes

Tell us about the problem

tns build android failed on ‘:app:mergeDebugAssets’ > unable to create new native thread

Which platform(s) does your issue occur on?

Android development on macOS Sierra

Please provide the following version numbers that your issue occurs with:

  • tns info output
     ✔ Component nativescript has 4.0.0 version and is up to date.
     ✔ Component tns-core-modules has 4.0.0 version and is up to date.
     ✔ Component tns-android has 4.0.1 version and is up to date.
    
  • Cross-platform modules: (check the ‘version’ attribute in the node_modules/tns-core-modules/package.json file in your project)
    {
      "version": "4.0.0"
    }
    
  • Runtime(s): (look for the "tns-android" and "tns-ios" properties in the package.json file of your project)
        "tns-android": {
          "version": "4.0.1"
        }
    
  • Plugin(s): (look for the version number in the package.json file of your project) No plugin

Please tell us how to recreate the issue in as much detail as possible.

I just run tns create sample-project --template tns-template-tab-navigation-ng, then run tns build android and the error mentioned above appeared

*note: run tns debug android --bundle completed without error

tns doctor output

✔ Getting environment information 
✔ Your ANDROID_HOME environment variable is set and points to correct directory.
✔ Your adb from the Android SDK is correctly installed.
✔ The Android SDK is installed.
✔ A compatible Android SDK for compilation is found.
✔ Javac is installed and is configured properly.
✔ The Java Development Kit (JDK) is installed and is configured properly.
✔ Xcode is installed and is configured properly.
✔ xcodeproj is installed and is configured properly.
✔ CocoaPods are installed.
✔ CocoaPods update is not required.
✔ CocoaPods are configured properly.
✔ Your current CocoaPods version is newer than 1.0.0.
✔ Python installed and configured correctly.
✔ The Python 'six' package is found.
No issues were detected.
✔ Getting NativeScript components versions information...
✔ Component nativescript has 4.0.0 version and is up to date.
✔ Component tns-core-modules has 4.0.0 version and is up to date.
✔ Component tns-android has 4.0.1 version and is up to date.
✖ Component tns-ios is not installed.

tns debug android --log trace, output attached trace.log.zip

Is there code involved? If so, please share the minimal amount of code needed to recreate the problem.

No

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 5
  • Comments: 55 (7 by maintainers)

Most upvoted comments

gradle daemon runs a large number of threads while working on mergeDebugAssets task, when the number of threads exceeds the maximum limit of sysctl kern.num_taskthread the task will fail with that exception.

default nativescript org.gradle.jvmargs is -Xmx16384M, with default JVM stack size (-Xss1M), it can run a maximum of 16384 threads if it doesn’t exceed the kern.num_taskthread limit.

adjusting jvm max heap (-Xmx) and max stack size (-Xss) will solve the problem

CMIIW

For those that experience the issue with --ng builds only, updating Gradle to the latest version (4.9 at this time) appears to resolve this problem.

log.txt same problem here

Have the same problem at Win 7. After update from 3 to 4 version, tns build android reaches 71% ( app:mergeDebugAssets()), and then my computer hardly responses to any action for a very long time. I have not ios build installed at all.

On my linux box, this process can be done successfully, but it take very long times, the shortest is 1 hours 30mins

and the longest is 9 hours until I dropped it

Just for update,

building sample app based on tab template succeeded, but building sample app based on sidedrawer template still emit the same error

I can confirm running with --bundle does work and without it it get the famous error. but what does --bundle do to fix to problem ?

I had a very similar problem. After updating my Android build tools, the problem went away.

I just ran: sdkmanager "platform-tools" "platforms;android-26" (Since I was using API 26)

i dont think that was the problem, i have 12GB ram…