Nativescript with vue and ts fail to build - nativescript

I created a nativescript vue template:
sudo vue init nativescript-vue/vue-cli-template project
When I try to run it with the command: tns run, I get the following errors:
Gradle build...
FAILURE: Build completed with 2 failures.
1: Task failed with an exception.
-----------
* Where:
Build file '/home/petar/Documents/Workspace/js/project/platforms/android/app/build.gradle' line: 221
* What went wrong:
A problem occurred evaluating project ':app'.
> Invalid revision: undefined
* 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.
==============================================================================
2: Task failed with an exception.
-----------
* What went wrong:
A problem occurred configuring project ':app'.
> SDK location not found. Define location with an ANDROID_SDK_ROOT environment variable or by setting the sdk.dir path in your project's local properties file at '/home/petar/Documents/Workspace/js/roomy/roomy/platforms/android/local.properties'.
* 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 6s
Unable to apply changes on device: 2383f95c9f0d7ece. Error is: Command ./gradlew failed with exit code 1.
Also, I get a couple of warnings just after I run the command. I installed Android studio, tried to set the JAVA_HOME variable correctly, and a couple of other things, but nothing worked.
✖ The ANDROID_HOME environment variable is not set or it points to a non-existent directory. You will not be able to perform any build-related operations for Android.
To be able to perform Android build-related operations, set the `ANDROID_HOME` variable to point to the root of your Android SDK installation directory.
✖ WARNING: adb from the Android SDK is not installed or is not configured properly.
For Android-related operations, the NativeScript CLI will use a built-in version of adb.
To avoid possible issues with the native Android emulator, Genymotion or connected
Android devices, verify that you have installed the latest Android SDK and
its dependencies as described in http://developer.android.com/sdk/index.html#Requirements
✖ WARNING: The Android SDK is not installed or is not configured properly.
You will not be able to run your apps in the native emulator. To be able to run apps
in the native Android emulator, verify that you have installed the latest Android SDK
and its dependencies as described in http://developer.android.com/sdk/index.html#Requirements

You have installed Android Studio but possibly haven't, as error 2 and tns points to, set ANDROID_SDK_ROOT environment variable.
What OS are you using?

Related

Where are Gradle detailed logs when building Flutter application in debug mode?

I am debugging my Flutter application and sometimes I get Gradle build errors. That's fine, some configuration is incorrect.
However it is difficult to find the actual problem as the debug console is not displaying any details, such as which row is breaking the build.
There's no error trace.
Launching lib\main.dart on Android SDK built for x86 in debug mode...
* Error running Gradle:
ProcessException: Process "C:\Users\<USER>\Projects\<app>\android\gradlew.bat" exited abnormally:
Command: C:\Users\<USER>\Projects\<APP>\android\gradlew.bat app:properties
Please review your Gradle project setup in the android/ folder.
Exited (sigterm)
Where, or how, can I see the Gradle logs when building a Flutter application in debug mode?
Here is a print too.
You should edit your $HOME/.gradle/gradle.properties file by adding:
org.gradle.console=verbose
and run
flutter run -v
Here a piece of output in VSCode
You can open the Android part of your project with AndroidStudio to help you understand the gradle errors.
With IntelliJ or VSCode, you just have to right click on android folder and click "Open in Android Studio"

Nativescript building android errors

I have a nativescript (3.0) application which I am developing on mac (ElCapitan). I am able to run the iOS emulator without a problem, but I cannot find a way to build the app for Android. I am getting the following error:
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'MyApp'.
> Flavor 'nativescript-telerik-ui' has unknown dimension 'nativescript-telerik-ui'.
* 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: 2.004 secs
Command ./gradlew failed with exit code 1
I followed the nativescript documentation strictly, removed the android platform and added it again, reinstalled the Android SDK and tools, but without any success.
At this point I am out of ideas. Any help would be greatly appreciated.
Thank you.
did you try nuke it?
tns plugin remove nativescript-telerik-ui
tns plugin add nativescript-telerik-ui
my be you have an older version
It seems you have changed something on the "AndroidManifest.xml" file and which is not correct. Please fix the "AndroidManifest.xml" file.
If not, you can try this
tns platform remove android
tns platform add android
if only these two lines are not enough for the solution, you may run the android platform on Android Studio.
app/platforms/android
This is the directory, you have to open on Android Studio. After opening this, Android Studio will suggest to you what you have to do.

gradlew.bat failed with exit code 1

i am very new to nativescript, i try to build my first app in nativescript, but it shows
=============================================================================
C:\Nativescript\Grab1>
C:\Nativescript\Grab1>tns prepare android
Executing before-prepare hook from C:\Nativescript\Grab1\hooks\before-prepare\na
tivescript-dev-android-snapshot.js
Preparing project...
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further detail
s.
FAILURE: Build failed with an exception.
What went wrong:
org/slf4j/impl/StaticLoggerBinder
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug
option to get more log output.
Processing node_modules failed. Error: Command C:\Nativescript\Grab1\platforms\a
ndroid\gradlew.bat failed with exit code 1
C:\Nativescript\Grab1>
================================================================================
here i attached my command prompt screen shot also, please help me to solve this problem friends
It seems some files missing in platform -> android folder. I fixed this issue by removing the android platform and adding it again by using the below command:
Make sure you are in project directory.Then try this below two commands:
tns platform remove android
tns platform add android
Same way for IOS:
tns platform remove ios
tns platform add ios
Just in case if someone out there is having the same problem on MacOS systems
tns platform remove iOS
tns platform add iOS
Just delete the platform folder from the root directory of the project and run
tns run android
I guess Gradle keeps the history logs which is creating the error. So we need to delete that and rebuild the project.

Appcelerator liveview build fails for "development" deployment with appc CLI

I'm using the latest tooling (as below) to build my project with the command
appc ti build -p ios -T device -D development --liveview
All generally works as expected until I quit the liveview session and attempt to build with the same command again.
Failed Output:
[INFO] App thinning disabled, skipping asset image sets
[INFO] Processing JavaScript files
An uncaught exception was thrown!
ENOTDIR: not a directory, open '/Users/gb/Documents/Work/Project/workspaces/appcelerator/Project/build/iphone/build/Products/Debug-iphoneos/Project.app/project/controller.js'
ENOTDIR: not a directory, open '/Users/gb/Documents/Work/Project/workspaces/appcelerator/Project/build/iphone/build/Products/Debug-iphoneos/Project.app/project/controller.js'
If I then attempt to build again I get this output...
[INFO] Processing JavaScript files
[INFO] Writing app properties
[INFO] Writing i18n files
[INFO] Processing Titanium symbols
[INFO] Removing files
[INFO] Optimizing .plist and .png files
[INFO] Invoking xcodebuild
[ERROR] ** BUILD FAILED **
[ERROR] The following build commands failed:
[ERROR] GenerateDSYMFile build/Products/Debug-iphoneos/Project.app.dSYM build/Products/Debug-iphoneos/Project.app/Project
[ERROR] (1 failure)
This output will be the same on each subsequent attempt to build
By chance, I found that if I reboot my machine I can build again, so I attempted all sorts of workarounds (cleaning build folders, derived data in xcode, restarting appc studio, building in studio....) to no avail, but eventually found a best case undesirable workaround to this issue in the form of:
appc logout
appc login
If I then attempt to build again it will succeed!
I can only assume therefore that the build issue has something to do with perhaps cached files associated with my dev cert as I understand this is regenerated on each login logout... Appc folks - any ideas?
The tooling seems to have become terribly unreliable over the last number of releases and needs some attention from the folks at Appcelerator IMO. Liveview is meant to speedup development time and it's great when it works (still probably lagging behind the awesome TiShadow of old), however in this instance it is breaking the build process and sucking up endless hours with indeterminate build behaviour. Am I doing something wrong???
Has anyone else discovered a better workaround or is this a known issue?
For reference, if I've built as above for development and then try to build for a "test" deployment with the command
appc ti build -p ios -T device -D test --liveview
I get the error (even after logging in and out and cleaning the project with appc ti clean)
[INFO] : Invoking xcodebuild
[ERROR] : ** BUILD FAILED **
[ERROR] : The following build commands failed:
[ERROR] : CompileC build/Intermediates/Project.build/Debug-iphoneos/Project.build/Objects-normal/armv7/TiUIiOSProxy.o Classes/TiUIiOSProxy.m normal armv7 objective-c com.apple.compilers.llvm.clang.1_0.compiler
[ERROR] : (1 failure)
This cannot be fixed until I do a reboot AFAICT!!!
Then, finally, the test deployment builds as expected and can usually be repeated (unlike development deployments).
All help greatly appreciated :)
Environment:
Operating System
Name = Mac OS X
Version = 10.11.6
Architecture = 64bit
# CPUs = 8
Memory = 8.0GB
Node.js
Node.js Version = 4.2.6
npm Version = 2.14.12
Appcelerator CLI
Installer = 4.2.7
Core Package = 5.4.0
Titanium CLI
CLI Version = 5.0.9
node-appc Version = 0.2.31
Titanium SDKs
5.4.0.GA
Version = 5.4.0
Install Location = /Users/gb/Library/Application Support/Titanium/mobilesdk/osx/5.4.0.GA
Platforms = android, mobileweb, iphone
git Hash = 4ba4c0a
git Timestamp = 08/10/16 05:43
node-appc Version = 0.2.35
...
Xcode
7.3.1 (build 7D1014) - Xcode default
Install Location = /Applications/Xcode.app/Contents/Developer/
iOS SDKs = 9.3
iOS Simulators = 9.3
Watch SDKs = 2.2
Watch Simulators = 2.2
Supported by TiSDK 5.4.0.GA = yes
EULA Accepted = yes
Teams = ********* (active)
Try this process:
Copy your entire project at some different location other than the current Studio workspace.
Now, after copying your project to some other folder, delete the project folder from workspace.
Create a new project with same name and same app id.
Note down the guid tag value from new tiapp.xml file.
Replace the content of new project with the original copied project.
Now finally replace the new guid with the original guid which you noted down in Step 4.
Run your project without LiveView mode.

Android Studio build fails with "java not found"

I am trying to build a project with Gradle, but the build is failing with the error "java not found". Whilst this works absolutely fine on the command line, it fails in Android Studio. The exact error is:
Error:Execution failed for task ':app:preDexRealDebug'.
com.android.ide.common.internal.LoggedErrorException: Failed to run command:
/Applications/Android Studio.app/sdk/build-tools/19.1.0/dx --dex --output /Users/amlcurran/Projects/Messages/app/build/intermediates/pre-dexed/real/debug/libGoogleAnalyticsServices-9d8e3e3fe0cc3007420cb25dbd38e357c5461aad.jar /Users/amlcurran/Projects/Messages/app/libs/libGoogleAnalyticsServices.jar
Error Code:
127
Output:
/Applications/Android Studio.app/sdk/build-tools/19.1.0/dx: line 89: exec: java: not found
My JDK Location (in Project Settings>SDK Locations) is set to "/Library/Java/JavaVirtualMachines/jdk1.7.0_45.jdk/Contents/Home", although every time I change this it seems to revert itself.
UPDATE: A non-Gradle project builds fine.
It turns out to be an issue I introduced yesterday trying to get the non-Gradle project working.
I had set my JDK to the one specified above but had issues with compiling, so moved my java executable in usr/bin/java. This clearly messed up Gradle - moving it back made Gradle work again (although I assume it has now broken the non-Gradle project).

Resources