Context:
- You have an application that was developed 7 years ago and there have been no updates since then.
- Your application was developed with python 2.7, Java 8, Android SDK 7.0 (API level 24), tools_r25.2.5, ndk-r13, ant 1.9.4, and cocos2d-x 3.13.1 (Sadly its development was discontinued).
Problem:
- Google Play requires you to update your app to target Android 12 (API level 31).
Experience:
1. You tried installing all the tools and compiling the code. Luckily no problem happened.
2. You checked for Java and Gradle compatibility. You decided to stay with Java 8 because cocos2d-x only works best with Java 8. It means that your Gradle version must be less than 4.3. So you selected version 4.1 for Gradle.
3. You checked for Gradle and Android Gradle Plugin compatibility. You realized that you can only use Android Gradle plugin version 3.0.0 or less. So you selected version 3.0.0 for Android Gradle plugin.
4. You searched for “gradle-wrapper.properties” and updated Gradle to version 4.1.
#distributionUrl=https\://services.gradle.org/distributions/gradle-2.4-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
5. You searched for “build.gradle” and updated Android Gradle plugin to version 3.0.0.
buildscript {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
dependencies {
// classpath 'com.android.tools.build:gradle:1.3.0'
classpath 'com.android.tools.build:gradle:3.0.0'
...
6. You set your app targetSdkVersion to 31, created APK file and uploaded it to Google Play.
7. Google Play complained about “android:exported” property for activities with “intent-filter“. You added “android:exported” property to your AndroidManifest.xml but the problem still persisted.
8. You suspected that Google Play Services library caused the issue because your app uses Firebase Ads that depends on Google Play Services library. So you tried removing Firebase Ads and you were happy when Google Play did not complain anymore.
9. Then you decided to add Google AdMob SDK to your app to replace Firebase Ads. You set your minSdkVersion to 19, your targetSdkVersion to 33 and follow the instructions until you got many build errors with play-services-ads:22.4.0.
10. You tried using latest SDK tools (26.1.1) but you got “The “android” command is deprecated.” issue. cocos2d-x development had been discontinued so you had to revert back to 25.2.5 SDK tools.
11. You tried downgrading play-services-ads to a lower version using trials and errors and luckily you found that version 17.2.1 worked.
12. You created APK file, uploaded it to Google Play, and sent for review. Google Play complained that you must have included 64-bit and 32-bit native code in your app.
13. Luckily, you could build cocos2d-x 3.13.1 for 64-bit architectures by searching for “Application.mk” and set APP_ABI :=armeabi-v7a arm64-v8a, and searching for “gradle.properties” and set PROP_APP_ABI=armeabi-v7a:arm64-v8a, and searching for “build.gradle” and set ndk.abiFilters ‘armeabi-v7a’, ‘arm64-v8a’ under defaultConfig. You also noticed that cocos2d-x 3.13.1 has not supported x86_64 achitectures but at least finally you could be able to publish your app to Google Play.
Lessons learned:
1. Select mature and long-term support tools for your application development.
2. Always package the tools that you used together with the application source code.
3. Always document source code compilation steps and configuration setting locations.
4. Regularly update your application if possible.