Android cpp-tests - missing Resources

I’ve downloaded cocos2d-x 3.17.2, unzipped, and ran setup.py.

I opened tests/cpp-tests/proj.android in Android Studio (3.4.1)

I got an “Error configuring” very much like this post: https://github.com/cocos2d/cocos2d-x/issues/19293
I had to change
#PROP_BUILD_TYPE=cmake
to
PROP_BUILD_TYPE=ndk-build
in
gradle.properties,
like the post advises - then it compiled.

I’m not sure what I’m doing here to be honest - I’m completely knew to Android - but since that post is from January, this ought to be fixed by now.

Then, trying to run the test, I’m completely missing the stuff from Resources - I can see in Android Studio that I do not have an “assets” folder that it should have gotten copied into, and the first asset it tries to load (arial.ttf) it can’t find.
Sounds similar to this:

I would really like to get the tests to run. What do I have to change to get the Resources copied into the package?

Note that if I create a new project with cocos cmd line tool, the Resources for that do get added to the package, and I am able to run the placeholder app.

Thanks
Greg

Thanks for posting. We can look into it.

@coulsonwang @zhangxm

@gmayer you should install ninja by your self as the issue said.

@zhangxm I read that also - but I don’t even know what that means. I read a bit about the Ninja build system, but I don’t know if there is some way through Android Studio that I’m supposed to do this?
Also, I don’t know if this is in regards to the lack of Resources getting copied, or the build failure. Which one is ninja supposed to fix?

As noted, I fixed the build failure with PROP_BUILD_TYPE=ndk-build.

Also, as noted, a new project, created with cocos cmd line tool did not have the Resource-copy problem.

thanks
Greg

Because now cocos2d-x uses cmake by default, and new Android Studio system uses cmake to generate ninja, so that’s why it needs installing ninja. And it seems Android Studio shift ninja, but not set the environment variable correctly. We will try to set it in setup.py.

Thanks @zhangxm - in the meantime, how do I fix cpp-tests locally so the Resource get copied over?
Would installing ninja fix that? If so, can you give me a bit more detail (I’m sorry I’m a total noob when it comes to Android) - do I download something manually from https://ninja-build.org/ or do I install something through the SDK Manager in Android Studio?

thanks
Greg

@gmayer i don’t think ninja is something with resources, it is only used to build source codes. You can manually install ninja and set it to environment variable.

Understood. So… my main question, and the title of this thread, is as of yet unanswered.

Does anyone out there know how to fix Android cpp-tests to copy Resources over correctly?

thanks in advance :slight_smile:
greg

Does android studio automatically install ninja ? because I never had to download it or install it and my cocos2d-x v3.17.2 project is building fine on Android Studio 3.4.1

are you developing on windows or mac OS ? I can confirm the assets folder doesn’t show up on mine either but it is still building successfully

I am building on Windows. How about you @IzzyJM?

As noted, for a new project, the Resources do get copied to an assets folder. Just not for the cpp-tests.

1 Like

I am building on Mac OS, i read around in the forums that on windows android studio sometimes doesn’t locate the ninja so you have to set the path for the variable and then everything should build fine even with the assets folder not there because it built for me without the assets folder visible on the left panel

@gmayer could you please describe the steps you did in more detail? And what’s the error log?

Hi @zhangxm, I don’t have log output handy right now (I’m on a different machine), but in summary, I downloaded and unzipped 3.17.2, ran setup.py (skipping the NDK_ var settings for now), and followed these instructions:

https://docs.cocos2d-x.org/cocos2d-x/en/installation/Android-Studio.html

As noted, to get it to build I had to set: PROP_BUILD_TYPE=ndk-build

Could I suggest that if Ninja is needed, details be added to these (otherwise excellent) instructions?
i.e. what exactly is the envvar that needs to be set, and where should it be pointing?

The important part of the log output from the cpp-tests was basically an error on the first asset it tries to load, which I believe was arial.ttf.

Also, it is still unclear to me so far in this thread if Ninja has anything to do with the missing Resources copy for cpp-tests. From your previous comments, it sounds like not.

Not sure if this is possible, but if you have a fresh machine available (Mac or Windows), can you try the above? i.e. download the engine, install Android Studio, and try and build and run ccp-tests?

thanks
Greg
(* also, could someone please add to the Android instructions to install LLDB from the SDK Manager - I could not hit breakpoints in C++ until I did this, though it gave no indication that this was the problem)

This is something I can help with. It is indeed unclear to me if ninja is needed, actually.

I do have a spare MacBook Air I can wipe and try these instructions. I’ll start it today.

Edit: apparently my Air needs to do an Internet Install and estimated 15 hours! geez. We are supposed to be getting fiber internet in the next month (dates keep changing), fingers crossed.

1 Like

Thanks @slackmoehrle!

@gmayer we tried to set environment variable for ninja in setup.py.

Solution: Edit app/build.grade

sourceSets.main {
    java.srcDir "src"
    res.srcDir "res"
    manifest.srcFile "AndroidManifest.xml"
    assets.srcDir "../../Resources" <-------- added
}

This creates an assets folder.

In my case, this error occurs when run.

Execution failed for task ': CppTests: mergeDebugAssets'
../tests/cpp-tests/Resources/Images/test_image_rgba4444.pvr.gz: Error: Duplicate resources

Deleting the file ‘test_image_rgba4444.pvr.gz’ resolves itself.

Hi @gmayer just wanted to let you know I started this today and so far a few changes to the docs for clarity are being made (will be here once I can push: https://github.com/cocos2d/cocos2d-x-docs/pull/230)

Between macOS internet restore, XCode, Android Studio, Cocos and all the related stuff my connection has been hammered for days. Slow DSL. I am at the point now where I am creating a new virtual device and it is installing what it needs, another 2gb. So soon I’ll be back in touch.

I’m having trouble getting cpp-tests to run in am emulator. I’ll try a device later today and see if that fairs better.