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

Can't build any plugins (Android) *Failed to build plugin @nativesctript/core #5649

Closed
3 tasks done
CTOaramos opened this issue Mar 13, 2022 · 35 comments
Closed
3 tasks done
Labels

Comments

@CTOaramos
Copy link

CTOaramos commented Mar 13, 2022

Issue Description

Hi, does anyone experienced this ? im trying to run the Hello World Template (Pure Typescript)
Screen Shot 2022-03-13 at 9 46 56 AM

Here's my current versions
Screen Shot 2022-03-13 at 9 48 08 AM

Reproduction

No response

Relevant log output (if applicable)

No response

Environment

No response

Please accept these terms

@CTOaramos CTOaramos added the bug-pending-triage Reported bug, pending triage to confirm. label Mar 13, 2022
@NathanWalker
Copy link
Contributor

@CTOaramos looks like potentially sdk version related - when possible could you run this command and post the results:

echo 'y' | npx nativescript-envinfo

@CTOaramos
Copy link
Author

CTOaramos commented Mar 13, 2022

Hi, @NathanWalker thank you for the response here it is;
Screen Shot 2022-03-13 at 3 36 55 PM

im not sure why is that not found; i have my emulator running from android studio i have downloaded some build tools
Screen Shot 2022-03-13 at 3 44 32 PM
Screen Shot 2022-03-13 at 3 44 39 PM

heres my zshrc;
Screen Shot 2022-03-13 at 3 47 02 PM

i don't know how can i fix that not found issue ;

im just trying to run the hello world template;

what i have tried so far

  • test to run on jave version 8, 11, 17
  • downgrade nativescript to @8.1
  • downgrade node to @14

@CTOaramos
Copy link
Author

CTOaramos commented Mar 13, 2022

Hi, @NathanWalker, I have added sdkmanager in the $PATH and the it changed;
Screen Shot 2022-03-13 at 4 15 13 PM
Screen Shot 2022-03-13 at 4 25 37 PM
Screen Shot 2022-03-13 at 4 47 49 PM

but im still getting the error
Screen Shot 2022-03-13 at 4 15 21 PM

@CTOaramos
Copy link
Author

CTOaramos commented Mar 13, 2022

I downloaded obsolete version of ndk; nativescript-envinfo #android now have all value; but im still getting
Screen Shot 2022-03-13 at 5 29 02 PM
Screen Shot 2022-03-13 at 5 29 45 PM
Screen Shot 2022-03-13 at 5 30 27 PM
Screen Shot 2022-03-13 at 5 30 43 PM
Screen Shot 2022-03-13 at 5 30 37 PM
Screen Shot 2022-03-13 at 5 30 54 PM

This is app is the Hello World template;
Screen Shot 2022-03-13 at 5 32 32 PM

@rigor789
Copy link
Member

@CTOaramos please share your package.json - we can try reproducing with your dependencies...

But before any of that, please make sure you install the latest cli - seems like you are on 8.1.5.
There were some fixed in 8.2.x cli that would affect the plugin builds.

npm i -g nativescript

@CTOaramos
Copy link
Author

Hi, @rigor789 Im running the Hello World template Typescript;

i updated to 8.2.2 still getting error
Screen Shot 2022-03-15 at 7 52 12 AM
Screen Shot 2022-03-15 at 7 52 24 AM
;

@milosmatic
Copy link

milosmatic commented Mar 15, 2022

I can confirm that I'm getting the same issue on both newly created projects and existing ones.

  • node v17.7.1
  • npm v8.5.2
  • ns v8.2.2

I'm using M1 Mac.

@rigor789
Copy link
Member

Please post the stack-trace, so we can do some searching as well - seems to happen for a few people, but not everyone - there must be some correlation between the cases, we just don't know what yet...

Since gradle itself is throwing the error, I believe it to be a gradle bug/issue - that's what I would focus my search on...

@milosmatic
Copy link

image

image

@rigor789
Copy link
Member

Please include it in a textual form - I can't copy it from screenshots.

@milosmatic
Copy link

ns build android
Copying template files...
⠼ (##################) ⠏ reify:@nativescript/android: http fetch GET 200 https://registry.npmjs.org/@nativescript/android/-/android-8.2.2.Platform android successfully added. v8.2.2
Preparing project...
asset vendor.js 15.4 MiB [emitted] (name: vendor) (id hint: defaultVendor)
asset bundle.js 353 KiB [emitted] (name: bundle)
asset runtime.js 12.5 KiB [emitted] (name: runtime)
Entrypoint bundle 15.8 MiB = runtime.js 12.5 KiB vendor.js 15.4 MiB bundle.js 353 KiB
runtime modules 2.72 KiB 8 modules
orphan modules 576 bytes [orphan] 7 modules
modules by path ./node_modules/ 5.2 MiB
javascript modules 4.94 MiB 560 modules
json modules 273 KiB
modules by path ./node_modules/mdn-data/css/.json 242 KiB 3 modules
modules by path ./node_modules/css-tree/ 30.7 KiB 2 modules
modules by path ./src/ 125 KiB
modules by path ./src/app/ 6.62 KiB 6 modules
modules by path ./src/
.ts 840 bytes
./src/polyfills.ts 545 bytes [built] [code generated]
./src/main.ts 295 bytes [built] [code generated]
./src/app.css 118 KiB [built] [code generated]
external "~/package.json" 42 bytes [optional] [built] [code generated]
webpack 5.67.0 compiled successfully in 6132 ms
Webpack compilation complete.
Failed to build plugin @nativescript/core :
Error: spawn ./gradlew ENOENT

Exception in thread "DisconnectableInputStream source reader" org.gradle.api.UncheckedIOException: java.io.IOException: Input/output error
at org.gradle.internal.UncheckedException.throwAsUncheckedException(UncheckedException.java:62)
at org.gradle.internal.UncheckedException.throwAsUncheckedException(UncheckedException.java:41)
at org.gradle.util.internal.DisconnectableInputStream$1.run(DisconnectableInputStream.java:127)
at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: java.io.IOException: Input/output error
at java.base/java.io.FileInputStream.readBytes(Native Method)
at java.base/java.io.FileInputStream.read(FileInputStream.java:279)
at java.base/java.io.BufferedInputStream.read1(BufferedInputStream.java:290)
at java.base/java.io.BufferedInputStream.read(BufferedInputStream.java:351)
at org.gradle.util.internal.DisconnectableInputStream$1.run(DisconnectableInputStream.java:98)
... 1 more
~ applying user-defined configuration from /Users/milos/Projects/ns-test/App_Resources/Android/before-plugins.gradle

@rigor789
Copy link
Member

I couldn't find anything yet - can you run this in a new project, and then zip up the platforms/android folder and share here?

Also try running the build with --log trace and check if perhaps there's more to the stack-trace from gradle - it generally seems like it's trying to read/write a file it has no permission to read/write, but the stack-trace doesn't seem to include the path it's failing on.

@milosmatic
Copy link

Here is the trace log https://pastebin.com/7zGtYWBF

@CTOaramos
Copy link
Author

CTOaramos commented Mar 16, 2022

@rigor789
Copy link
Member

open /usr/local/lib/node_modules/nativescript/lib/services/android-plugin-build-service.js and and around line 463 change the following:

try {
    yield this.$childProcess.spawnFromEvent(gradlew, localArgs, "close", {
        cwd: pluginBuildSettings.pluginDir,
        stdio: "inherit",
    });
}
catch (err) {
    this.$errors.fail(`Failed to build plugin ${pluginBuildSettings.pluginName} : \n${err}`);
}

Add a console log right after the try {:

try {
    console.log('gradlew', gradlew);
    console.log('localArgs', localArgs);
    console.log('pluginBuildSettings.pluginDir', pluginBuildSettings.pluginDir);
    
    yield this.$childProcess.spawnFromEvent(gradlew, localArgs, "close", {
        cwd: pluginBuildSettings.pluginDir,
        stdio: "inherit",
    });
// ...

And build again, and let me know what those logs print - I suspect something might be off there - but not sure what, this might help identify the issue.

@milosmatic
Copy link

@rigor789 here is the log after changes https://pastebin.com/KwCLYVRw

@NathanWalker
Copy link
Contributor

@milosmatic when you get a chance could you run the following command and copy/paste the results (not screenshots) including the invocation of the command visible in the output:

echo 'y' | npx nativescript-envinfo

@milosmatic
Copy link

@NathanWalker here it is

OS: macOS 12.3
CPU: (10) arm64 Apple M1 Pro
Shell: /bin/zsh
node: 17.7.2
npm: 8.5.2
nativescript: 8.2.2

# android
java: 11.0.14.1
ndk: Not Found
apis: 27, 28, 29, 30, 31
build_tools: 27.0.3, 28.0.3, 29.0.3, 30.0.3, 31.0.0
system_images:
  - android-30 | Google Play ARM 64 v8a

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

Dependencies

"dependencies": {
  "@angular/animations": "~13.2.0",
  "@angular/common": "~13.2.0",
  "@angular/compiler": "~13.2.0",
  "@angular/core": "~13.2.0",
  "@angular/forms": "~13.2.0",
  "@angular/platform-browser": "~13.2.0",
  "@angular/platform-browser-dynamic": "~13.2.0",
  "@angular/router": "~13.2.0",
  "@nativescript/angular": "^13.0.0",
  "@nativescript/core": "~8.2.0",
  "@nativescript/theme": "~3.0.2",
  "rxjs": "~7.5.0",
  "zone.js": "~0.11.5"
},
"devDependencies": {
  "@angular-devkit/build-angular": "~13.2.0",
  "@angular/compiler-cli": "~13.2.0",
  "@nativescript/android": "8.2.2",
  "@nativescript/ios": "8.2.1",
  "@nativescript/types": "~8.2.0",
  "@nativescript/webpack": "~5.0.6",
  "@ngtools/webpack": "~13.2.0",
  "typescript": "~4.5.5"
}
ns doctor
✔ Getting environment information

No issues were detected.
✔ 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.
✔ Xcode version 13.3.0 satisfies minimum required version 10.
✔ Getting NativeScript components versions information...
✔ Component nativescript has 8.2.2 version and is up to date.
✔ Component @nativescript/core has 8.2.1 version and is up to date.
✔ Component @nativescript/ios has 8.2.1 version and is up to date.
✔ Component @nativescript/android has 8.2.2 version and is up to date.

@msl2000
Copy link

msl2000 commented Mar 21, 2022

Having the same gradle issue: Below is my package.json

{ "ioas": { "v8Flags": "--expose_gc", "markingMode": "none", "maxLogcatObjectSize": 100900 }, "name": "@nativescript/template-blank-vue", "main": "app/app.js", "displayName": "Blank", "version": "8.0.4", "description": "NativeScript Application", "author": "NativeScript Team <oss@nativescript.org>", "license": "SEE LICENSE IN <your-license-filename>", "repository": "<fill-your-repository-here>", "homepage": "https://github.com/NativeScript/nativescript-app-templates", "bugs": { "url": "https://github.com/NativeScript/NativeScript/issues" }, "nativescript": { "id": "com.dribl.app" }, "publishConfig": { "access": "public" }, "files": [ "app", "App_Resources", "hooks", "tools", "!tools/assets", ".editorconfig", "jsconfig.json" ], "keywords": [ "nstudio", "nativescript", "mobile", "{N}", "tns", "vue", "nativescript-vue", "template", "master-detail", "detail", "category-general" ], "dependencies": { "@fortawesome/fontawesome-pro": "^5.15.4", "@nativescript-community/ui-drawer": "^0.0.33", "@nativescript-community/ui-material-bottom-navigation": "^5.3.19", "@nativescript-community/ui-material-bottomsheet": "^6.2.5", "@nativescript-community/ui-material-tabs": "^5.3.19", "@nativescript-community/ui-pulltorefresh": "^2.5.0", "@nativescript-community/ui-svg": "0.0.8", "@nativescript/background-http": "^5.0.2", "@nativescript/camera": "^5.0.10", "@nativescript/core": "^8.0.11", "@nativescript/datetimepicker": "^2.1.9", "@nativescript/firebase": "^11.1.3", "@nativescript/imagepicker": "^1.0.6", "@nativescript/theme": "~3.0.1", "@nstudio/nativescript-pulltorefresh": "^3.0.2", "animate.css": "^4.1.1", "atob": "^2.1.2", "axios": "^0.24.0", "buffer": "^6.0.3", "file-system": "^2.2.2", "fs": "^0.0.1-security", "lodash": "^4.17.21", "moment": "^2.29.1", "nativescript-animate-sass": "^0.0.2", "nativescript-appversion": "^1.4.4", "nativescript-bottom-navigation": "^2.0.5", "nativescript-carousel": "^7.0.1", "nativescript-clipboard": "^2.1.1", "nativescript-google-maps-sdk": "file:nativescript-google-maps-sdk-4.0.0.tgz", "nativescript-vue": "~2.9.0", "nativescript-vue-navigator": "^1.2.0", "vue-moment": "^4.1.0", "vue-slide-up-down": "^2.0.1", "vuex": "^3.6.2" }, "devDependencies": { "@nativescript/android": "8.0.0", "@nativescript/ios": "8.0.0", "@nativescript/webpack": "beta", "nativescript-vue-template-compiler": "~2.9.0", "sass": "^1.42.1" }, "private": "true", "readme": "NativeScript Application" }

Using the following:
Nativescript cli 8.2.2
Java (OpenJDK) 1.8

Same gradle ENOENT error as above

@CTOaramos
Copy link
Author

Reset my mac the 3rd time; still no luck; this was working 2 months ago; the only things that i did that i think that could cause this are;

  • downgraded my node to node@14
  • downgraded my jdk from 17 - 1.8

i reset my mac and all use all the updated version; still cannot build any plugin (Hello World Template)

@NathanWalker
Copy link
Contributor

@CTOaramos we recommend node 16 or 17 with npm 7 or 8 at least.

@NathanWalker
Copy link
Contributor

NathanWalker commented Mar 21, 2022

@milosmatic only thing that jumps out is build-tools 31 which you have installed is corrupted (something on androids side which was discussed couple months back among the android community: https://stackoverflow.com/questions/68387270/android-studio-error-installed-build-tools-revision-31-0-0-is-corrupted) - I would recommend installing build-tools 32 and ensure those are set in your app.gradle for example:

compileSdkVersion 32
buildToolsVersion "32.0.0"
defaultConfig {
minSdkVersion 23
targetSdkVersion 32

@milosmatic
Copy link

I'm getting the same error.

// You can add your native dependencies here
dependencies {
//  implementation 'androidx.multidex:multidex:2.0.1'
}

compileSdkVersion 32
buildToolsVersion "32.0.0"

android {
  compileSdkVersion 32
  buildToolsVersion "32"

  defaultConfig {
    minSdkVersion 23
    targetSdkVersion 32

    // Version Information
    versionCode 1
    versionName "1.0.0"
    
    generatedDensities = []
  }

  aaptOptions {
    additionalParameters "--no-version-vectors"
  }
}
ns build android
Preparing project...
asset vendor.js 15.4 MiB [compared for emit] (name: vendor) (id hint: defaultVendor)
asset bundle.js 353 KiB [compared for emit] (name: bundle)
asset runtime.js 12.5 KiB [compared for emit] (name: runtime)
Entrypoint bundle 15.8 MiB = runtime.js 12.5 KiB vendor.js 15.4 MiB bundle.js 353 KiB
runtime modules 2.72 KiB 8 modules
orphan modules 576 bytes [orphan] 7 modules
modules by path ./node_modules/ 5.2 MiB
  javascript modules 4.94 MiB 560 modules
  json modules 273 KiB
    modules by path ./node_modules/mdn-data/css/*.json 242 KiB 3 modules
    modules by path ./node_modules/css-tree/ 30.7 KiB 2 modules
modules by path ./src/ 125 KiB
  modules by path ./src/app/ 6.62 KiB 6 modules
  modules by path ./src/*.ts 840 bytes
    ./src/polyfills.ts 545 bytes [built] [code generated]
    ./src/main.ts 295 bytes [built] [code generated]
  ./src/app.css 118 KiB [built] [code generated]
external "~/package.json" 42 bytes [optional] [built] [code generated]
webpack 5.67.0 compiled successfully in 5591 ms
Webpack compilation complete.
Failed to build plugin @nativescript/core :
Error: spawn ./gradlew ENOENT

@CTOaramos
Copy link
Author

CTOaramos commented Mar 22, 2022

Here's mine still getting the same error

app.gradle

// You can add your native dependencies here
dependencies {
// implementation 'androidx.multidex:multidex:2.0.1'
}

android {
compileSdkVersion 32
buildToolsVersion "32.0.0"
// ndkVersion ""

defaultConfig {
minSdkVersion 17
targetSdkVersion 32

// Version Information
versionCode 1
versionName "1.0.0"

generatedDensities = []

}

aaptOptions {
additionalParameters "--no-version-vectors"
}
}

================================================
Preparing project...
asset vendor.js 6.07 MiB [compared for emit] (name: vendor) (id hint: defaultVendor)
asset bundle.js 342 KiB [compared for emit] (name: bundle)
asset runtime.js 11.5 KiB [compared for emit] (name: runtime)
Entrypoint bundle 6.42 MiB = runtime.js 11.5 KiB vendor.js 6.07 MiB bundle.js 342 KiB
runtime modules 2.46 KiB 7 modules
orphan modules 356 bytes [orphan] 6 modules
modules by path ./node_modules/@nativescript/core/ 1.37 MiB 185 modules
modules by path ./node_modules/css-tree/ 317 KiB 113 modules
modules by path ./app/ 123 KiB 8 modules
modules by path ./node_modules/source-map/lib/.js 36.3 KiB 6 modules
modules by path ./node_modules/reduce-css-calc/dist/ 131 KiB 5 modules
modules by path ./node_modules/postcss-value-parser/lib/
.js 12.5 KiB
./node_modules/postcss-value-parser/lib/index.js 607 bytes [built] [code generated]

  • 4 modules
    modules by path ./node_modules/mdn-data/css/*.json 242 KiB
    ./node_modules/mdn-data/css/at-rules.json 11.6 KiB [built] [code generated]
  • 2 modules
  • 4 modules
    webpack 5.70.0 compiled successfully in 12722 ms
    Webpack compilation complete.
    (node:1935) [DEP0148] DeprecationWarning: Use of deprecated folder mapping "./" in the "exports" field module resolution of the package at /Users/aceramos/Desktop/ACE/DEV/MOBILE/Perennial/test-app/node_modules/tslib/package.json.
    Update this package.json to use a subpath pattern like "./*".
    (Use node --trace-deprecation ... to show where the warning was created)
    Failed to build plugin @nativescript/core :
    Error: spawn ./gradlew ENOENT

    ================================================

@msl2000
Copy link

msl2000 commented Mar 22, 2022

Having the same error as the first post of this thread, line by line. Is everyone in this thread having this issue using a Mac with an M1/M1 pro chip?

@rigor789
Copy link
Member

Good news, I am able to reproduce the issue with node installed via Homebrew. I'm looking into it, but in the meantime, you can try installing node with a version manager like nvm, n, volta etc. That seems to work all around...

rigor789 added a commit that referenced this issue Mar 22, 2022
Some node installations have trouble with relative paths passed to child_process.spawn() - so in those cases we resolve the full path instead.

ref #5649
@rigor789
Copy link
Member

I have pushed out a fix that should fix this - please try nativescript@next from npm:

npm i -g nativescript@next

And then build again, and let me know if still running into an issue.

@CTOaramos
Copy link
Author

Hi, @rigor789 MAN! YOU ARE A HERO!! Thank you; i was able to build now;

npm i -g nativescript@next does it!;

@matteonatale
Copy link

matteonatale commented Mar 23, 2022

Hi, @rigor789 I had the same issue since this morning (I'm from Italy), then after a npm i -g nativescript@next plugins are built correctly and everything works fine. I'm curious to know where the problem was and how should we handle next versions of nativescript and gradle.

Thanks! 😆

@milosmatic
Copy link

@rigor789 I can confirm that the issue is gone. Excellent work!

@rigor789
Copy link
Member

Thanks for confirming, will publish a patch release shortly...

As for why this was required, I frankly don't know - but node installed through Homebrew had trouble spawning a relative path command like ./gradlew - it did spawn it - because the process ran and had logs outputting, but node would also throw the ENOENT error. This is not the case with the same node version installed through nvm for example, so it's quite puzzling. The fix I did was to always resolve ./<path> spawns to a full path - which seems to work across all node installations.

@rigor789 rigor789 added bug and removed bug-pending-triage Reported bug, pending triage to confirm. labels Mar 23, 2022
@rigor789
Copy link
Member

@danielritter
Copy link

danielritter commented Jul 7, 2023

I have the same/similar issue with v8.5.0 on a Rocky 9 linux virtual machine (build with TeamCity):

12:59:05   webpack 5.86.0 compiled with 3 warnings in 97999 ms
12:59:05   Webpack compilation complete. Watching for file changes.
12:59:13      ~ applying user-defined configuration from /srv/teamcity/agents/agent-2/work/85ceec441cda0047/mobile/apps/mobile-nativescript/App_Resources/Android/before-plugins.gradle
12:59:13   
12:59:13   FAILURE: Build failed with an exception.
12:59:13   
12:59:13   * Where:
12:59:13   Build file '/srv/teamcity/agents/agent-2/work/85ceec441cda0047/mobile/apps/mobile-nativescript/platforms/tempPlugin/core/build.gradle' line: 167
12:59:13   
12:59:13   * What went wrong:
12:59:13   A problem occurred evaluating root project 'core'.
12:59:13   > Invalid revision: build-tools_r33.0.2-linux.zip
12:59:13   
12:59:13   * Try:
12:59:13   > Run with --stacktrace option to get the stack trace.
12:59:13   > Run with --info or --debug option to get more log output.
12:59:13   > Run with --scan to get full insights.
12:59:13   
12:59:13   * Get more help at https://help.gradle.org
12:59:13   
12:59:13   BUILD FAILED in 5s
12:59:13   Failed to build plugin @nativescript/core :
12:59:13   Error: Command ./gradlew failed with exit code 1
12:59:13   Done.
12:59:13   
12:59:13   
12:59:13   
12:59:13    >  NX   Running target android for project mobile-nativescript failed
12:59:13   
12:59:13      Failed tasks:
12:59:13   
12:59:13      - mobile-nativescript:android
12:59:13   
12:59:13      Hint: run the command with --verbose for more details.

And my app.gradle looks like

// You can add your native dependencies here
dependencies {
//  implementation 'androidx.multidex:multidex:2.0.1'
}

android {
  compileSdkVersion 33
  buildToolsVersion "33.0.2"
  // ndkVersion ""

  defaultConfig {
    minSdkVersion 21
    targetSdkVersion 33

    // Version Information
    versionCode 1
    versionName "1.0.0"
    
    generatedDensities = []
  }

  aaptOptions {
    additionalParameters "--no-version-vectors"
  }
}

On my local machine I can build successfully.

@rigor789
Copy link
Member

rigor789 commented Jul 7, 2023

@danielritter not sure where that revision string is coming from, but sound like that's the issue

Invalid revision: build-tools_r33.0.2-linux.zip

@danielritter
Copy link

@rigor789 Thanks, I had to delete the file build-tools_r33.0.2-linux.zip in the build-tools folder, I recently added it there before. Now it can build successfully. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants