Is it possible to use NativeScript?

Hello there!

I’d like to develop a mobile app using NativeScript. I installed the CLI through an npm command, set up a new project, but when I try to launch it in Android using ns run android, it fails because it needs an Android emulator.

Is it possible to make it work with IDX?

Thank you c:

The output :

blank-test-7031061:~/blank-test/example-app{master}$ ns run android
✔ 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.
✖ 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 

✖ Cannot find a compatible Android SDK for compilation.
To be able to build for Android with your current android runtime, install one of the following supported Android SDK targets:
  android-17
  android-18
  android-19
  android-20
  android-21
  android-22
  android-23
  android-24
  android-25
  android-26
  android-27
  android-28
  android-29
  android-30
  android-31
  android-32
  android-33
  android-34
Supported targets vary based on what android runtime you have installed. Currently your app uses @nativescript/android null 
 Run `$ sdkmanager` to manage your Android SDK versions. 

✖ No compatible version of the Android SDK Build-tools are installed on your system. You can install any version in the following range: '>=23 <=34'. 
 Install the required build-tools through Android Studio. In case you already have them installed, make sure the `ANDROID_HOME` environment variable is set correctly. 

✖ 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 https://docs.nativescript.org/setup 

✖ 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). 

Your environment is not configured properly and you will not be able to execute local builds.
Verify that your environment is configured according to the system requirements described at
https://docs.nativescript.org/setup/linux#setting-up-linux-for-android.v

Hi @zonetecde - that is interesting! With our Flutter project template, the workspace has all of the dependencies configured for building and previewing apps using the Android emulator.

I am thinking out loud here, but have you tried running this command inside a Flutter workspace? The Android emulator would be present there, so this error may not appear there.

Thanks,
Kirupa

Just tried it, but sadly, it does not work, and I got the exact same output. Good idea though :slight_smile: !

Flutter workspace required

You have to set ANDROID_HOME as stated in the documents
(Setting up Linux for NativeScript | NativeScript)

export ANDROID_HOME=/opt/android 

To make this permanent add the follow snippet to dev.nix

  env = {
    ANDROID_HOME=/opt/android;
  };

After rebuilding the environment, you can ensure that it works by running this command:

ns doctor android

WARNING: DO NOT SET PATH IN nix.dev, DUE TO A BUG, IT MAY LEAD YOUR WORKSPACE TO BE PERMENTANLY BROKEN

1 Like

It worked, thank you !!!

1 Like