I created a demo project and tried to run it against a genymotion android emulator in my company network.
When i run "tns run android" i get this error as below:
tns run android
Searching for devices...
Executing before-liveSync hook from C:\projects\apps\tnsDemo\hooks\before-liveSync\nativescript-angular-sync.js
Skipping prepare.
Building project...
Gradle build...
:config phase: createDefaultIncludeFiles
+found plugins: tns-core-modules-widgets
:config phase: createPluginsConfigFile
Creating product flavors include.gradle file in C:\projects\apps\tnsDemo\platforms\android/configurations folder...
:config phase: pluginExtend
+applying configuration from: C:\projects\apps\tnsDemo\platforms\android\configurations\include.gradle
+applying configuration from: C:\projects\apps\tnsDemo\platforms\android\configurations\tns-core-modules-widgets\include.gradle
:config phase: addAarDependencies
+adding dependency: C:\projects\apps\tnsDemo\platforms\android\libs\aar\widgets-release.aar
Exception in thread "main" java.lang.IllegalArgumentException: There are no parameters passed!
at com.ig.GetInterfaceNames.main(GetInterfaceNames.java:27)
FAILURE: Build failed with an exception.
Where:
Build file 'C:\projects\apps\tnsDemo\platforms\android\build-tools\android-static-binding-generator\build.gradle' line: 69
What went wrong:
Execution failed for task ':asbg:generateInterfaceNamesList'.
Process 'command 'C:\Program Files\Java\jdk1.8.0_144\bin\java.exe'' 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.
Unable to apply changes on device: 192.168.92.101:5555. Error is: Command gradlew.bat failed with exit code 1.
Executing after-watch hook from C:\projects\apps\tnsDemo\hooks\after-watch\nativescript-dev-typescript.js
Platform: Android
Java version: 1.8.0_144"
tns version: 3.2.1
tns-core-modules.d.ts: version: 3.1.1
tns-android: version: 3.2.0
Seems like something blocks the connection to the emulator but I don't know how to workaround it.
Seems like i found the origin of the problem.
The exception is thrown when the "org.gradle.parallel" property in the gradle.properties file is set to true.
When I set it to false everything works fine.
Related
I am trying to build my android app and am getting an error about the version of Gradle that is being used. When I make the change that is suggested and run the command again the change gets changed back causing it to fail again.
I have tried replacing all references to gradle-4.1-all.zip with gradle-4.10.1-all.zip and for some reason it keeps getting changed back at this location /gradle/wrapper/gradle-wrapper.properties to gradle-4.10.1-all.zip
Android Studio project detected
ANDROID_HOME=/Users/user.account/Library/Android/sdk
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_201.jdk/Contents/Home
studio
Subproject Path: CordovaLib
Subproject Path: app
FAILURE: Build failed with an exception.
Where:
Build file '/Users/user.account/cordovaProjects/hybrid-base/platforms/android/CordovaLib/build.gradle' line: 41
What went wrong:
A problem occurred evaluating project ':CordovaLib'.
Failed to apply plugin [id 'com.android.library']
Minimum supported Gradle version is 4.10.1. Current version is 4.1. If using the gradle wrapper, try editing the distributionUrl in /Users/user.account/cordovaProjects/hybrid-base/gradle/wrapper/gradle-wrapper.properties to gradle-4.10.1-all.zip
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 0s
/Users/user.account/cordovaProjects/hybrid-base/platforms/android/gradlew: Command failed with exit code 1 Error output:
FAILURE: Build failed with an exception.
Where:
Build file '/Users/user.account/cordovaProjects/hybrid-base/platforms/android/CordovaLib/build.gradle' line: 41
What went wrong:
A problem occurred evaluating project ':CordovaLib'.
Failed to apply plugin [id 'com.android.library']
Minimum supported Gradle version is 4.10.1. Current version is 4.1. If using the gradle wrapper, try editing the distributionUrl in /Users/user.account/cordovaProjects/hybrid-base/gradle/wrapper/gradle-wrapper.properties to gradle-4.10.1-all.zip
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 0s
I am able to get a build to work if I do a cordova platform remove android and then immediately cordova platform add android but as soon as I try to build a second time it fails
If for any reason you need a different version of gradle there is no need to edit any file, just set the CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL env var with value the url where to fin the gradle zip, for example
http://services.gradle.org/distributions/gradle-4.1-all.zip
I do not have any problem with version 4.1 ( win10, android platform 7.1.4 ).
After you set your desired gradle version, reset your project ( remove all plugin and all platforms and manual edits then reinstall ) and then try to build.
If the problem persist, to help you better, post the error and please specify which OS, cordova version and android platform version you are using.
As a rule of thumb, from my experience with cordova, when you think that the only way to set a certain configuration is to edit platform files, there is probably a proper way to do so ( for example to automatically sign the apk when build )
C:\Users\Tuladhar\WebstormProjects\myproject>ionic cordova build android
[WARN] Not performing Ionic build for project type: ionic1.
cordova build android
Running command: "C:\Program Files\nodejs\node.exe" C:\Users\Tuladhar\WebstormProjects\myproject\hooks\after_prepare\010_add_platform_class.js C:\Users\Tuladhar\WebstormProjects\myproject
add to body class: platform-android
ANDROID_HOME=C:\Users\Tuladhar\AppData\Local\Android\android-sdk
JAVA_HOME=C:\Program Files\Java\jdk1.8.0_121
Subproject Path: CordovaLib
The Task.leftShift(Closure) method has been deprecated and is scheduled to be removed in Gradle 5.0. Please use Task.doLast(Action) instead.
at build_859uxik73yildsrgrru9xamjo.run(C:\Users\Tuladhar\WebstormProjects\myproject\platforms\android\build.gradle:141)
BUILD FAILED
Total time: 22.164 secs
FAILURE: Build failed with an exception.
What went wrong:
A problem occurred configuring root project 'android'.
Could not resolve all dependencies for configuration ':_debugApk'.
A problem occurred configuring project ':CordovaLib'.
Could not open cp_proj remapped class cache for cxcpcn2de84br0eekalu3p9nv (C:\Users\Tuladhar.gradle\caches\3.3\scripts-remapped\build_c7ur6ql0tv1x27ryhuthd38ad\cxcpcn2de84br0eekalu3p9nv\cp_proj1efd45104ffa2d33563b85b9edda76e3).
Unexpected lock protocol found in lock file. Expected 3, found 0.
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
Error: cmd: Command failed with exit code 1 Error output:
FAILURE: Build failed with an exception.
What went wrong:
A problem occurred configuring root project 'android'.
Could not resolve all dependencies for configuration ':_debugApk'.
A problem occurred configuring project ':CordovaLib'.
Could not open cp_proj remapped class cache for cxcpcn2de84br0eekalu3p9nv (C:\Users\Tuladhar.gradle\caches\3.3\scripts-remapped\build_c7ur6ql0tv1x27ryhuthd38ad\cxcpcn2de84br0eekalu3p9nv\cp_proj1efd45104ffa2d33563b85b9edda76e3).
Unexpected lock protocol found in lock file. Expected 3, found 0.
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
[ERROR] An error occurred while running cordova build android (exit code 1).
1.Remove platforms (you can delete it from folder)
2.Remove node_modules (you can delete it from folder)
3.Upgrade your ionic-cli version to the latest (npm update -g ionic )
4.run npm install
5.run ionic cordova platform add android
6.run ionic cordova run android
Try these steps accordingly and it will work. If not try updating android api and sdk tools and re-do the steps.
I am facing the below error from Android studio project.
Error:Process 'command 'git'' finished with non-zero exit value 128
I was downloading source from VCS->Git, and cancelled it in the middle. Then I downloaded the same source locally and 'open existing android studio project' option. Once this project is opened in studio, I couldn't run it at all. It is still throwing error as below.
Error:fatal: Not a git repository (or any of the parent directories):
.git
FAILURE: Build failed with an exception.
Where: Script '/Users/.../functions.gradle' line: 19
What went wrong: A problem occurred evaluating project '..'.
Process 'command 'git'' finished with non-zero exit value 128
Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
I tried cleaning the project and run, observed the same error.
I again downloaded the same project from VCS->Git completely, still observing the same error either cases.
Could someone guide me how to solve this?
You can from the terminal, access the root of your projet then do:
git init
It will initialise your project as a git project, then try again and tell us what you have
I created an Android platform with success, but when I run
ionic build android
I get the following error:
FAILURE: Build failed with an exception.
* What went wrong:
Could not create an instance of type org.gradle.invocation.DefaultGradle_Decorated.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
ERROR building one of the platforms: Error code 1 for command: /home/skylek/Ionic/conFusion/platforms/android/gradlew with args: cdvBuildDebug,-b,/home/skylek/Ionic/conFusion/platforms/android/build.gradle,-Dorg.gradle.daemon=true,-Pandroid.useDeprecatedNdk=true
You may not have the required environment or OS to build this project
Error: Error code 1 for command: /home/skylek/Ionic/conFusion/platforms/android/gradlew with args: cdvBuildDebug,-b,/home/skylek/Ionic/conFusion/platforms/android/build.gradle,-Dorg.gradle.daemon=true,-Pandroid.useDeprecatedNdk=true
Can anyone help me out.
I had exactly the same problem with an ionic project build with the m-ionic yeoman generator, that was uploaded to the ionic cloud.
It started after my computer crashed with a 'blue screen of death', in the middle of a compilation task
What We did to fix the project was to copy and replacing the gradle and corodova files :
.gradle
cordova
CordovaLib
gradle
gradlew.bat
from other ionic>platform>android project that I knew was working fine, beacuse we thought the Cordova files might be corrupted, and early in the project we fixed a similar compilation problem that way. It did not fixed the problem. But then removed the ionic cloud configuration files: ionic.project .
And it worked!!
I hope it could help you!
I am trying to get the basic Cordova v5.0 Android v4.0 project to build on Mac OS X Yosemite, but keep getting this error. Note: The same process builds fine on Cordova v4. I have uninstalled and reinstalled the Android SDK, Cordova, and even Gradle (but I don't think I need it). I've checked that my Path variable contains the correct paths to /tools and /platform_tools. But when I do the 'cordova build' or 'cordova build android' I always get the same error:
Could not create an instance of type
org.gradle.invocation.DefaultGradle_Decorated.
Further down it says:
You may not have the required environment or OS to build this project
What am I missing?
Here's the full text of what I'm doing:
my_acct$cordova create build_test com.example.build_test "BuildTest"
Creating a new cordova project.
my_acct$cd build_test
my_acct$cordova platform add android
Adding android project...
Creating Cordova project for the Android platform:
Path: platforms/android
Package: com.example.build_test
Name: BuildTest
Activity: MainActivity
Android target: android-22
Copying template files...
Android project created with cordova-android#4.0.0
Discovered plugin "cordova-plugin-whitelist" in config.xml. Installing to the project
Fetching plugin "cordova-plugin-whitelist#1" via npm
npm http GET https://registry.npmjs.org/cordova-plugin-whitelist
npm http GET https://registry.npmjs.org/cordova-plugin-whitelist
npm http 304 https://registry.npmjs.org/cordova-plugin-whitelist
Installing "cordova-plugin-whitelist" for android
my_acct$cordova build
Running command: /Users/my_acct/Documents/Development/work/build_test/platforms/android/cordova/build
ANDROID_HOME=/Users/my_acct/Documents/Development/android-sdk-macosx/sdk
JAVA_HOME=/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
Running: /Users/my_acct/Documents/Development/work/build_test/platforms/android/gradlew cdvBuildDebug -b /Users/my_acct/Documents/Development/work/build_test/platforms/android/build.gradle -Dorg.gradle.daemon=true
FAILURE: Build failed with an exception.
* What went wrong:
Could not create an instance of type org.gradle.invocation.DefaultGradle_Decorated.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
/Users/my_acct/Documents/Development/work/build_test/platforms/android/cordova/node_modules/q/q.js:126
throw e;
^
Error code 1 for command: /Users/my_acct/Documents/Development/work/build_test/platforms/android/gradlew with args: cdvBuildDebug,-b,/Users/my_acct/Documents/Development/work/build_test/platforms/android/build.gradle,-Dorg.gradle.daemon=true
ERROR building one of the platforms: Error: /Users/my_acct/Documents/Development/work/build_test/platforms/android/cordova/build: Command failed with exit code 8
You may not have the required environment or OS to build this project
Error: /Users/my_acct/Documents/Development/work/build_test/platforms/android/cordova/build: Command failed with exit code 8
at ChildProcess.whenDone (/Users/my_acct/.node/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:131:23)
at ChildProcess.emit (events.js:98:17)
at maybeClose (child_process.js:766:16)
at Process.ChildProcess._handle.onexit (child_process.js:833:5)
If I change to use java 1.7 or 1.8, the error changes to:
A problem occurred configuring root project 'android'.
Could not resolve all dependencies for configuration ':classpath'.
Could not resolve com.android.tools.build:gradle:1.0.0+.
Required by:
:android:unspecified
org.slf4j.spi.LocationAwareLogger.log(Lorg/slf4j/Marker;Ljava/lang/String;ILjava/lang/String;[Ljava/lang/Object;Ljava/lang/Throwable;)V
Here's the full results for using java 1.7 or 1.8:
my_acct$cordova build
Running command: /Users/my_acct/Documents/Development/work/build_test/platforms/android/cordova/build
ANDROID_HOME=/Users/my_acct/Documents/Development/android-sdk-macosx/sdk
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home
Running: /Users/my_acct/Documents/Development/work/build_test/platforms/android/gradlew cdvBuildDebug -b /Users/my_acct/Documents/Development/work/build_test/platforms/android/build.gradle -Dorg.gradle.daemon=true
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'android'.
> Could not resolve all dependencies for configuration ':classpath'.
> Could not resolve com.android.tools.build:gradle:1.0.0+.
Required by:
:android:unspecified
> org.slf4j.spi.LocationAwareLogger.log(Lorg/slf4j/Marker;Ljava/lang/String;ILjava/lang/String;[Ljava/lang/Object;Ljava/lang/Throwable;)V
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 4.859 secs
/Users/my_acct/Documents/Development/work/build_test/platforms/android/cordova/node_modules/q/q.js:126
throw e;
^
Error code 1 for command: /Users/my_acct/Documents/Development/work/build_test/platforms/android/gradlew with args: cdvBuildDebug,-b,/Users/my_acct/Documents/Development/work/build_test/platforms/android/build.gradle,-Dorg.gradle.daemon=true
ERROR building one of the platforms: Error: /Users/my_acct/Documents/Development/work/build_test/platforms/android/cordova/build: Command failed with exit code 8
You may not have the required environment or OS to build this project
Error: /Users/my_acct/Documents/Development/work/build_test/platforms/android/cordova/build: Command failed with exit code 8
at ChildProcess.whenDone (/Users/my_acct/.node/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:131:23)
at ChildProcess.emit (events.js:98:17)
at maybeClose (child_process.js:766:16)
at Process.ChildProcess._handle.onexit (child_process.js:833:5)
I figured it out. I found old, conflicting .jar files in ~/Library/Java/Extensions. Blew away the entire ~/Library/Java directory. Cordova (and Android Studio) runs great now.
The other way how this problem can be resolved is by changing the repository from
mavenCentral()
to
maven{
url 'https://repo1.maven.org/maven2'
}
in both platforms/android/build.gradle and platforms/android/CordovaLib/build.gradle