Pre-built libs for android not compiles(as usually :) ), how to build using option with full source code of cocos2d-x and Android Studio?

There is no master.

Screen%20Shot

I’m trying to follow: http://www.cocos2d-x.org/docs/cocos2d-x/en/installation/Android-Studio.html

Created new project: cocos new TestGame -l cpp (I want to use it as clean working project for my game, by adding my source code files into it).

Next -

next, launch Android Studio.

And how to open my project? Open exists project or import? Whats the difference?

Something is missed here:

Launch - missed how to open and what - config project.

@energyy are you still using pre-builts?

Sorry. I was looking in the wrong repo :frowning:

Yes, We really should try and fix this or see what is possible. I was updating the pre-built libs doc the last few days.

I don’t want to use pre-builts for android. It’s all time pain. I’m done… I updated my previous post. There are questions what to do and missed info…

upd.: okay I was able to built new and empty project. Now I’m trying as usually drag and drop my source code files like in Xcode, to the project folder Classes but got an error : Cannot move. How to add my source code cpp files into the project?

Also, where there are no proj.android-studio but only proj.android ?

p.s. actually I’m trying to compile for android all this day, it’s still can’t be compiled. So awkward tool as android) well, I don’t have a choice and need to build my game for it…

If you want compile for android-studio then you need an aditional command --android-studio then in Android-studio IDE select to open it.

Example (without using pre-builts):
cocos compile -p android --ap android-19 --android-studio

I typed that I don’t want to use it. At topic title and in prev. post. I want to use ANdroid Studio and there are post about this question of how to actually, I can’t even add any file into it…

no, we not using prebuilds as it always problem compiling them. Regarding Java 9, yes we also faced that issue on new mac when by default wast installed latest java version, downgrading to java8 fixed issue with compile with older gradle.

1 Like

It seems like prebuilds will work with cmake for all platforms:

Yea… but check my post thoughts - CMake support all platform build & prebuilt libs for cocos2d-x

I’ve got some success with compiling an empty project. But what I’m trying to do next, is move cocos2d-x folder outside, but can’t compile with such config.

This works well:

settings.gradle
project(':libcocos2dx').projectDir = new File(settingsDir, '../cocos2d/cocos/platform/android/libcocos2dx')

Android.mk
$(call import-add-path,$(LOCAL_PATH)/../../../cocos2d) $(call import-add-path,$(LOCAL_PATH)/../../../cocos2d/external) $(call import-add-path,$(LOCAL_PATH)/../../../cocos2d/cocos) $(call import-add-path,$(LOCAL_PATH)/../../../cocos2d/cocos/audio/include)

$(call import-add-path, $(LOCAL_PATH)/../../../cocos2d)


I have cocos2d-x folder located at /Volumes/MacData/cocos2d-x

So, I’m trying to set:

settings.gradle
project(':libcocos2dx').projectDir = new File('/Volumes/MacData/cocos2d-x/cocos/platform/android/libcocos2dx')

Android.mk
$(call import-add-path,/Volumes/MacData/cocos2d-x) $(call import-add-path,/Volumes/MacData/cocos2d-x/external) $(call import-add-path,/Volumes/MacData/cocos2d-x/cocos) $(call import-add-path,/Volumes/MacData/cocos2d-x/cocos/audio/include)

$(call import-add-path, /Volumes/MacData/cocos2d-x)

But I’m getting an error:

Error:A problem occurred configuring project ‘:TestGame’.

executing external native build for ndkBuild /Volumes/MacData/Projects/TestGame/proj.android/app/jni/Android.mk

Any ideas how to fix this?

It could be that there is some module inside which can’t find other module due u moved cocos2d-x folder and it looking for relative/absolute path.

Are u sure that u not getting more output in log? Havre atry compile thru console not Android-studio.

Also it could be due u have cocos2d-x - minus sign inside name, this import-add-path for me is tricky need to have clear view what they do where folder located and so on.

What is reason to move cocos2d-x outside project, u want to safe space or use it to other projects? in this case i recomnd to use symlinks or submodules -depends on how u want to store it.

Heh, I figured out it. Thank anyway for your suggestions.
I just removed folder build manually: /Volumes/MacData/GitProjects/TestGame/proj.android/app/build

When I used Clean Project in studio, it’s not worked. Seems like when I build before with cocos2d folder inside project root, there happened some glitch… when changed paths… studio probably thinks that cocos inside project root, but as I removed it after changed paths, got that error.

Yes and for me this should be like a general idea for using cocos2d-x. A lot of savings for space everywhere, from git to local and speed of building. By the way, are you using ccache? I’ve installed it but after compile in android studio my it’s cache is 0…

good to know, also regarding that android-studio compile vs console, I was trying to upgrade to gradle 3+ in cocos2d-x and there was real mess with studio ;/ cocos for now doesn’t work properly with it, so just in case don’t update it.

For ccache we heard about it, but we for now don’t want to use it as it’s not clear if u compiling really latest code or not and for us it is very critical to be with full control over your code and understand what happening with build.

For this space saving - I really recomnding for you to try submodules, just add repo with cocos2d-x folder and then use it as submodule for new projects where it will be checkouted to cocos2d folder.

Honestly I’m not familiar with android, but I think I’m using all latest?
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip

  dependencies {
        classpath 'com.android.tools.build:gradle:3.0.1'

But all looks ok for me, build succeeded. But will keep my eyes on it :slight_smile:

Yes, it’s will save git, but not locally anyway, plus this build folder, currently for example for my game it’s 2.32Gb if use cocos2d-x folder with git inside project it will add more 2.75Gb. So more than 5Gb for only 1 game.

Yeah, u upgraded to latest one, so far I had issue compiling thru console so I’m assuming u didn’t faced it because compiling with android-studio. For me it also not clear yet how stable apk this new gradle making and if there is any benefits using it.

For that issue then probably u could try also symlink.

Add cocos2d-x to git, then checkout out it to specific location as cocos2d, after making new project make symlink with reltive path to that cocos2d folder and then u can use default project setup, but it is almost same as u doing now - you just no need to change that default config files - so it is up to you how you feel it is easier for you.

I see, well, I’m currently developed only 1-st level for my game, of I hope 100 levels :smiley: so it’s a long time, will test all this on myself.

And as currently I’ve done build with external cocos2d-x folder - everything is ok for me.
Now I know, that cleaning built folders and cache for that android studio is 1st task ever. Omg, tomorrow I will back to Xcode and perfect and ideal development process… today all day with android was like too much stress for me lol.

biggest mess was for me with cache, when devs was making changes like for 2 days in project and when i checkouted project - compililer somehow made build by mixing latest and old files - so I had strange build with some new and old functionality - until I deleted build and extranealndk folder it was mixing classes

btw we now experimenting with cricket audio engine, it seems working in cocos2d-x so maybe would be very good alternative to default one

FMOD is the best, all optimizations and stability. Some weeks ago I’ve found some audio engine free and with remark: its ok but not so fast and cool as FMOD, but you can use it as beginning… probably should create a new topic to talk about audio engines… I can;t find what that engine was… but it’s free and open source as I remember…

ok, would be cool to create new topic:) for it ,we liked fmod , but we need proper wrapper for it, also it cost some money