- تم التحرير
Bug: Crash on Android with Cocos2d-x
Hello,
We're using cocos2d-x 3.12 combined with the latest Spine runtime.
Android Version 4.4.2 on a Nexus 7 (2012)
Now we're trying load a Skeleton using this code:
SkeletonAnimation *skeleton = SkeletonAnimation::createWithFile("DizznySniper.json", "DizznySniper.atlas");
This works fine on iOS but does not on Android. This is the Stacktrace on Android, recorded via Crashlytics:
0 libc.so 0x40113e38 strlen
1 libc.so 0x4011c5c5 strdup
2 libcocos2dcpp.so 0x6ed0bf9c spSkeletonJson_readSkeletonData
3 libcocos2dcpp.so 0x6ed0bef8 spSkeletonJson_readSkeletonDataFile
4 libcocos2dcpp.so 0x6ed007dc spine::SkeletonRenderer::initWithFile(std::string const&, std::string const&, float)
5 libcocos2dcpp.so 0x6ed003f4 spine::SkeletonRenderer::SkeletonRenderer(std::string const&, std::string const&, float)
We made sure that the files are present on Android with a log placed in _spUtil_readFile
length 2482 READ assets/common/DizznySniper.atlas
length 37340 READ assets/common/DizznySniper.json
Since it works on iOS, the file is present on Android and it worked fine on Android with the previous Spine Runtime, I believe there's an Android specific bug in the latest Spine Runtime.
Created an issue here, let's continue the discussion there [cocos2d-x] Crash on Android loading specific files · Issue #704 · EsotericSoftware/spine-runtimes · GitHub
Isn't the solution in the discussion link applied to runtime yet? I got the crash like this with cocos2d-x 3.13.1 and recently spine runtime. It's working good in iOS and android 5.0.1, but crashed in android 4.4.4.
Yes, the fix has been applied. Please update to the latest runtime files from the master branch of the GitHub repository.
I used the latest runtime but when I try to load spine data, it's still crashed in Android 4.4.4.
Can your provide me with a project that reproduces the error? Ideally, I can just download it, add the cocos2d-x code and compile/run for Android.
It's not a special project when I tested it. (on El capitan)
- Make a project with cocos2d-x 3.13.1 (recently version)
- Replace spine runtime as recently version (from GitHub)
- Try to load a spine sample
It is working good in iOS and Android 5.0 device (LG G3), but crashed only in Android 4.4.4 device (Samsung galaxy S3) with this log. It seems like the first post.
libMyGame.so (spSkeletonJson_readSkeletonData+92)
libMyGame.so (spSkeletonJson_readSkeletonDataFile+132)
libMyGame.so (spine::SkeletonRenderer::initWithFile(std::string const&, std::string const&, float)+328)
libMyGame.so (spine::SkeletonRenderer::SkeletonRenderer(std::string const&, std::string const&, float)+196)
And I saw spine runtime update (cocos2d-x) on Github 4 hours ago, so replace to that version and try to build. But it makes build error on iOS build.
(Error log : Cannot initialize a parameter of type 'spAtlas *' with an lvalue of type 'const char[37]')
So I rollback the spine runtime to 3 days ago version.
I'll give Android another try. For the compilation error on iOS, can you please provide the full build log? Which file, which line?