cocos2d / cocos2d-x

Cocos2d-x is a suite of open-source, cross-platform, game-development tools utilized by millions of developers across the globe. Its core has evolved to serve as the foundation for Cocos Creator 1.x & 2.x.
https://www.cocos.com/en/cocos2d-x
18.16k stars 7.05k forks source link

cocos compile run -p android no longer works after Android SDK update #17424

Closed dmrdev closed 7 years ago

dmrdev commented 7 years ago

Just updated Android SDK tools to the latest version 25.3.1 and now tools/android.bat no longer works, it reports:

The "android" command is no longer available.
For manual SDK and AVD management, please use Android Studio.
For command-line tools, use
tools\bin\sdkmanager.bat and tools\bin\avdmanager.bat
Error running command, return code: 1.

Steps to Reproduce:

  1. Update android SDK to the latest versions
  2. Launch android app build compile compile -p android or compile run -p android
dmrdev commented 7 years ago

Moreover even compile compile -p android --android-studio doesn't work because it also depends on android.bat utility.

liketemple commented 7 years ago

meet same problem.

dumganhar commented 7 years ago

@natural-law , please take a look at this issue. Thanks.

dmrdev commented 7 years ago

As a temporary solution I downloaded the previous version (25.2.3) of SDK tools from this page: https://developer.android.com/studio/index.html (see the bottom of the page) and then replaced tools folder in the Android sdk with the previous one.

dmrdev commented 7 years ago

Sorry, maybe I created an issue in a wrong repository because the same issue was already posted to the cocos2d-console repository almost two weeks ago: https://github.com/cocos2d/cocos2d-console/issues/404

but unfortunately it is not fixed yet.

natural-law commented 7 years ago

Yep, I will fix the problem later. Before that, you can rollback the version of Android SDK tools to avoid the problem. Sorry for the inconvenience!

natural-law commented 7 years ago

@dmrntpv How did you got the Android SDK tools 25.3.1? I just installed the latest version of Android Studio. But I can't update the Android SDK tools version to 25.3.1 (I tried it both on Mac & Windows): image

dmrdev commented 7 years ago

@natural-law, I just run update and chose to update to the latest versions of all suggested packages.

dmrdev commented 7 years ago

@natural-law, just checked again and this is something interesting, now it suggests to update not to 25.3.1, but to 25.2.5.

dmrdev commented 7 years ago

Just now I have updated the tools to 25.2.5 and Android Studio no longer suggests to upgrade it further.

Maybe they rolled back the update after so many complaints.

dmrdev commented 7 years ago

I don't have any special update settings (canary, beta etc). All my Android Studio update settings are set to default.

natural-law commented 7 years ago

Maybe they rolled back the update after so many complaints.

Yep, maybe it is. So, i'll solve the problem once i can reproduce it. Thanks for your feedback!

yjwong commented 7 years ago

Got this issue 2 days ago. As an alternative for the time being, I switched to using Gradle and externalNativeBuild to accomplish my needs. It does bring other great benefits like full debugger support and reliable code-completion in Android Studio.

dmrdev commented 7 years ago

@yjwong, could you please describe how you did that? Does it work with JSB to copy the fresh versions of js-files to resources?

Morozov-5F commented 7 years ago

Not only cocos project experiencing this issue. Android SDK developers just removed a whole bunch of tools. There's a comment on how to make a temporary workaround: https://github.com/NativeScript/nativescript-cli/issues/2583#issuecomment-283712933

dmrdev commented 7 years ago

@natural-law, the new version (25.3.1) of SDK tools is available again via Android Studio updater tool. You can update now and try to fix the issue. Thank you!

formatCvt commented 7 years ago

Confirm bug. Downgrade to 25.2.3 helps. Looks like the solution should be come from Google

thorx2 commented 7 years ago

@formatCvt Unfortunately Google has completely dropped the standalone GUI manager, ergo "android", and has moved all command line SDK management to a new tool found here \tools\bin\ sdkmanager

Not sure if somehow pointing the build command to the new tool would work or not but I am currently in the midsts of trying it.

formatCvt commented 7 years ago

@gamer-11 Cocos (and other game engines) uses tool "android" for project actions (https://developer.android.com/studio/tools/help/android.html), not for sdk management. And now we have no command line tool for this, maybe Google knows how to create/update project from command line since they removed android tool.

yjwong commented 7 years ago

@dmrntpv I wrote a post on Medium detailing how to use externalNativeBuild with cocos2d-x so it doesn't depend on the cocos command line tool. I'm not sure if it works with JSB though, but I would imagine a Gradle script could function as a replacement.

If anyone's interested: https://medium.com/@yjwong/using-externalnativebuild-with-cocos2d-x-f6a3c8eacfc8

formatCvt commented 7 years ago

externalNativeBuild also discussed here https://github.com/cocos2d/cocos2d-x/pull/15676

natural-law commented 7 years ago

Hello, everybody. I'm improving command cocos compile to support the externalNativeBuild in gradle. After that, I'll solve the problem caused by the Android SDK tools 25.3.x.

Thanks for all your feedback!

myxrome commented 7 years ago

Hi, could you plese share your fix?

thorx2 commented 7 years ago

@formatCvt Forgive me if I am wrong. I understand that the command had various purposes(and that other game engines use them, well even the Unity projects are affected by this update). I was merely stating the reason for Google to drop the tool might be that they wanted people to use Android Studio for most of the development. From the link you have shared I get the sense that they have bundled the same via Studio, meaning for the time being the only way (that I know of) to create and manage an android project is via the IDE.

It would be super awesome if we could just open up the project in studio and have the ability to code and compile/deploy in the same environment as in iOS development in xcode.

slackmoehrle commented 7 years ago

@natural-law a user on the forums posted this: https://goo.gl/IlUvSp might be worth a look. He had success.

formatCvt commented 7 years ago

@gamer-11 no problem =) You can try open/code/compile/deploy/debug in studio (Android Studio 2.3) with patch from here https://github.com/cocos2d/cocos2d-x/pull/15676 But we need console too, for continuous integration

natural-law commented 7 years ago

Hi, guys! In the latest code of cocos2d-console, I've solved the error when using Android SDK Tools 25.3.x.

As the release note of Android SDK Tools 25.3.0 said, the ant scripts has been removed. So, The Eclipse project will not be supported with Android SDK Tools 25.3.x.

Hope it's helpful!

formatCvt commented 7 years ago

Thanks!

atsimerman commented 7 years ago

How about cocos2d-x-3.13.1 and earlier ?

minggo commented 7 years ago

It is nothing about cocos2d-x version. It is about the tools version you used.

jgod commented 7 years ago

Replacing the tools works for me. Thanks guys 👍

james-muldoon commented 7 years ago

What version of the tools works? I've been trying to install cocos for the past 3 days using this guide http://cocos2d-x.org/docs/installation/Android-terminal/index.html but all the versions are out of date

jgod commented 7 years ago

@james-muldoon 25.2.3 works for me

james-muldoon commented 7 years ago

@jgod thanks for the reply. That's the version of tools that I have, but I'm still getting the message "The "android" command is deprecated" (shown in screenshot). Are you perhaps using a different SDK or NDK version to me? My NDK is r10c.

2017-04-10
minggo commented 7 years ago

@james-muldoon i think @natural-law has already answered it above. You should copy tools from old Android SDK because some tools are deleted in new Android SDK.

james-muldoon commented 7 years ago

Doing this just creates a different error for me. Do you download the SDK through Android Studio? Since downloading the command line tools now no longer includes the android SDK (further complicating following the given installation instructions)

2017-04-10 3
piotrros commented 7 years ago

@mingoo I've updated cocos console, android sdk tools to the latest and I'm still getting:

cocos gen-libs -p android --app-abi armeabi-v7a

running: '/Users/piotr/Documents/pierdoly/cocos2d-x-3.14/tools/cocos2d-console/bin/cocos compile -s /Users/piotr/Documents/pierdoly/cocos2d-x-3.14/tools/simulator -p android --ndk-mode release --app-abi armeabi-v7a'

Building mode: debug
Using Eclipse project : /Users/piotr/Documents/pierdoly/cocos2d-x-3.14/tools/simulator/frameworks/runtime-src/proj.android
Ant (Eclipse project) is not supported from Android SDK Tools 25.3.0.
Error running command, return code: 101.
crazyhappygame commented 7 years ago

I have the same issue. Latest cocos console, android sdk tools

Ant (Eclipse project) is not supported from Android SDK Tools 25.3.0

rohitchauhan404 commented 7 years ago

https://dl.google.com/android/repository/tools_r25.2.5-windows.zip https://dl.google.com/android/repository/tools_r25.2.5-macosx.zip https://dl.google.com/android/repository/tools_r25.2.5-linux.zip

rename tools folder, and extract and put tools folder from above depending on your OS.

Kingurus commented 7 years ago

I had the same problem. Thank you rohitchauhan365 for posting the fix.

er-bpradip commented 7 years ago

I have an old project in cocos 3.13.x and I have now modified the game code. i am unable to compile this code for android devices. Is there any easy way to upgrade my code to cocos 3.15.x version and compile it. I have upgraded by copying cocos2d folder from new version 1.15.x to my existing project and I saw following error

**Try: Run with --stacktrace option to get the stack trace. Run with --debug option to get more log output.

BUILD FAILED

Total time: 1 mins 52.021 secs Stopped 0 compiler daemon(s). Error running command, return code: 1.**

I am new to cocos, any help will be highly appreciable.

williamxhero commented 7 years ago

cocos2dx is dead. if not for the legacy project, We will definite using Unity.

v1993 commented 7 years ago

@minggo do you agree with @williamxhero?

minggo commented 7 years ago

No, it is caused by Android SDK issue. I think i answered it above. You can use cocos run -p android --android-studio or copy tools folder from old Android SDK.

sgwood commented 6 years ago

@minggo cocos run -p android --android-studio also failed. why?

TankTheFrank commented 6 years ago

@minggo Ant was deprecated a long time ago, unless you're time traveling from 2009 I would say is definitely not an Android SDK issue.

minggo commented 6 years ago

@sgwood cocos run -p android --android-studio works. @TankTheFrank android command is also removed too. What this issue is saying that, Eclipse projects are not supported.

lalaphoon commented 6 years ago

@minggo if my old cocos project (created from 3.4) doesn't have proj.android-studio, is it okay to copy and paste from where it has one (like a project created in 3.16)?

huhuang03 commented 2 years ago

In latest android sdk, the android.bat seems misssing. So functions depends on android.bat will fail, likes projectRoot/setup.py setup andorid.

There's no plan to fix this?