Android build in release mode

Hello I’m preparing to release my app and It doesn’t work:

I ran the command cocos run -s /myProject -p android -m release and it attempts to build in release mode
but then it gives me weird errors.

I’m running cocos2d-x v3.15 and Ndk version of 11.2.2725575 (to be exact)

I noticed in Application.mk if I build in release mode it changes the APP_OPTIM to release which is the cause of the problem. I kept it APP_OPTIM to be set to debug and everything works! and it asks for a keystore path…

Will me setting APP_OPTIM to debug have an effect on my application?
What does in fact APP_OPTIM do? what does it matter if i set it to one or the other?

Maybe try to compile it first and use android studio (better support).

cocos compile -p android --android-studio -m release

Also add “release keys” to the gradle properties.

I assume you have added all the files to Android.mk?

Yea all files are added in Android.mk.
What is the “release keys” can you show me how to add that to the gradle properties file?

can refer to this doc

Are you using ‘Device::setKeepScreenOn’ in your code? or any of Device:: things?

I don’t think so

Have you tried compiling android with --android-studio flag? Even without release keys (link already posted how to set it up) you should be able to compile everything.