Documentation on CLI android compilation is wrong

Currently the both the docs and the devs on the forums give incredibly confusing and contradictory information on what the cocos command-line tool can/should be used for.

Look at this discussion Some basic questions for learning plan, it occurred a week ago, @slackmoehrle says “If you use XCode or Android Studio you can compile from directly within. You can always use the cocos compile … command from a terminal”. He then later refers to the docs where it’s all “well discussed”.

Now what’s discussed? Here it says under the topic of “Software Installations/Android”: “Deprecated Document. Cocos2d-x V3.15 or less is the last supported version.”. Okay, this however gives the impression that one shouldn’t use it for cocos new either. However if then you visit the “Tools/Command-Line tool” section you can see this under it:
"… command-line tool called cocos … allows you to create new Cocos2d-x applications as well as run them and deploy them … works for all cocos2d-x supported platforms, which include: ios, android, mac, linux, win32, wp8_1, wp10 and web". Why is android there?

Technically cocos compile -p android has been deprecated at least since March 1st 2017 (https://github.com/cocos2d/cocos2d-x/issues/17424) due to the fact that 25.2.5 was the last SDK tools version supporting Ant (required for the command-line-based compilation to work). But since then, the conveying of this problem to users of the framework or the documentation efforts to circumvent this problem has been so horribly executed that I bet it generated frustration for thousands of people. Think of attempts/reactions like this: Cocos2D-x - Cannot compile for Linux and Android crashing in 3.16 .

Why is it that even after 9 months the documentation and even devs in a way advise users to use the command-line tool for android compilation? In the last 2 years Cocos documentation has been like a disguised minefield for newcomers.

1 Like

Damn, I understand you so much.
I struggled for weeks for just compile android or customize the project. Also, many links of docs, examples are awkward, old and not useful. Well… open-source software :slight_smile:

Can you tell me how this implies not to use cocos new? I’ll correct wording if that is what is being implied. cocos new is still perfectly valid.

This: “… command-line tool called cocos … allows you to create new Cocos2d-x applications as well as run them and deploy them … works for all cocos2d-x supported platforms, which include: ios, android, mac, linux, win32, wp8_1, wp10 and web”. Why is android there?

It says create new and deploy which does work for Android still.

Edit: I looked at this: Some basic questions for learning plan
and I do see how that is confusing. You can still compile Android Studio apps from the command line.

In GitHub v3 branch all deprecated Android stuff has been removed already and proj.android_studio is now just proj.android so cocos compile will work.

cocos deploy and cocos run always behaved as cocos compile but on top of it it copied the apk to the device and in case of run it even started the activity. I suppose now it is configured not to run compilation/library repacking/hexing in case of android. It sure did before.

if I read this right, currently, if you are using an older Android SDK then cocos compile works as it always has. It wasn’t until recently that this was broken by the removal of items we depended up for cocos compile. However, now Android command-line development is deprecated all together. These instructions are valid again because proj.android was deprecated and proj.android-studio has been renamed proj.android. I get that this state of flus has caused some confusion.

If you have thoughts on how to word this better, please let me know. I will also review it and see what I come up with.

Thank you for pointing out the confusion. This is why one cannot test their own work. You don’t see where you fail.

I’m actually trying to reinstate my 3.15.1 project after reinstalling Windows. I used CLI android compilation (SDK 22/23) successfully previously with tools downgrade but now I somehow keep getting “The system cannot find the file specified.” errors at various points during compilation so I guess there’s no way but to adopt the Android Studio method.

I would have loved if the compile script were patched to work with Gradle, which should be very much possible (https://developer.android.com/studio/build/building-cmdline.html) but it looks like for some reason that is not happening.