Nativescript won't run on Android - nativescript

I've been using my application on the Nativescript Playground for android, it seems to be working fine, but when i try to run this on my android emulator it just doesn't bundle.
Execution failed for task ':app:processDebugManifest'.
null
Command gradlew.bat failed with exit code 1
TNS 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.
√ Local builds for iOS can be executed only on a macOS system. To build for iOS on a different operating system, you can use the NativeScript cloud infrastructure.
√ Getting NativeScript components versions information...
√ Component nativescript has 6.7.8 version and is up to date.
‼ Update available for component tns-core-modules. Your current version is 6.5.5 and the latest available version is 6.5.8.
‼ Update available for component tns-android. Your current version is 6.5.0 and the latest available version is 6.5.1.
‼ Update available for component tns-ios. Your current version is 6.5.0 and the latest available version is 6.5.1.
I've tried using different SDK versions, removing my Gradle folders and changing the properties in AndroidManifest.xml but it doesn't works at all.

Related

Can't deploy nativescript app to ios emulator or real device

I have successfully deployed my nativescript app to my ios and android devices and emulators many, many times. But now, when I try to deploy the app to ios, the builder stops at Project successfully prepared (ios) and won't load it to the emulator or device.
I deleted the hooks, node_modules, and platforms folders, then rebuilt with the same result. I can successfully run the app if I run it directly through XCode, just not from the nativescript cli.
Here's the output from tns 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 11.6.0 satisfies minimum required version 10.
✔ Getting NativeScript components versions information...
✔ Component nativescript has 6.7.8 version and is up to date.
✔ Component tns-core-modules has 6.5.12 version and is up to date.
✔ Component tns-android has 6.5.3 version and is up to date.
✔ Component tns-ios has 6.5.2 version and is up to date.
Any idea as to why I can deploy from XCode but not the command line?
I have had similar problems in the past, and it has always meant doing an update of Nativescript and then restarting my system. However, your tns doctor output looks basically the same as mine and I'm not having any issues with this. Not sure what to say -- maybe try a new npm install -g nativescript -- but it looks like you are already up to date. I've found in my experiences that this seems to happen if Xcode has updated and the version of Nativescript I have is one behind. Your situation may be for a different reason. Also, for whatever reason, I also found I need to completely reboot (paradoxical as that sounds) after doing an update to get things working again. That led me to speculate at one point that something in the connectivity layer might get jiggered up and causing things to wait for a ready state that never appears (?) but that doesn't really make much sense either on deeper thought. Wish I had a more definitive suggestion!
I finally found the problem. In my situation, the nativescript-videorecorder plugin has a hook that runs during the after-prepare phase of the build process. The after-prepare script creates a promise that only resolves if it finds the AndroidManifest.xml in the platforms folder. When I delete the platforms folder to do a clean rebuild of ios, the AndroidManifest.xml doesn't exist causing the promise to hang.
If I build for android first, the ios build runs fine and deploys to my simulator and real device.
I notified the owner of nativescript-videorecorder. Hopefully this helps someone else who may have a similar problem with this or another plugin.

Nativescript doctor throws warnings and errors

I want to connect my virtual android device to nativescript sidekick.
When I open NativeScript Sidekick and click on "Virtual Device Launcher" Button, I get the following error message.
[20-03-24 09:50:23.966] Unable to execute avdmanager, ensure JAVA_HOME is set and points to correct directory
So I ran tns doctor:
TIP: To avoid setting up the necessary environment variables, you can use the chocolatey package manager to install the Android SDK and its dependencies.
There seem to be issues with your configuration.
Component nativescript has 6.5.0 version and is up to date.
Your ANDROID_HOME environment variable is set and points to correct directory.
WARNING: 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: 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
WARNING: Cannot find a compatible Android SDK for compilation. To be able to build for Android, install Android SDK 28 or later.
Run `$ sdkmanager` to manage your Android SDK versions.
WARNING: You need to have the Android SDK Build-tools installed on your system. You can install any version in the following range: '>=23 <=29'.
Run `$ sdkmanager` from your command-line to install required `Android Build Tools`. In case you already have them installed, make sure `ANDROID_HOME` environment variable is set correctly.
WARNING: Error executing command 'javac'. Make sure you have installed The Java Development Kit (JDK) and set JAVA_HOME environment variable.
You will not be able to build your projects for Android.
To be able to build for Android, verify that you have installed The Java Development Kit (JDK) and configured it according to system requirements as
described in http://docs.nativescript.org/setup/ns-cli-setup/ns-setup-win.html#system-requirements
WARNING: WARNING: The Java Development Kit (JDK) is not installed or is not configured properly.
You will not be able to work with the Android SDK and you might not be able
to perform some Android-related operations. To ensure that you can develop and
test your apps for Android, verify that you have installed the JDK as
described in http://docs.oracle.com/javase/8/docs/technotes/guides/install/install_overview.html (for JDK 8).
Local builds for iOS can be executed only on a macOS system. To build for iOS on a different operating system, you can use the NativeScript cloud infrastructure.
Your environment is not configured properly and you will not be able to execute local builds. To continue, choose one of the following options:
Run $ tns preview command to enjoy NativeScript without any local setup.
Run $ tns setup command to run the setup script to try to automatically configure your environment for local builds.
In order to test your application use the $ tns login command to log in with your account and then $ tns cloud build command to build your app in the cloud.
Verify that your environment is configured according to the system requirements described at http://docs.nativescript.org/setup/ns-cli-setup/ns-setup-win.html#system-requirements.
Android Studio Says Android SDK-Tools are installed:
ANDROID_SDK_HOME is in my environment variables (user):
JAVA_HOME is in my environment variables (system):
When I open cmd and run javac -version I get javac 1.8.0_131
adb devices says List of devices attached (works fine)
First option I suggest to you is to run sdkmanager in the command line and try tns run again.
For setting the java_home path this is a link : Setting JAVA_HOME at Android SDK
Second option you may need to change the path of ANDROID_HOME: for example this is mine
C:\Users\USERNAME\AppData\Local\Android\Sdk note the sdk at the end of the path

NativeScript for Windows error: Android SDK Build-tools v29 You can install any version in the following range: '>=23 <=28'

When trying to follow the NativeScript for Vue Quick Start here: https://nativescript-vue.org/en/docs/getting-started/quick-start/
in June 2019, the Android SDK is version 29.
At the command $ tns run android --bundle or when running tns doctor I get the following error: You need to have the Android SDK Build-tools installed on your system. You can install any version in the following range: '>=23 <=28' and yes, I also get the message Your ANDROID_HOME environment variable is set and points to correct directory. BUT of course it is version 29, not '>=23 <=28'
Other SO responses do not seem to address this problem.
How to install an older version in this case?
In the Android SDK manager, go to the SDK Tools tab and then select the Show Package Details checkbox. Older versions will then be displayed.

Getting error `spawn ./gradlew ENOENT` when I run `tns build android`

I'm starting with nativescript. I'm trying to build a hello world application to test it. However, when I run it, I get an exit status 127 for command not found.
Here is how I try to build:
[ahmed#localhost hello]$ tns build android
Executing before-shouldPrepare hook from /home/ahmed/PycharmProjects/hello/hooks/before-shouldPrepare/nativescript-dev-webpack.js
Skipping prepare.
Building project...
Gradle build...
spawn ./gradlew ENOENT
[ahmed#localhost hello]$ echo $?
127
[ahmed#localhost hello]$
If I run tns doctor, everything seems to be ok
[ahmed#localhost hello]$ tns 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.
✔ Local builds for iOS can be executed only on a macOS system. To build for iOS on a different operating system, you can use the NativeScript cloud infrastructure.
✔ Getting NativeScript components versions information...
✔ Component nativescript has 5.1.0 version and is up to date.
✔ Component tns-core-modules has 5.1.1 version and is up to date.
✔ Component tns-android has 5.1.0 version and is up to date.
✔ Component tns-ios has 5.1.0 version and is up to date.
[ahmed#localhost hello]$
What did I miss?
I ran tns install to install dependencies. That solved my issue.
I was trying several things, the one that worked fort me, was:
ns clean
ns install

Nativescript. Execution failed for task ':mergeF0DebugResources'

I am getting the following exception Execution failed for task ':mergeF0DebugResources.
When running 'tns build android' or 'tns run android --emulator'
tns version: 2.0.1
java version "1.8.0_92"
This error typically means your platform folder has been messed up. Typically in v2.0x of NativeScript this is typically caused because you added or removed a plugin. In the next (hopefully) version this should be fixed.
However, in the meantime to "fix" this error all you typically need to do is:
tns platform remove android
then
tns platform add android
The other possibility is that you do not have the android sdk installed properly. If you type "android" at a command/terminal window, does it show that you have all the following installed:
Android SDK Tools
Android SDK Platform Tools
Android SDK Build Tools
At least one of the SDK's, 4.4.2 and higher
Android Support Repository
Android Support Library
All of them must be showing that they are installed.

Resources