Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLI 8.2.x cannot build plugin with targetSdk 32 and buildTools 32.0.0 #5660

Open
3 tasks done
agonper opened this issue Mar 30, 2022 · 15 comments
Open
3 tasks done

CLI 8.2.x cannot build plugin with targetSdk 32 and buildTools 32.0.0 #5660

agonper opened this issue Mar 30, 2022 · 15 comments
Labels
bug-pending-triage Reported bug, pending triage to confirm.

Comments

@agonper
Copy link

agonper commented Mar 30, 2022

Issue Description

When running ns plugin build using NS CLI 8.2.x, the following error raises:

FAILURE: Build failed with an exception.

* Where:
Build file '/private/var/folders/5q/6zrvvtkj5_g7l948bjdttwwr0000gn/T/android-project2022230-40036-1rbjm2o.grn5/nativescript_context_apis/build.gradle' line: 38

* What went wrong:
A problem occurred evaluating root project 'nativescript_context_apis'.
> /private/var/folders/5q/6zrvvtkj5_g7l948bjdttwwr0000gn/platforms/android/dependencies.json (No such file or directory)

* 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 461ms
Failed to build plugin nativescript-context-apis : 
Error: Command ./gradlew failed with exit code 1

Rolling back to CLI 8.1.5 temporally fixes the problem (defaults to targetSdk 31 and buildTools 30.0.3).

Reproduction

https://github.com/GeoTecINIT/nativescript-context-apis

  1. Install latest NS CLI version
  2. clone
  3. cd publish
  4. run ./pack.sh

Relevant log output (if applicable)

Trying to get macOS version.
Exec system_profiler SPSoftwareDataType -detailLevel mini 
 stdout: Software:

    System Software Overview:

      System Version: macOS 12.2.1 (21D62)
      Kernel Version: Darwin 21.3.0

 
 stderr: 
macOS version based on system_profiler is 12.2.
Looking for project in '~/nativescript-context-apis/src'
Project directory is '~/nativescript-context-apis/src'.
No config file found - falling back to ~/nativescript-context-apis/src/nativescript.config.ts.
Project Config Service using legacy configuration...
failed to add embedded package.json data to config Error: ENOENT: no such file or directory, open '~/nativescript-context-apis/src/app/package.json'
    at Object.openSync (node:fs:585:3)
    at Object.readFileSync (node:fs:453:35)
    at FileSystem.readFile (~/.nvm/versions/node/v16.13.1/lib/node_modules/nativescript/lib/common/file-system.js:192:19)
    at FileSystem.readText (~/.nvm/versions/node/v16.13.1/lib/node_modules/nativescript/lib/common/file-system.js:202:21)
    at FileSystem.readJson (~/.nvm/versions/node/v16.13.1/lib/node_modules/nativescript/lib/common/file-system.js:205:27)
    at ProjectConfigService.fallbackToLegacyNSConfig (~/.nvm/versions/node/v16.13.1/lib/node_modules/nativescript/lib/services/project-config-service.js:238:50)
    at ProjectConfigService.readConfig (~/.nvm/versions/node/v16.13.1/lib/node_modules/nativescript/lib/services/project-config-service.js:139:25)
    at ProjectData.initializeProjectDataFromContent (~/.nvm/versions/node/v16.13.1/lib/node_modules/nativescript/lib/project-data.js:61:45)
    at ProjectData.initializeProjectData (~/.nvm/versions/node/v16.13.1/lib/node_modules/nativescript/lib/project-data.js:50:22)
    at new ProjectDataService (~/.nvm/versions/node/v16.13.1/lib/node_modules/nativescript/lib/services/project-data-service.js:40:25) {
  errno: -2,
  syscall: 'open',
  code: 'ENOENT',
  path: '~/nativescript-context-apis/src/app/package.json'
}
Initializing project identifiers. Config:  {}
Loading extensions.
Collecting system information...
System information:
{
  "platform": "darwin",
  "shell": "/bin/zsh",
  "os": "Darwin endpriv100.scom-glt.uminho.pt 21.3.0 Darwin Kernel Version 21.3.0: Wed Jan  5 21:37:58 PST 2022; root:xnu-8019.80.24~20/RELEASE_ARM64_T8101 arm64\n",
  "procArch": "arm64",
  "nodeVer": "16.13.1",
  "npmVer": "8.3.2",
  "nodeGypVer": null,
  "nativeScriptCliVersion": "8.2.3",
  "gitVer": "2.32.0 (Apple Git-132)",
  "dotNetVer": null,
  "javacVersion": "11.0.11",
  "javaVersion": "11.0.11",
  "javaPath": "~/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/211.7628.21.2111.8139111/Android Studio.app/Contents/jre/Contents/Home/bin/java",
  "adbVer": "1.0.41",
  "androidInstalled": true,
  "monoVer": null,
  "gradleVer": null,
  "isAndroidSdkConfiguredCorrectly": true,
  "xcodeVer": "13.3.0",
  "xcodeprojLocation": "/opt/homebrew/bin/xcodeproj",
  "itunesInstalled": false,
  "cocoaPodsVer": "1.11.2",
  "isCocoaPodsWorkingCorrectly": true,
  "isCocoaPodsUpdateRequired": false,
  "pythonInfo": {
    "isInstalled": true,
    "isSixPackageInstalled": true
  }
}
Current CLI version:  8.2.3
Project dir from hooksArgs is: undefined.
Hooks directories: [
  '~/nativescript-context-apis/src/hooks'
]
No config file found - falling back to ~/nativescript-context-apis/src/nativescript.config.ts.
Project Config Service using legacy configuration...
failed to add embedded package.json data to config Error: ENOENT: no such file or directory, open '~/nativescript-context-apis/src/app/package.json'
    at Object.openSync (node:fs:585:3)
    at Object.readFileSync (node:fs:453:35)
    at FileSystem.readFile (~/.nvm/versions/node/v16.13.1/lib/node_modules/nativescript/lib/common/file-system.js:192:19)
    at FileSystem.readText (~/.nvm/versions/node/v16.13.1/lib/node_modules/nativescript/lib/common/file-system.js:202:21)
    at FileSystem.readJson (~/.nvm/versions/node/v16.13.1/lib/node_modules/nativescript/lib/common/file-system.js:205:27)
    at ProjectConfigService.fallbackToLegacyNSConfig (~/.nvm/versions/node/v16.13.1/lib/node_modules/nativescript/lib/services/project-config-service.js:238:50)
    at ProjectConfigService.readConfig (~/.nvm/versions/node/v16.13.1/lib/node_modules/nativescript/lib/services/project-config-service.js:139:25)
    at ProjectConfigService.getValue (~/.nvm/versions/node/v16.13.1/lib/node_modules/nativescript/lib/services/project-config-service.js:157:27)
    at HooksService.initialize (~/.nvm/versions/node/v16.13.1/lib/node_modules/nativescript/lib/common/services/hooks-service.js:50:56)
    at HooksService.<anonymous> (~/.nvm/versions/node/v16.13.1/lib/node_modules/nativescript/lib/common/services/hooks-service.js:80:18) {
  errno: -2,
  syscall: 'open',
  code: 'ENOENT',
  path: '~/nativescript-context-apis/src/app/package.json'
}
BeforeHookName for command resolveCommand is before-resolveCommand
No config file found - falling back to ~/nativescript-context-apis/src/nativescript.config.ts.
Project Config Service using legacy configuration...
failed to add embedded package.json data to config Error: ENOENT: no such file or directory, open '~/nativescript-context-apis/src/app/package.json'
    at Object.openSync (node:fs:585:3)
    at Object.readFileSync (node:fs:453:35)
    at FileSystem.readFile (~/.nvm/versions/node/v16.13.1/lib/node_modules/nativescript/lib/common/file-system.js:192:19)
    at FileSystem.readText (~/.nvm/versions/node/v16.13.1/lib/node_modules/nativescript/lib/common/file-system.js:202:21)
    at FileSystem.readJson (~/.nvm/versions/node/v16.13.1/lib/node_modules/nativescript/lib/common/file-system.js:205:27)
    at ProjectConfigService.fallbackToLegacyNSConfig (~/.nvm/versions/node/v16.13.1/lib/node_modules/nativescript/lib/services/project-config-service.js:238:50)
    at ProjectConfigService.readConfig (~/.nvm/versions/node/v16.13.1/lib/node_modules/nativescript/lib/services/project-config-service.js:139:25)
    at ProjectConfigService.getValue (~/.nvm/versions/node/v16.13.1/lib/node_modules/nativescript/lib/services/project-config-service.js:157:27)
    at HooksService.getCustomHooksByName (~/.nvm/versions/node/v16.13.1/lib/node_modules/nativescript/lib/common/services/hooks-service.js:182:56)
    at HooksService.<anonymous> (~/.nvm/versions/node/v16.13.1/lib/node_modules/nativescript/lib/common/services/hooks-service.js:87:42) {
  errno: -2,
  syscall: 'open',
  code: 'ENOENT',
  path: '~/nativescript-context-apis/src/app/package.json'
}
Project dir from hooksArgs is: undefined.
Hooks directories: [
  '~/nativescript-context-apis/src/hooks'
]
No config file found - falling back to ~/nativescript-context-apis/src/nativescript.config.ts.
Project Config Service using legacy configuration...
failed to add embedded package.json data to config Error: ENOENT: no such file or directory, open '~/nativescript-context-apis/src/app/package.json'
    at Object.openSync (node:fs:585:3)
    at Object.readFileSync (node:fs:453:35)
    at FileSystem.readFile (~/.nvm/versions/node/v16.13.1/lib/node_modules/nativescript/lib/common/file-system.js:192:19)
    at FileSystem.readText (~/.nvm/versions/node/v16.13.1/lib/node_modules/nativescript/lib/common/file-system.js:202:21)
    at FileSystem.readJson (~/.nvm/versions/node/v16.13.1/lib/node_modules/nativescript/lib/common/file-system.js:205:27)
    at ProjectConfigService.fallbackToLegacyNSConfig (~/.nvm/versions/node/v16.13.1/lib/node_modules/nativescript/lib/services/project-config-service.js:238:50)
    at ProjectConfigService.readConfig (~/.nvm/versions/node/v16.13.1/lib/node_modules/nativescript/lib/services/project-config-service.js:139:25)
    at ProjectConfigService.getValue (~/.nvm/versions/node/v16.13.1/lib/node_modules/nativescript/lib/services/project-config-service.js:157:27)
    at HooksService.initialize (~/.nvm/versions/node/v16.13.1/lib/node_modules/nativescript/lib/common/services/hooks-service.js:50:56)
    at HooksService.<anonymous> (~/.nvm/versions/node/v16.13.1/lib/node_modules/nativescript/lib/common/services/hooks-service.js:80:18) {
  errno: -2,
  syscall: 'open',
  code: 'ENOENT',
  path: '~/nativescript-context-apis/src/app/package.json'
}
AfterHookName for command resolveCommand is after-resolveCommand
No config file found - falling back to ~/nativescript-context-apis/src/nativescript.config.ts.
Project Config Service using legacy configuration...
failed to add embedded package.json data to config Error: ENOENT: no such file or directory, open '~/nativescript-context-apis/src/app/package.json'
    at Object.openSync (node:fs:585:3)
    at Object.readFileSync (node:fs:453:35)
    at FileSystem.readFile (~/.nvm/versions/node/v16.13.1/lib/node_modules/nativescript/lib/common/file-system.js:192:19)
    at FileSystem.readText (~/.nvm/versions/node/v16.13.1/lib/node_modules/nativescript/lib/common/file-system.js:202:21)
    at FileSystem.readJson (~/.nvm/versions/node/v16.13.1/lib/node_modules/nativescript/lib/common/file-system.js:205:27)
    at ProjectConfigService.fallbackToLegacyNSConfig (~/.nvm/versions/node/v16.13.1/lib/node_modules/nativescript/lib/services/project-config-service.js:238:50)
    at ProjectConfigService.readConfig (~/.nvm/versions/node/v16.13.1/lib/node_modules/nativescript/lib/services/project-config-service.js:139:25)
    at ProjectConfigService.getValue (~/.nvm/versions/node/v16.13.1/lib/node_modules/nativescript/lib/services/project-config-service.js:157:27)
    at HooksService.getCustomHooksByName (~/.nvm/versions/node/v16.13.1/lib/node_modules/nativescript/lib/common/services/hooks-service.js:182:56)
    at HooksService.<anonymous> (~/.nvm/versions/node/v16.13.1/lib/node_modules/nativescript/lib/common/services/hooks-service.js:87:42) {
  errno: -2,
  syscall: 'open',
  code: 'ENOENT',
  path: '~/nativescript-context-apis/src/app/package.json'
}
Trying to handle SIGINT event. CLI overrides this behavior and does not allow handling SIGINT as this causes issues with Ctrl + C in terminal.
The stackTrace of the location trying to handle SIGINT is:
    at process.on (~/.nvm/versions/node/v16.13.1/lib/node_modules/nativescript/lib/nativescript-cli.js:26:28)
    at ~/.nvm/versions/node/v16.13.1/lib/node_modules/nativescript/node_modules/signal-exit/index.js:158:17
    at Array.filter (<anonymous>)
    at load (~/.nvm/versions/node/v16.13.1/lib/node_modules/nativescript/node_modules/signal-exit/index.js:156:23)
    at module.exports (~/.nvm/versions/node/v16.13.1/lib/node_modules/nativescript/node_modules/signal-exit/index.js:62:7)
    at Object.<anonymous> (~/.nvm/versions/node/v16.13.1/lib/node_modules/nativescript/node_modules/proper-lockfile/lib/lockfile.js:331:1)
    at Module._compile (node:internal/modules/cjs/loader:1101:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
spawn: ~/.nvm/versions/node/v16.13.1/bin/node "~/.nvm/versions/node/v16.13.1/lib/node_modules/nativescript/lib/detached-processes/cleanup-process.js" "~/.nvm/versions/node/v16.13.1/lib/node_modules/nativescript/lib/bootstrap.js"
Initializing analytics statuses.
Analytics statuses:  { TrackFeatureUsage: 'enabled', TrackExceptions: 'enabled' }
Will send the following information to Google Analytics: {
  type: 'googleAnalyticsData',
  category: 'CLI',
  googleAnalyticsDataType: 'pageview',
  path: 'plugin build',
  title: 'plugin build',
  customDimensions: { cd5: 'CLI', cd2: 'Pure TypeScript', cd9: 'false' }
}
spawn: ~/.nvm/versions/node/v16.13.1/bin/node "~/.nvm/versions/node/v16.13.1/lib/node_modules/nativescript/lib/services/analytics/analytics-broker-process.js" "~/.nvm/versions/node/v16.13.1/lib/node_modules/nativescript/lib/bootstrap.js"
Will send the following information to Google Analytics: {
  type: 'googleAnalyticsData',
  category: 'CLI',
  googleAnalyticsDataType: 'event',
  action: 'Options',
  label: '{"log":"trace","$0":"ns","profileDir":"private","bundle":"webpack"}',
  customDimensions: { cd2: 'Pure TypeScript', cd9: 'false', cd5: 'CLI' },
  value: undefined
}
Shasum of file ~/nativescript-context-apis/src/platforms/android/README.md is 45f2f63427be0a461a7e2dfd5ff0ad5bab64068f
Shasum of file ~/nativescript-context-apis/src/platforms/android/AndroidManifest.xml is a49c6297b29f6fca5b1b61650dae089ff2181ba0
Shasum of file ~/nativescript-context-apis/src/platforms/android/include.gradle is c5d0724464fa299cfa6642b73471c394124e08da
Shasum of file ~/nativescript-context-apis/src/platforms/android/contextapis-release.aar is 92983b4b520ca94459e16bdc33cb26cf4ca8b2e8
No config file found - falling back to ~/nativescript-context-apis/src/nativescript.config.ts.
Project Config Service using legacy configuration...
failed to add embedded package.json data to config Error: ENOENT: no such file or directory, open '~/nativescript-context-apis/src/app/package.json'
    at Object.openSync (node:fs:585:3)
    at Object.readFileSync (node:fs:453:35)
    at FileSystem.readFile (~/.nvm/versions/node/v16.13.1/lib/node_modules/nativescript/lib/common/file-system.js:192:19)
    at FileSystem.readText (~/.nvm/versions/node/v16.13.1/lib/node_modules/nativescript/lib/common/file-system.js:202:21)
    at FileSystem.readJson (~/.nvm/versions/node/v16.13.1/lib/node_modules/nativescript/lib/common/file-system.js:205:27)
    at ProjectConfigService.fallbackToLegacyNSConfig (~/.nvm/versions/node/v16.13.1/lib/node_modules/nativescript/lib/services/project-config-service.js:238:50)
    at ProjectConfigService.readConfig (~/.nvm/versions/node/v16.13.1/lib/node_modules/nativescript/lib/services/project-config-service.js:139:25)
    at ProjectConfigService.getValue (~/.nvm/versions/node/v16.13.1/lib/node_modules/nativescript/lib/services/project-config-service.js:157:27)
    at PackageManager.<anonymous> (~/.nvm/versions/node/v16.13.1/lib/node_modules/nativescript/lib/package-manager.js:108:61)
    at Generator.next (<anonymous>) {
  errno: -2,
  syscall: 'open',
  code: 'ENOENT',
  path: '~/nativescript-context-apis/src/app/package.json'
}
Exec npm view @nativescript/android  dist-tags --json 
 stdout: {
  "rc": "8.2.0-rc.0",
  "latest": "8.2.2",
  "alpha": "8.2.0-alpha.11"
}
 
 stderr: 
Exec npm view @nativescript/[email protected]  version_info --json 
 stdout: {
  "v8": "8.3.110.9",
  "gradle": "7.4",
  "gradleAndroid": "7.1.2",
  "ndk": "r21",
  "ndkApiLevel": "122",
  "minSdk": "17",
  "compileSdk": "31",
  "buildTools": "31.0.0",
  "kotlin": "1.6.0"
}
 
 stderr: 
Got gradle versions {"gradleVersion":"7.4","gradleAndroidPluginVersion":"7.1.2"} from the latest runtime v8.2.2
Project dir from hooksArgs is: undefined.
Hooks directories: [
  '~/nativescript-context-apis/src/hooks'
]
No config file found - falling back to ~/nativescript-context-apis/src/nativescript.config.ts.
Project Config Service using legacy configuration...
failed to add embedded package.json data to config Error: ENOENT: no such file or directory, open '~/nativescript-context-apis/src/app/package.json'
    at Object.openSync (node:fs:585:3)
    at Object.readFileSync (node:fs:453:35)
    at FileSystem.readFile (~/.nvm/versions/node/v16.13.1/lib/node_modules/nativescript/lib/common/file-system.js:192:19)
    at FileSystem.readText (~/.nvm/versions/node/v16.13.1/lib/node_modules/nativescript/lib/common/file-system.js:202:21)
    at FileSystem.readJson (~/.nvm/versions/node/v16.13.1/lib/node_modules/nativescript/lib/common/file-system.js:205:27)
    at ProjectConfigService.fallbackToLegacyNSConfig (~/.nvm/versions/node/v16.13.1/lib/node_modules/nativescript/lib/services/project-config-service.js:238:50)
    at ProjectConfigService.readConfig (~/.nvm/versions/node/v16.13.1/lib/node_modules/nativescript/lib/services/project-config-service.js:139:25)
    at ProjectConfigService.getValue (~/.nvm/versions/node/v16.13.1/lib/node_modules/nativescript/lib/services/project-config-service.js:157:27)
    at HooksService.initialize (~/.nvm/versions/node/v16.13.1/lib/node_modules/nativescript/lib/common/services/hooks-service.js:50:56)
    at HooksService.<anonymous> (~/.nvm/versions/node/v16.13.1/lib/node_modules/nativescript/lib/common/services/hooks-service.js:80:18) {
  errno: -2,
  syscall: 'open',
  code: 'ENOENT',
  path: '~/nativescript-context-apis/src/app/package.json'
}
BeforeHookName for command buildAndroidPlugin is before-buildAndroidPlugin
No config file found - falling back to ~/nativescript-context-apis/src/nativescript.config.ts.
Project Config Service using legacy configuration...
failed to add embedded package.json data to config Error: ENOENT: no such file or directory, open '~/nativescript-context-apis/src/app/package.json'
    at Object.openSync (node:fs:585:3)
    at Object.readFileSync (node:fs:453:35)
    at FileSystem.readFile (~/.nvm/versions/node/v16.13.1/lib/node_modules/nativescript/lib/common/file-system.js:192:19)
    at FileSystem.readText (~/.nvm/versions/node/v16.13.1/lib/node_modules/nativescript/lib/common/file-system.js:202:21)
    at FileSystem.readJson (~/.nvm/versions/node/v16.13.1/lib/node_modules/nativescript/lib/common/file-system.js:205:27)
    at ProjectConfigService.fallbackToLegacyNSConfig (~/.nvm/versions/node/v16.13.1/lib/node_modules/nativescript/lib/services/project-config-service.js:238:50)
    at ProjectConfigService.readConfig (~/.nvm/versions/node/v16.13.1/lib/node_modules/nativescript/lib/services/project-config-service.js:139:25)
    at ProjectConfigService.getValue (~/.nvm/versions/node/v16.13.1/lib/node_modules/nativescript/lib/services/project-config-service.js:157:27)
    at HooksService.getCustomHooksByName (~/.nvm/versions/node/v16.13.1/lib/node_modules/nativescript/lib/common/services/hooks-service.js:182:56)
    at HooksService.<anonymous> (~/.nvm/versions/node/v16.13.1/lib/node_modules/nativescript/lib/common/services/hooks-service.js:87:42) {
  errno: -2,
  syscall: 'open',
  code: 'ENOENT',
  path: '~/nativescript-context-apis/src/app/package.json'
}
Selected targetSdk is: 32
Installed Android Targets are:  [ 'android-29', 'android-30', 'android-31', 'android-32' ]
Selected buildToolsVersion is: 32.0.0
spawn: /var/folders/5q/6zrvvtkj5_g7l948bjdttwwr0000gn/T/android-project2022230-44184-xpwr89.jmdfq/nativescript_context_apis/gradlew "-p" "/var/folders/5q/6zrvvtkj5_g7l948bjdttwwr0000gn/T/android-project2022230-44184-xpwr89.jmdfq/nativescript_context_apis" "assembleRelease" "-PcompileSdk=android-32" "-PbuildToolsVersion=32.0.0" "-PappPath=~/nativescript-context-apis/src/app" "-PappResourcesPath=~/nativescript-context-apis/src/App_Resources"

FAILURE: Build failed with an exception.

* Where:
Build file '/private/var/folders/5q/6zrvvtkj5_g7l948bjdttwwr0000gn/T/android-project2022230-44184-xpwr89.jmdfq/nativescript_context_apis/build.gradle' line: 38

* What went wrong:
A problem occurred evaluating root project 'nativescript_context_apis'.
> /private/var/folders/5q/6zrvvtkj5_g7l948bjdttwwr0000gn/platforms/android/dependencies.json (No such file or directory)

* 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

Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.

You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

See https://docs.gradle.org/7.4/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 783ms
Failed to build plugin nativescript-context-apis : 
Error: Command ./gradlew failed with exit code 1
Error: Failed to build plugin nativescript-context-apis : 
Error: Command ./gradlew failed with exit code 1
    at Errors.failWithOptions (~/.nvm/versions/node/v16.13.1/lib/node_modules/nativescript/lib/common/errors.js:157:27)
    at Errors.fail (~/.nvm/versions/node/v16.13.1/lib/node_modules/nativescript/lib/common/errors.js:130:21)
    at AndroidPluginBuildService.<anonymous> (~/.nvm/versions/node/v16.13.1/lib/node_modules/nativescript/lib/services/android-plugin-build-service.js:470:30)
    at Generator.throw (<anonymous>)
    at rejected (~/.nvm/versions/node/v16.13.1/lib/node_modules/nativescript/lib/services/android-plugin-build-service.js:12:65)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)


### Environment

```yaml
OS: macOS 12.2.1
CPU: (8) arm64 Apple M1
Shell: /bin/zsh
node: 16.13.1
npm: 8.3.2
nativescript: 8.2.3

# android
java: 11.0.11
ndk: Not Found
apis: 29, 30, 31, 32
build_tools: 29.0.0, 30.0.3, 32.0.0
system_images:
  - android-31 | Google Play ARM 64 v8a
  - android-32 | Google Play ARM 64 v8a

# ios
xcode: 13.3/13E113
cocoapods: 1.11.2
python: 2.7.18
python3: 3.8.9
ruby: 2.6.8
platforms:
  - DriverKit 21.4
  - iOS 15.4
  - macOS 12.3
  - tvOS 15.4
  - watchOS 8.5

Dependencies

"dependencies": {
  "@nativescript/geolocation": "^8.0.2",
  "@triniwiz/nativescript-couchbase": "~1.3.1",
  "nativescript-permissions": "1.3.11",
  "rxjs": "^7.5.5"
},
"devDependencies": {
  "@nativescript/core": "~8.2.0",
  "@nativescript/types": "~8.2.0",
  "prompt": "^1.0.0",
  "rimraf": "^2.6.3",
  "semver": "^5.6.0",
  "tslint": "^5.12.1",
  "typescript": "~4.5.5"
}

Please accept these terms

@agonper agonper added the bug-pending-triage Reported bug, pending triage to confirm. label Mar 30, 2022
@grigala
Copy link

grigala commented Apr 28, 2022

Hi @agonper, I have exactly the same problem when building a plugin using tns build plugin. I don't think it's targetSdk 32 related though, I have the same thing with 31.

I discovered that the only way to tell NS where to look for package.json is to switch to nativescript.config.ts file where you can override the location of the app directory.

import { NativeScriptConfig } from '@nativescript/core';

export default {
  id: 'org.nativescript.app',
  appPath: '.',
  appResourcesPath: 'App_Resources',
  android: {
    v8Flags: '--expose_gc',
    markingMode: 'none',
  },
  cli: {
    packageManager: "npm",
    /**
     * Optional - Override the files or paths to clean when running the `ns clean` command
     */
    pathsToClean: ["node_modules"],
    /**
     * Optional - Additional files or paths to clean when running the `ns clean` command, the paths are appended to the
     * default list of paths.
     */
    additionalPathsToClean: [],
  },
  useLegacyWorkflow: false,
} as NativeScriptConfig;

This should fix that particular error Error: ENOENT: no such file or directory, open '***/app/package.json'. But then I am getting this weird SIGINT error, exactly the same as #5186 which is an old issue but

It appears that this is not just plugin build command related when I run:

tns info --log trace
tns info --log trace

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*                                                                                                                                               *
*  The "TRACE" log level might print some sensitive data like secrets or access tokens in request URLs. Be careful when you share this output.  *
*                                                                                                                                               *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *


Trying to get macOS version.
Exec system_profiler SPSoftwareDataType -detailLevel mini 
 stdout: Software:

    System Software Overview:

      System Version: macOS 12.3.1 (21E258)
      Kernel Version: Darwin 21.4.0
      Time since boot: 4 days 11:54

 
 stderr: 
macOS version based on system_profiler is 12.3.
Looking for project in '***'
Project directory is '***'.
You have both a nativescript.config.js and nativescript.config.ts file. Defaulting to nativescript.config.ts.
Initializing project identifiers. Config:  {
  id: 'org.nativescript.app',
  appPath: '.',
  appResourcesPath: 'App_Resources',
  android: { v8Flags: '--expose_gc', markingMode: 'none' },
  cli: {
    packageManager: 'npm',
    pathsToClean: [ 'node_modules' ],
    additionalPathsToClean: []
  },
  useLegacyWorkflow: false
}
Loading extensions.
Collecting system information...
System information:
{
  "platform": "darwin",
  "shell": "/bin/zsh",
  "os": "Darwin MacBook-Pro.local 21.4.0 Darwin Kernel Version 21.4.0: Fri Mar 18 00:45:05 PDT 2022; root:xnu-8020.101.4~15/RELEASE_X86_64 x86_64\n",
  "procArch": "x64",
  "nodeVer": "16.15.0",
  "npmVer": "8.5.5",
  "nodeGypVer": null,
  "nativeScriptCliVersion": null,
  "gitVer": "2.34.1",
  "dotNetVer": null,
  "javacVersion": "11.0.14",
  "javaVersion": "11.0.14",
  "javaPath": "/Users/george/.sdkman/candidates/java/current/bin/java",
  "adbVer": "1.0.41",
  "androidInstalled": true,
  "monoVer": null,
  "gradleVer": "7.3.3",
  "isAndroidSdkConfiguredCorrectly": true,
  "xcodeVer": "13.3.1",
  "xcodeprojLocation": "/usr/local/bin/xcodeproj",
  "itunesInstalled": false,
  "cocoaPodsVer": "1.11.3",
  "isCocoaPodsWorkingCorrectly": true,
  "isCocoaPodsUpdateRequired": false,
  "pythonInfo": {
    "isInstalled": true,
    "isSixPackageInstalled": true
  }
}
Current CLI version:  8.2.3
Project dir from hooksArgs is: undefined.
Hooks directories: [ '***src/hooks' ]
You have both a nativescript.config.js and nativescript.config.ts file. Defaulting to nativescript.config.ts.
BeforeHookName for command resolveCommand is before-resolveCommand
You have both a nativescript.config.js and nativescript.config.ts file. Defaulting to nativescript.config.ts.
Project dir from hooksArgs is: undefined.
Hooks directories: [ '***/src/hooks' ]
You have both a nativescript.config.js and nativescript.config.ts file. Defaulting to nativescript.config.ts.
AfterHookName for command resolveCommand is after-resolveCommand
You have both a nativescript.config.js and nativescript.config.ts file. Defaulting to nativescript.config.ts.
Trying to handle SIGINT event. CLI overrides this behavior and does not allow handling SIGINT as this causes issues with Ctrl + C in terminal.
The stackTrace of the location trying to handle SIGINT is:
    at process.on (/usr/local/lib/node_modules/nativescript/lib/nativescript-cli.js:26:28)
    at /usr/local/lib/node_modules/nativescript/node_modules/signal-exit/index.js:158:17
    at Array.filter (<anonymous>)
    at load (/usr/local/lib/node_modules/nativescript/node_modules/signal-exit/index.js:156:23)
    at module.exports (/usr/local/lib/node_modules/nativescript/node_modules/signal-exit/index.js:62:7)
    at Object.<anonymous> (/usr/local/lib/node_modules/nativescript/node_modules/proper-lockfile/lib/lockfile.js:331:1)
    at Module._compile (node:internal/modules/cjs/loader:1105:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
spawn: /usr/local/bin/node "/usr/local/lib/node_modules/nativescript/lib/detached-processes/cleanup-process.js" "/usr/local/lib/node_modules/nativescript/lib/bootstrap.js"
Initializing analytics statuses.
Analytics statuses:  { TrackFeatureUsage: 'disabled', TrackExceptions: 'disabled' }
⠋ Getting NativeScript components versions information...You have both a nativescript.config.js and nativescript.config.ts file. Defaulting to nativescript.config.ts.
Determined packageManager to use from user config is: npm
⠋ Getting NativeScript components versions information...Exec npm view nativescript  dist-tags --json 
 stdout: {
  "next": "8.2.3-next-04-06-2022-2104719071",
  "alpha": "8.2.4-alpha.0",
  "latest": "8.2.3"
}
 
 stderr: 
Using version 8.2.3. 
⠇ Getting NativeScript components versions information...Exec npm view tns-core-modules  dist-tags --json 
 stdout: {
  "tns-next": "6.5.25-tns-next-09-28-2021-1283647697",
  "latest": "6.5.27"
}
 
 stderr: 
Using version 6.5.27. 
⠼ Getting NativeScript components versions information...Exec npm view @nativescript/ios  dist-tags --json 
 stdout: {
  "rc": "8.1.0-rc.1",
  "alpha": "8.2.4-alpha.1",
  "custom": "8.2.0-alpha.7",
  "JSC": "6.5.5",
  "latest": "8.2.3"
}
 
 stderr: 
Using version 8.2.3. 
Exec npm view @nativescript/android  dist-tags --json 
 stdout: {
  "rc": "8.2.0-rc.0",
  "alpha": "8.2.0-alpha.11",
  "latest": "8.2.2"
}
 
 stderr: 
Using version 8.2.2. 
✔ Getting NativeScript components versions information...
✔ Component nativescript has 8.2.3 version and is up to date.
✔ Component @nativescript/ios has 8.2.3 version and is up to date.
✔ Component @nativescript/android has 8.2.2 version and is up to date.

@rigor789
Copy link
Member

The SIGINT part is unrelated - that's normal - it doesn't indicate a failure

Trying to handle SIGINT event. CLI overrides this behavior and does not allow handling SIGINT as this causes issues with Ctrl + C in terminal.
The stackTrace of the location trying to handle SIGINT is:
    at process.on (/usr/local/lib/node_modules/nativescript/lib/nativescript-cli.js:26:28)
    at /usr/local/lib/node_modules/nativescript/node_modules/signal-exit/index.js:158:17
    at Array.filter (<anonymous>)
    at load (/usr/local/lib/node_modules/nativescript/node_modules/signal-exit/index.js:156:23)
    at module.exports (/usr/local/lib/node_modules/nativescript/node_modules/signal-exit/index.js:62:7)
    at Object.<anonymous> (/usr/local/lib/node_modules/nativescript/node_modules/proper-lockfile/lib/lockfile.js:331:1)
    at Module._compile (node:internal/modules/cjs/loader:1105:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)

@grigala
Copy link

grigala commented Apr 28, 2022

The SIGINT part is unrelated - that's normal - it doesn't indicate a failure

Well it clearly crashes plugin build and that's the only error in the detailed logs, so something must be related.
The normal tns plugin build run without --log trace does not make sense at all:

FAILURE: Build failed with an exception.

* Where:
Build file '/private/var/folders/p4/sl5tq_l94y30x3sr7t82kqdh0000gn/T/android-project2022328-1547-ga7cpq.a5i7v/***/build.gradle' line: 38

* What went wrong:
A problem occurred evaluating root project '***'.
> /private/var/folders/p4/sl5tq_l94y30x3sr7t82kqdh0000gn/platforms/android/dependencies.json (No such file or directory)

* 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 587ms
Failed to build plugin ***:
Error: Command ./gradlew failed with exit code 1

Could it be somehow related to #5664? - I just noticed that compileSdk version is 32 even thought I have it set to 31 in the build.gradle file:

spawn: /var/folders/p4/sl5tq_l94y30x3sr7t82kqdh0000gn/T/android-project2022328-2849-1jj9zr7.ivl7/***/gradlew 
"-p"
"/var/folders/p4/sl5tq_l94y30x3sr7t82kqdh0000gn/T/android-project2022328-2849-1jj9zr7.ivl7/***" 
"assembleRelease" 
"-PcompileSdk=android-32" 
"-PbuildToolsVersion=31.0.0" 
"-PappPath=/plugin/src" 
"-PappResourcesPath=/plugin/src/App_Resources"

So my initial comment that it might not be related to SDK 32 could be wrong... No idea at this point.

@rigor789
Copy link
Member

The build fails on the gradle side, why it does - I'm not sure yet, haven't had a chance to dig deeper myself. Just thought I'd chime in on the SIGINT part to avoid going down that path, as it is definitely not the cause of the failure.

@grigala
Copy link

grigala commented Apr 28, 2022

Ahm, ok, thanks for clarifying.

Is there a way to get a hold of that gradlew:assembleRelease task trace? I asked about it once on Discord, but the only known detailed log output command I know of is --log trace.

Annoyingly enough, this file gets wiped out as soon as process exits, so I have no chance of looking into that file and see what's happening on line 38 - but it must be something generic as @agonper has the same line error.
Build file '/private/var/folders/p4/sl5tq_l94y30x3sr7t82kqdh0000gn/T/android-project2022328-1547-ga7cpq.a5i7v/***/build.gradle' line: 38

Got gradle versions {"gradleVersion":"7.4","gradleAndroidPluginVersion":"7.1.2"} from the latest runtime v8.2.2
Project dir from hooksArgs is: undefined.
Hooks directories: [ '/plugin/src/hooks' ]
You have both a nativescript.config.js and nativescript.config.ts file. Defaulting to nativescript.config.ts.
BeforeHookName for command buildAndroidPlugin is before-buildAndroidPlugin
You have both a nativescript.config.js and nativescript.config.ts file. Defaulting to nativescript.config.ts.
Selected targetSdk is: 32
Installed Android Targets are:  [ 'android-30', 'android-31', 'android-32' ]
Selected buildToolsVersion is: 31.0.0
spawn: /var/folders/p4/sl5tq_l94y30x3sr7t82kqdh0000gn/T/android-project2022328-2849-1jj9zr7.ivl7/***/gradlew 
"-p" 
"/var/folders/p4/sl5tq_l94y30x3sr7t82kqdh0000gn/T/android-project2022328-2849-1jj9zr7.ivl7/***" 
"assembleRelease" 
"-PcompileSdk=android-32" 
"-PbuildToolsVersion=31.0.0" 
"-PappPath=/plugin/src" 
"-PappResourcesPath=/plugin/src/App_Resources"

> Task :plugin:build FAILED

@grigala
Copy link

grigala commented Sep 29, 2022

@rigor789 an update regarding this one.

The big problem that I was finding very annoying up until now was the fact that the temp directory from where the error is thrown was being deleted immediately. So I was not able to go back and inspect the project or look at what's wrong at the reported line Build file '/private/var/folders/p4/sl5tq_l94y30x3sr7t82kqdh0000gn/T/android-project***/build.gradle' line: 38.

Fortunately, I've managed to by watching the directory and copying everything recursively obtain a copy of the project that is generated. Below is the command that is being executed:

spawn: 
/var/folders/p4/sl5tq_l94y30x3sr7t82kqdh0000gn/T/android-project2022829-41426-19roham.spy4/my_project/gradlew 
"-p" 
"/var/folders/p4/sl5tq_l94y30x3sr7t82kqdh0000gn/T/android-project2022829-41426-19roham.spy4/my_project" 
"assembleRelease" 
"-PcompileSdk=android-32" 
"-PbuildToolsVersion=32.0.0" 
"-PappPath=/Users/.../my_projectt/plugin/src" 
"-PappResourcesPath=/Users/george/.../my_project/plugin/src/App_Resources"

And this is the error being produced by the command:

FAILURE: Build failed with an exception.

* Where:
Build file '/private/var/folders/p4/sl5tq_l94y30x3sr7t82kqdh0000gn/T/
android-project2022829-41426-19roham.spy4/my_project/build.gradle' line: 38

* What went wrong:
A problem occurred evaluating root project 'my_project'.
> /private/var/folders/p4/sl5tq_l94y30x3sr7t82kqdh0000gn/platforms/android/dependencies.json (No such file or directory)

So here is the line 38 from the generated android-project2022829-41426-19roham.spy4s build.gradle file, that is going crazy:
image

We are clearly looking for this /platforms/android/dependencies.json which is not there.

Notice the path where we are looking for it /private/var/folders/p4/sl5tq_l94y30x3sr7t82kqdh0000gn/, it's in a completely different location than generated project folder, which is located at: /private/var/folders/p4/sl5tq_l94y30x3sr7t82kqdh0000gn/T/android-project2022829-41426-19roham.spy4/my_project.

When or by which task this file is being generated?

Found the template in the source code as well:

project.ext.USER_PROJECT_ROOT = "$rootDir/../../.."
project.ext.PLATFORMS_ANDROID = "platforms/android"
project.ext.PLUGIN_NAME = "{{pluginName}}"
// the build script will not work with previous versions of the CLI (3.1 or earlier)
def dependenciesJson = file("${project.ext.USER_PROJECT_ROOT}/${project.ext.PLATFORMS_ANDROID}/dependencies.json")
def appDependencies = new JsonSlurper().parseText(dependenciesJson.text)

@grfalk
Copy link

grfalk commented Dec 20, 2022

I am experiencing exactly the same issue.

I use macOS and I am also seeing what appears to be the missing ".../T/..." in the path to the missing "dependencies.json" file referenced in the build error output (as nicely detailed by @grigala in the Sep 29 post above). This leads me to believe the error is more about "no such directory" than it is about "no such file", as I have added a "dependencies.json" file to my plugin project (containing only an empty JSON array "[]"), but I continue to receive the same error.

@agonper / @grigala - did you discover a solution - or a workaround - to this issue?

If so, posting an update would be greatly appreciated! Thank you.

@grigala
Copy link

grigala commented Dec 20, 2022

Hi @grfalk, adding an empty dependencies.json to your project would not change much. I wish it was that easy.

So, after my last discussion with the core members, they all admitted that it's clearly a bug they've introduced, but they've all been surprised that we are still using this way of building plugins, which apparently is considered kind of "legacy" way of doing it (broken legacy way), and they themselves haven't been doing it in this way for a long time. Instead, they are using NX workspace way, like packing the sources directly.

As I didn't get much of an additional feedback, I gave up on it and all my plugins are simply frozen where they were. Migrating to their proposed "just pack sources" isn't trivial and would require quite an effort in my case due to a lot of complexity in my plugins, but maybe it could work fine in your case - give it a go.

@grfalk
Copy link

grfalk commented Dec 20, 2022

@grigala - thank you very much for your reply. It explains a lot regarding what I have been experiencing regarding this error, as well what I am seeing when reviewing {N} tooling source code.

So, based on the feedback you received the {N} core team members...

...they all admitted that it's clearly a bug they've introduced, but they've all been surprised that we are still using this way of building plugins...

...does that imply that all the "current" (i.e.- v7) NativeScript Plugin documentation is no longer valid/applicable?

e.g. - Plugin Reference and tns plugin build

Or is there updated {N} documentation that I am missing regarding how to create/manage {N} plugin projects using the NX project build paradigm?

I am migrating a {N} v6 plugin to be compatible with {N} v7/8, which is how I found myself in {N} "legacy-land". I have completed the required modifications to the plugin's Typescript and native source code for both platforms such that it is now compatible with {N} v7/8. I am now simply attempting to use tns plugin build to create the plugin archive. Creating the .tgz archive is simple enough. What I am relying on the tns plugin build command to do is generate the .aar archive for the Android platform.

@grigala (or anyone else reading this) - do know if there is a version of {N} I could "fallback to" where the logic associated with the tns plugin build build command has not yet been munged to work with the NX project build paradigm?

@grigala
Copy link

grigala commented Dec 21, 2022

@grfalk

...does that imply that all the "current" (i.e.- v7) NativeScript Plugin documentation is no longer valid/applicable?

No, it's valid if you are building with an older CLI tools. They introduced this bug in v8.2 I think.

Documentation is a mess to be honest, they didn't migrate from v7 to v8 properly, and I often find myself in the situation when the documentation is available for v7 but nowhere to be found for current. 🤷‍♂️

@grfalk
Copy link

grfalk commented Dec 21, 2022

So, after my last discussion with the core members, they all admitted that it's clearly a bug they've introduced, but they've all been surprised that we are still using this way of building plugins, which apparently is considered kind of "legacy" way of doing it (broken legacy way), and they themselves haven't been doing it in this way for a long time. Instead, they are using NX workspace way, like packing the sources directly.

So... if I "read between the lines", this issue is low priority (an assumption on my part because it has been open since 2022-03) because it does not negatively affecting the (newer) NX-based build approach for plugins (or possibly supports it?), yet broke the (now legacy?) tns plugin build functionality that has been a part of the {N} architecture for years? And at the same time, the move to the NX build approach for plugins has not been documented, nor have details been provided for migrating "legacy" plugin projects to the NX build paradigm?

I am aware that with the release of {N} v7, the {N} team updated all the {N} team-managed plugins to be compatible and consolidated them into a single repo project managed by NX. Using NX to manage a repo that is composed of 34 (formerly standalone) plugin subprojects makes sense to do. But expecting all organizations/individuals in the {N} community that use custom (or extended {N}-managed) plugins to spontaneously do the same without any official notification or documentation is questionable (at best). Organizations that utilize plugins in their {N} app(s) must be given notice, and need to be allotted time, to make such a migration for {N}-based products that are used in production scenarios. Moreover, use of the tns plugin build command, coupled with a few shell scripts, is all that I currently need to manage my one custom {N} plugin project.

OK - I am done venting. Back to this issue.

@grigala I tried falling back to {N} v8.1.x, but ran into issues apparently related to #1706 and #9814 (and both have been closed with "fixed in v8.2.x" as the solution). I also briefly tried falling back to {N} v7.x.y and ran into different issues when attempting to build my plugin using the tns plugin build command. Were you successful in any attempt to build your plugins with any {N} v7.0.0 or greater?

The big problem that I was finding very annoying up until now was the fact that the temp directory from where the error is thrown was being deleted immediately. Fortunately, I've managed to by watching the directory and copying everything recursively obtain a copy of the project that is generated.

@grigala Because I need to update my custom plugin in short order, I used your approach (quoted above) to "capture" the gradle project created by the execution of the tns plugin build command (using {N} v6.x.y). I am going to apply various "tooling version" updates to this project's references, then incorporate it into my custom plugin's build process in order build the version of my custom plugin that is compatible with {N} v7/8.

In the meantime, I will wait to see what the {N} team decides to do about the functionality tns plugin build command (if anything).

@grigala Thank you again for you replies 🙏. They have proven to be quite helpful.

@madmas
Copy link
Contributor

madmas commented Jan 24, 2023

Hi, I also digged into this ....and also found some PR that are open regarding the android build process, namely #5671 and #5578
maaybe those could help to fix this problem as in "simplify the current situation and then buld a clean solution on top of it? WDYT @farfromrefug ?

@farfromrefug
Copy link
Contributor

@madmas it could fix it. You can all easily test this by pulling my main branch, build and test with it

@jerbob92
Copy link

jerbob92 commented Mar 8, 2023

For everyone following, I can confirm that you can do the following to fix it:

  • Remove the .aar file from your platforms/android folder
  • Remove lines like this from the .npmignore file:
    • platforms/android/*
    • !platforms/android/include.gradle
    • !platforms/android/*.aar
    • !platforms/android/*.jar
  • Remove the tns plugin build part and scripts from your build process

See this commit for an example in my project.

This way it will ship the sources in platforms/android in your npm package and {N} will build it when people run an application that uses your plugin.

@jakovMR
Copy link

jakovMR commented Mar 15, 2023

@grfalk Try with this version (https://www.npmjs.com/package/nativescript/v/8.1.5-next-02-20-2022-1872272336). As I tested with this version, gradle issue is fixed while dependencies.json issue is not yet introduced.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug-pending-triage Reported bug, pending triage to confirm.
Projects
None yet
Development

No branches or pull requests

8 participants