Hi,
I downloaded and successfully created a basic project with the pre-compiled libraries template from cocos studio 3.10, (without editor since i like drawing and placing stuff in code), I opened win32 project and did my coding without any troubles, even debugging works with the pre-compiled template project.
But now, how do I debug in Android Studio? I know that I can deploy APK with (" cocos deploy -p android -m debug"), but there is not android studio project when you create a pre-compiled project. How do you guys do it?
Tks.
The thing is you can’t. By now at least. I don’t know why, but probably is hard to achieve. This is one of the most desired things by many developers (including me).
You can debug with Android Studio and it’s very easy. You must use the standalone framework though, not the one that comes with Cocos Studio, this way you will have an android studio template installed in proj.android-studio. This helps too: Cocos2d-x Android Studio. Editing the target android sdk versions must be done manually, if you get errors about incompatible android sdk versions post them here.
Hi,@MatrixAndrew
I was saw your video,it’s usefully,but i found that it just told how to compile and run cocos2d-x project on Android Studio,not debug cocos2d-x project’s c++ code in Android Studio.
So,could you tell us how to how to debug in Android Studio?
You can’t compile cocos2d-x projects using Android Studio yet, and in that sense some debugging features are not available (like setting breakpoints). But you can do other things, Logcat is already set up there showing both the system messages of the device and your application’s output. Plus stack traces, thread lifetimes and other useful run-time debugging features can all be displayed in Android Studio. You just have to run your app in debug mode there, clicking on the green bug instead of green play button. http://developer.android.com/tools/debugging/debugging-studio.html
@MatrixAndrew
Hi Andrew,
Tks for the links very useful, however I think that I didn’t really got the right message across, let me try again.
If you download the Cocos Installer 3.10 (not the cocos2d-x zip file), and you create a new project from the Cocos UI, you have the option to create a New Project with the “Precompile Library”, which is great because that make the size of the project folder much smaller ( acouple hundred MB instead of 3-4 Gbs), and it also compiles the project in seconds instead of minutes in comparison with the usual way of creating a project.
And it works great with the Win32, Mac and IOS projects, it compiles really fast and pretty much everything is working great but,…
The “catch” is that creating a project this way, cocos doesn’t create an Android Studio specific project, it just creates an Android Porject that you cant open with Android Studio. So you can’t launch you APK from Android Studio, so you can’t monitor your APK with the ADB with in android studio. I know you can’t "Debug your APK’ as per say, but you could at least listen to messages and monitor your application with in it.
So my question was, is there a way to take advantage of the new precompiled librarires project while still being able to use Android Studio for deploying you APK’s???
Hope I was more explicit this time… tks for your times guys.
As for me I just use eclipse to just see logcat, however I’m running app from console. As for debugging you can use gdb.
Using android studio for now doesn’t make any sense for me. It won’t deploy app anyway.
I like gradle libs include and project configuration setup, so how we can deal without andoroid studio project? We just migrated from eclipse which was nigthmare…
While waiting, I have been trying to find a work around and I found out somtthing that works but, it is kind of a pain in the butt… lol.
Let’s say that I create a project named “MyGame” with cocos UI and pick the “precompiled ibraries” option. After cocos create the folder. I rename the folder to “MyGame1”.
Then I create another project with the same name “MyGame” but now with the option “Source Code”, Cocos will create a folder with the cocos2dx framework included and all the usual project folders, including the Android Studio Folder.
I delete everything from the “MyGame” folder except the “cocos2d”, “android”, “android studio” folders and the CMake file, and then I copy everything from the “MyGame1” folder to the “MyGame” folder exept the “android” folder.
So now I have my precompiled projects for Win32, Mac and IOS and my Android and Android Studio folders that will be looking at the “cocos2d” source code in the project folder.
I tried coding something really quick in visual studio and it compiles fast and without errors. Then I proceded to open the Android Studio project, compiled it with “cocos compile -p android --android-studio” command line, and then deployed it with in android studio, and It picked up the changes I did in visual studio successfully, and I was able to track messages and logs from the running application.
So, it does work with that work around, but it is not pretty, Like “piotrros” stated a couple posts avobe, Using Android Studio in the develoopment state wouldn’t make sense right now since it would defeat the purpose of the fast development using precompiled files, so I guess that right now, the workflow would be to develop everything in desktop mode all you can until you have the need to start testing things in anroid, then you need to switch to a “Source code project”, unless someone else have a solution, although it might be a limitation of the android environment with NDK and not with the Framework itself, hopefully we can hear something from the developers…
Anyway, tks for the help guys, hopefully someone finds a good way around it.
Hi,
I’m new here and I’m studying cocos2d-x 3.10, upgrade to 2.7.11 python, my problem is I can not compile, I get the following from terminal:
MacBook-Pro-de-Jamso:Project_SC Jaime$ cocos compile -p android —android-studio
Traceback (most recent call last):
File “/Applications/Dev/cocos2d-x-3.10/tools/cocos2d-console/bin/cocos.py”, line 22, in
import cocos_project
File “/Applications/Dev/cocos2d-x-3.10/tools/cocos2d-console/bin/cocos_project.py”, line 4, in
import cocos
File “/Applications/Dev/cocos2d-x-3.10/tools/cocos2d-console/bin/cocos.py”, line 874, in
language, encoding = locale.getlocale()
File “/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/locale.py”, line 562, in getlocale
return _parse_localename(localename)
File “/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/locale.py”, line 475, in _parse_localename
raise ValueError, ‘unknown locale: %s’ % localename
ValueError: unknown locale: UTF-8