The "android" command is no longer available

Hi all,

I bought a new computer and I installed Cocos Creator 1.4.2 with the latest Android Studio (2.3.1). When I try to build an APK of my game, the “build” finishes without error, but the “compile” fails. In the native.log file I see the following:

Building mode: release
Using Android Studio project : C:\Users\PZsol\Documents\Cocos14\AriesPegSolitaire\build\jsb-default\frameworks\runtime-src\proj.android-studio
running: ‘“c:\Users\PZsol\AppData\Local\Android\sdk\tools\android” update project -t android-19 -p C:\Users\PZsol\Documents\Cocos14\AriesPegSolitaire\build\jsb-default\frameworks\runtime-src\proj.android-studio\app’


The “android” command is deprecated.
For manual SDK, AVD, and project management, please use Android Studio.
For command-line tools, use tools\bin\sdkmanager.bat
and tools\bin\avdmanager.bat


Invalid or unsupported command “update project -t android-19 -p C:\Users\PZsol\Documents\Cocos14\AriesPegSolitaire\build\jsb-default\frameworks\runtime-src\proj.android-studio\app”

Supported commands are:
android list target
android list avd
android list device
android create avd
android move avd
android delete avd
android list sdk
android update sdk
Error running command, return code: 1.

What can I do?

Thanks in advance,
Zsolt

there was alredy several topics about it - there is changes in latest android sdk - u need to replace it with old one.

Thanks for your reply, it helped. I replaced the android.bat with the old one, but now I get the following error message:

Error: Unable to access jarfile lib\archquery.jar
Invalid drive specification
ERROR: SWT folder ‘’ does not exist.
Please set ANDROID_SWT to point to the folder containing swt.jar for your platform.

On my old computer there is no such environment variable, and it works… what’s wrong now?

Thanks again and best regards,
Zsolt

Solution here http://discuss.cocos2d-x.org/t/cocos-compile-p-android-deprecated/35359

If you work on linux here is old workable SDK tools https://dl.google.com/android/repository/tools_r25.2.3-linux.zip

I downloaded the whole android-tools_r25.2.3-windows.zip, but I get more and more error messages. It looks quite complicated.

So, I think I will wait for the official Cocos Creator support for the newer Android tools.

Thanks again,
Zsolt

I had a similar problem but I fixed it by replacing the “tools” folder under sdk with the following file extracted: https://dl.google.com/android/repository/tools_r25.2.5-windows.zip

Thanks, I’ll give it a try soon. :slight_smile:

Best regards,
Zsolt

I get the same error message:

Android NDK: WARNING: APP_PLATFORM android-19 is larger than android:minSdkVersion 9 in ./AndroidManifest.xml

:frowning:

Technically this is a warning, not an error. This alone won’t cause you problems.

That is true, but it stops compiling. Maybe there is some problem with the Android NDK path, because compared to my old installation Android Studio 2.3.1 stores the NDK on a different path.

But for building the APK I can still use my old computer, so it is not soooo urgent, I can wait for the “official” support in Cocos Creator.

Best regards,
Zsolt

Referring to all the fix by replacing tools solution, I don’t think this is a long term solution. Since Google have planned to deprecate it, using an older version tools as a workaround solution is basically assuming we wouldn’t update the tools at all in the future.

For manual SDK, AVD, and project management, please use Android Studio.

Seems like Google wants workflow to be managed using Android Studio. Perhaps the better solution is to document a Cocos Creator project compiled with android studio process.

Ok, one more question: what is the Android NDK root if I installed it with Android Studio 2.3.1?

Thanks in advance,
Zsolt

First of all, NDK stands for Native Development Kit. Since the default app development language on Android is Java, the kits allows usage of native (C++) code.

We will face another issue while working with Cocos Creator project since they are not supporting the latest NDK version. The last official supported version I known was version r10e.

Android Studio manages the NDK, by default on Mac OS it is placed at “/Users/yourusername/Library/Android/sdk”. Note that there’s no way of downgrading the NDK. You will need to figure out a workaround if your version is not supported by the Cocos team.

PS: Perhaps replacing NDK with the desired version on the path that Android Studio referring to might work.

Meanwhite I created a build for the Android Studio (the Android Studio checkbox was checked). It was able to compile and create the APK that was successfully uploaded on my Android device(s), but the game crashes on start.

This method can be a workaround, I create a “build” with Cocos Creator, and “compile” with the Android Studio. But it does not work… any idea?

Best regards,
Zsolt

This PR updated the cocos2d-x-lite to support latest android-studio and ndk.
And one more feature is it will auto compile native code when build apk in android-studio.
This feature will be published in v1.5, or you can modify your project yourself according to this pr. :slight_smile:

Hello @jyinkailej, thanks for your response. The pull request link you attached is broken.

Oh, my fault!
Updated.

Well, I think I will wait for v1.5, I don’t want to spend more time with hacking the system. Many thanks for your efforts!

Best regards,
Zsolt