Template build failed on windows for Android


#1

Hi,
I am starting learn nativescript.

Install NativeScript by command
@powershell -NoProfile -ExecutionPolicy Bypass -Command “iex ((new-object net.webclient).DownloadString(’…’))”
+I already have android sdk instaled
+in the console I saw that gradle version 4.1 is being installed

I am able to create project:

tns create HelloWorld --template nativescript-template-tutorial
or
tns create HelloWorld2 --template tns-template-blank

but when i try to build the project I face below error. [Gradle]

tns build android

Searching for devices…
Skipping prepare.
Building project…
Gradle build…

FAILURE: Build failed with an exception.

  • What went wrong:
    A problem occurred configuring root project ‘HelloWorld2’.

Could not resolve all files for configuration ‘:classpath’.
Could not resolve com.android.tools.lint:lint-checks:25.3.3.
Required by:
project : > com.android.tools.build:gradle:2.3.3 > com.android.tools.build:gradle-core:2.3.3 > com.android.tools.lint:lint:25.3.3
Could not resolve com.android.tools.lint:lint-checks:25.3.3.
Could not load module metadata from C:\Users\whysocurious.gradle\caches\modules-2\metadata-2.23\descriptors\com.android.tools.lint\lint-checks\25.3.3\22da77b0d76ea8df17298218f3ec1f87\descriptor.bin
Could not resolve com.android.databinding:baseLibrary:2.3.3.
Required by:
project : > com.android.tools.build:gradle:2.3.3 > com.android.tools.build:gradle-core:2.3.3 > com.android.databinding:compilerCommon:2.3.3
Could not resolve com.android.databinding:baseLibrary:2.3.3.
Could not load module metadata from C:\Users\whysocurious.gradle\caches\modules-2\metadata-2.23\descriptors\com.android.databinding\baseLibrary\2.3.3\22da77b0d76ea8df17298218f3ec1f87\descriptor.bin
Could not resolve com.android.tools:annotations:25.3.3.
Required by:
project : > com.android.tools.build:gradle:2.3.3 > com.android.tools.build:gradle-core:2.3.3 > com.android.databinding:compilerCommon:2.3.3
Could not resolve com.android.tools:annotations:25.3.3.
Could not load module metadata from C:\Users\whysocurious.gradle\caches\modules-2\metadata-2.23\descriptors\com.android.tools\annotations\25.3.3\22da77b0d76ea8df17298218f3ec1f87\descriptor.bin
Could not resolve com.android.tools:annotations:25.3.3.
Required by:
project : > com.android.tools.build:gradle:2.3.3 > com.android.tools.build:gradle-core:2.3.3 > com.android.tools.build:builder:2.3.3 > com.android.tools.build:builder-model:2.3.3
project : > com.android.tools.build:gradle:2.3.3 > com.android.tools.build:gradle-core:2.3.3 > com.android.tools.build:builder:2.3.3 > com.android.tools:common:25.3.3
project : > com.android.tools.build:gradle:2.3.3 > com.android.tools.build:gradle-core:2.3.3 > com.android.tools.build:builder:2.3.3 > com.android.tools.analytics-library:shared:25.3.3
project : > com.android.tools.build:gradle:2.3.3 > com.android.tools.build:gradle-core:2.3.3 > com.android.tools.build:builder:2.3.3 > com.android.tools.analytics-library:tracker:25.3.3
Could not resolve com.android.tools:annotations:25.3.3.
Could not load module metadata from C:\Users\whysocurious.gradle\caches\modules-2\metadata-2.23\descriptors\com.android.tools\annotations\25.3.3\22da77b0d76ea8df17298218f3ec1f87\descriptor.bin
Could not resolve com.android.tools.layoutlib:layoutlib-api:25.3.3.
Required by:
project : > com.android.tools.build:gradle:2.3.3 > com.android.tools.build:gradle-core:2.3.3 > com.android.tools.build:builder:2.3.3 > com.android.tools:sdklib:25.3.3
Could not resolve com.android.tools.layoutlib:layoutlib-api:25.3.3.
Could not load module metadata from C:\Users\whysocurious.gradle\caches\modules-2\metadata-2.23\descriptors\com.android.tools.layoutlib\layoutlib-api\25.3.3\22da77b0d76ea8df17298218f3ec1f87\descriptor.bin
Could not resolve com.android.tools:dvlib:25.3.3.
Required by:
project : > com.android.tools.build:gradle:2.3.3 > com.android.tools.build:gradle-core:2.3.3 > com.android.tools.build:builder:2.3.3 > com.android.tools:sdklib:25.3.3
Could not resolve com.android.tools:dvlib:25.3.3.
Could not load module metadata from C:\Users\whysocurious.gradle\caches\modules-2\metadata-2.23\descriptors\com.android.tools\dvlib\25.3.3\22da77b0d76ea8df17298218f3ec1f87\descriptor.bin
Could not resolve com.android.tools:repository:25.3.3.
Required by:
project : > com.android.tools.build:gradle:2.3.3 > com.android.tools.build:gradle-core:2.3.3 > com.android.tools.build:builder:2.3.3 > com.android.tools:sdklib:25.3.3
Could not resolve com.android.tools:repository:25.3.3.
Could not load module metadata from C:\Users\whysocurious.gradle\caches\modules-2\metadata-2.23\descriptors\com.android.tools\repository\25.3.3\22da77b0d76ea8df17298218f3ec1f87\descriptor.bin

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

  • Get more help at https://help.gradle.org

BUILD FAILED in 6s
Unable to apply changes on device: b09955cd. Error is: Command gradlew.bat failed with exit code 1.

VER
Microsoft Windows [Version 10.0.15063]

tns info
│ nativescript — 3.4.1
│ tns-core-modules — 3.4.0
│ tns-android — 3.4.1
%ANDROID_HOME%
D:\Android\android-sdk

%JAVA_HOME%
C:\Program Files\Java\jdk1.8.0_121

Also I trying change gradle plugin version here …\HelloWorld2\platforms\android\build.gradle
from
classpath 'com.android.tools.build:gradle:2.3.3’
to
classpath ‘com.android.tools.build:gradle:3.0.1’

then i have another error:

Searching for devices…
Skipping prepare.
Building project…
Gradle build…
+ applying user-defined configuration from C:\Users\whysocurious\HelloWorld2\app\App_Resources\Android\app.gradle
Configuration ‘compile’ in project ‘:app’ is deprecated. Use ‘implementation’ instead.
Configuration ‘debugCompile’ in project ‘:app’ is deprecated. Use ‘debugImplementation’ instead.
+ adding nativescript runtime package dependency: nativescript-optimized
+ adding aar plugin dependency: C:\Users\whysocurious\HelloWorld2\node_modules\tns-core-modules-widgets\platforms\android\widgets-release.aar

FAILURE: Build failed with an exception.

  • Where:
    Build file ‘C:\Users\whysocurious\HelloWorld2\platforms\android\app\build.gradle’ line: 64

  • What went wrong:
    A problem occurred configuring project ‘:app’.

Could not get unknown property ‘outputFile’ for task ‘:app:packageDebug’ of type com.android.build.gradle.tasks.PackageApplication.

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

  • Get more help at https://help.gradle.org

BUILD FAILED in 9s
Unable to apply changes on device: b09955cd. Error is: Command gradlew.bat failed with exit code 1.


#2

Did you try running tns doctor? That notify you of any issues you may have with the Android SDK


#3

Yes, of course.
tns doctor
NOTE: You can develop for iOS only on Mac OS X systems.
To be able to work with iOS devices and projects, you need Mac OS X Mavericks or later.

Your components are up-to-date:
nativescript,tns-core-modules,tns-android,tns-ios

No issues were detected.


#4

A few ideas:

  1. Are you behind a corporate firewall? It could be that some dependencies weren’t downloaded properly.
  2. Do you have Android Studio installed? If so, I would run that and get any updates for the Android SDKs that it offers.
  3. Try NativeScript Sidekick and don’t worry about your local setup :slight_smile: