CLI doesn't see android-sdk but Sidekick does


#1

I installed Sidekick, and am able to create a project and run it on my android phone (which I presume means it builds too?)

But sidekick doesn’t have a vue project template available when creating new projects, so it seems I have to use the CLI route.

So I did vue init nativescript-vue/vue-cli-template <project-name> then npm run watch:android but that complains about android sdk not being installed properly:

Your adb from the Android SDK is correctly installed.
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 22 or later. 
 Run `$ sdkmanager` to manage your Android SDK versions. 

WARNING: You need to have Android SDK 22 or later and the latest Android Support Repository installed on your system. 
 Run `$ sdkmanager` to manage the Android Support Repository. In case you already have it 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-linux.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). 

And Sidekick doesn’t seem to let me open the project I created with the CLI, so I’m a bit stuck!


#2

OK so:

  1. It seems I was using cloud build from Sidekick, which means it never built locally in the first place.
  2. Sidekick can’t open the procjet created by vue init because it has a different directory structure (you need to open the /dist directory, and can the build from cloud)

#3

Hi, what is your OS ?
if it’s Ubuntu 18.04, you may follow this guide,

# first install 
sudo apt-get install lib32z1 lib32ncurses5 libbz2-1.0:i386 libstdc++6:i386

# install java8
sudo add-apt-repository ppa:webupd8team/java

sudo apt-get update

sudo apt-get install oracle-java8-installer

# export environment
sudo nano .bashrc

# then paste at last
export JAVA_HOME=$(update-alternatives --query javac | sed -n -e 's/Best: *\(.*\)\/bin\/javac/\1/p')

# make dir 
mkdir android/sdk

# then download android sdk command line tools only
# extract and copy tools in android/sdk folder

# export environment
sudo nano .bashrc

# then paste at last
export ANDROID_HOME=$HOME/android/sdk

# then reload .bashrc
source ~/.bashrc

# then create file
mkdir .android
touch ~/.android/repositories.cfg

# then hit this command and keep typing y and press ENTER
$ANDROID_HOME/tools/bin/sdkmanager --licenses

# then install android sdk
$ANDROID_HOME/tools/bin/sdkmanager "tools" "platform-tools" "platforms;android-25" "build-tools;27.0.3" "extras;android;m2repository" "extras;google;m2repository"

Now time for emulator, if you want to use android emulator then follow this

# then install emulator
$ANDROID_HOME/tools/bin/sdkmanager "system-images;android-25;google_apis;x86"

# then create emulator
$ANDROID_HOME/tools/bin/avdmanager create avd -n android-25 -k "system-images;android-25;google_apis;x86"

# open emulator
sudo $ANDROID_HOME/tools/emulator @android-25

if you want to use Genymotion , you can use it for personal use free.
after login to genymotion website, go genymotion download link
before that, download virtualbox

# then
chmod +x <Genymotion installer path>/genymotion-<version>_<arch>.bin
# guess it's on home folder
(chmod +x $HOME/genymotion-2.12.1-linux_x64.bin)

# then
cd <Genymotion installer path>
./genymotion-<version>_<arch>.bin -d <Genymotion installer path>
(cd $HOME/genymotion-2.12.1-linux_x64.bin -d genymotion)

# Run Genymotion using the following command
cd <Genymotion installer path>
./genymotion
($HOME/genymotion/genymotion)

# then download any custom phone, maybe API 25 and in setting point to android/sdk


# if you want to run by desktop entity, can do it like 
sudo ln -s $HOME/genymotion/genymotion /usr/local/bin

# then type and hit in terminal
cat > ~/.local/share/applications/genymotion.desktop <<EOL
[Desktop Entry]
Encoding=UTF-8
Name=Genymotion
Exec=genymotion
Icon=/$HOME/genymotion/icons/icon.png
Terminal=false
Type=Application
Categories=Development;
EOL

Happy coding :slight_smile:


#4

@eliyas5044 thanks for all that info. I had to reinstall android studio and JDK, and set a few paths for it to work, but it’s all good now.