Android generate apk for two platforms: armeabi-v7a:x86 (split apk)

Android generate apk for two platforms: armeabi-v7a:x86 (split apk)
0.0 0

#1

Hi,

I found crashes on Intel Android devices. I would like to have to apk armeabi-v7a and x86
How do you generate apk for two platforms?

I do not want to have single apk with both platforms inside (size is too big).
I set split apk https://developer.android.com/studio/build/configure-apk-splits.html
but
cocos compile -m release -p android --android-studio --ap android-19 --app-abi armeabi-v7a:x86 --ndk-mode release

fails with error:
23:37:31 Traceback (most recent call last): 23:37:31 File "g:\j\A\external\cocos2d-x\tools\cocos2d-console\bin\/cocos.py", line 998, in <module> 23:37:31 run_plugin(command, argv, plugins) 23:37:31 File "g:\j\A\external\cocos2d-x\tools\cocos2d-console\bin\/cocos.py", line 916, in run_plugin 23:37:31 plugin.run(argv, dependencies_objects) 23:37:31 File "g:\j\A\external\cocos2d-x\tools\cocos2d-console\plugins\plugin_compile\project_compile.py", line 1668, in run 23:37:31 self.build_android() 23:37:31 File "g:\j\A\external\cocos2d-x\tools\cocos2d-console\plugins\plugin_compile\project_compile.py", line 544, in build_android 23:37:31 self.apk_path = builder.do_build_apk(build_mode, self._no_apk, output_dir, self._custom_step_args, self) 23:37:31 File "g:\j\A\external\cocos2d-x\tools\cocos2d-console\plugins\plugin_compile\build_android.py", line 546, in do_build_apk 23:37:31 shutil.copy(gen_apk_path, output_dir) 23:37:31 File "g:\j\A\3rdparty\Python27\lib\shutil.py", line 119, in copy 23:37:31 copyfile(src, dst) 23:37:31 File "g:\j\A\3rdparty\Python27\lib\shutil.py", line 82, in copyfile 23:37:31 with open(src, 'rb') as fsrc: 23:37:31 IOError: [Errno 2] No such file or directory: 'g:\\j\\A\\repos\\puzzlegit\\my_app\\proj.android-studio\\app/build/outputs/apk\\PuzzleAnimalsGst-release.apk'

Two apk are created in folder ‘g:\j\A\repos\puzzlegit\my_app\proj.android-studio\app/build/outputs/apk\’.
Regards,
CHP


#2

If you have two APKs in the output folder, everything is fine. The cocos build tools isn’t smart enough to see both. The error also occurs, if you want to build more than one flavor for your apps. Just ignore the no such file or directory message. The cocos command just want to copy the APK into another folder, that’s why it shows this error.

And because you are using the proj.android-studio, why don’t you use gradle to compile your project? You don’t need to use the cocos command anymore.


#3

mars3142,

Thank you for answer.
I do not know gradle… What should I call instead of:

cocos compile -m release -p android --android-studio --ap android-19 --app-abi armeabi-v7a:x86 --ndk-mode release

Regards,
CHP


#4

In the proj.android-studio path you’ll find probably a gradlew file. Just call this

gradlew build

This should do the main work. If everything is fine, you’ll find in app/build/outputs/apk the same both files, the cocos command created (hopefully). But the command is much easier zu remember :wink:

The only different is, as I said earlier, that cocos wanted to copy the APK into another build folder, which isn’t necessary at all.


#5

mars3142,

Thank you for answer.
But how can I set all those parameters “-m release–ap android-19 --app-abi armeabi-v7a:x86 --ndk-mode release”?
It should be set in build.gradle file?

Regards,
CHP


#6

Maybe Android Studio support will help you. I was able to use it to create my build with gradle (but it helped me a lot, that my day job is Android developer).