-
-
Notifications
You must be signed in to change notification settings - Fork 214
Update guide to v2.3.0 for Android
For v2.3.0+ of Axmol, the project template has changed, so any projects being moved to that version need to be updated. Most of the changes are in the proj.android
folder, such as app/build.gradle
. Also, a file named .axproj
now exists in the root of the project, which is where all the configuration goes (such as the NDK version, min SDK, etc. for Android).
If you see the error, java.lang.Exception: No installed ndk found, required 23.3.*
, then it means that you need to install NDK r23d (23.3.12186248) or higher. The Android Studio SDK Manager does not have this version listed, so you cannot install it from there. Running the following command from inside the Axmol root folder will install NDK r23d:
./setup.ps1 -p android
Alternatively, you can read the information below on how to set the NDK version in your own project.
Please take in account the following indications:
The org.axmol
namespace has changed to dev.axmol
. In CMakeLists.txt
:
config_android_shared_libs("org.axmol.lib" "${CMAKE_CURRENT_SOURCE_DIR}/proj.android/app/src")
now becomes as follows:
config_android_shared_libs("dev.axmol.lib" "${CMAKE_CURRENT_SOURCE_DIR}/proj.android/app/src")
A file named .axproj
is now generated in the root folder of the project. Any project being upgraded from a previous version of Axmol needs to have this file added. The easiest way to do this is to just generate a new AXmol project (via axmol new
etc.) and copy the file over to your existing project.
The settings that can be added to .axproj
are all listed in this file, which happens to also set the default values:
https://github.com/axmolengine/axmol/blob/dev/1k/build.profiles
For example, if you need to use NDK r25 and have the minimum SDK level set to 21, and target_sdk to 35, the following must be added to .axproj
:
min_sdk=21
target_sdk=35
ndk=r25a+
The location of the Axmol java files has changed locations, so in previous version it would have been in {project}/proj.android/app/src/org/
, but now it has changed to {project}/proj.android/app/src/dev/
. Just rename the org
to dev
, and update any references in your Java code to the updated namespace. For example:
import org.axmol.lib.AxmolActivity;
Would change to
import dev.axmol.lib.AxmolActivity;
{project}/proj.android/app/build.gradle
has been updated, so it would be best to compare one from a newly generated project (from Axmol 2.3.0+) to your existing one. For example, the for projects running on Axmol v2.x, it would have something similar to this content:
android {
namespace "test"
compileSdk PROP_COMPILE_SDK_VERSION.toInteger()
// Setup native build tools: ndk & cmake
def nbtInfo = axutils.findNativeBuildTools(project, '3.28.1+')
ndkVersion = nbtInfo[0]
if(nbtInfo[1]) {
ndkPath = nbtInfo[1]
}
def cmakeVer = nbtInfo[2]
def cmakeOptions = Eval.me(nbtInfo[3])
defaultConfig {
applicationId "test"
minSdkVersion PROP_MIN_SDK_VERSION
targetSdkVersion PROP_TARGET_SDK_VERSION
versionCode 1
versionName "1.0"
externalNativeBuild {
cmake {
arguments = []
arguments.addAll(cmakeOptions)
cppFlags "-frtti -fexceptions -fsigned-char"
}
}
ndk {
abiFilters = __1K_ARCHS.split(':').collect{it as String}
}
}
In Axmol v2.3.0 projects, this has now changed to:
android {
// Resolve build profiles
def buildProfiles = AxmolUtils.resolveBuildProfiles(project)
def packageName = buildProfiles['packageName']
def cmakeVer = buildProfiles['cmakeVer']
def cmakeOptions = Eval.me(buildProfiles['cmakeOptions'])
def minSdk = buildProfiles['minSdk']
def targetSdk = buildProfiles['targetSdk']
// Apply build profiles
namespace packageName
compileSdk targetSdk.toInteger()
ndkVersion = buildProfiles['ndkVer']
if(buildProfiles.containsKey('ndkPath')) {
ndkPath = buildProfiles['ndkPath']
}
defaultConfig {
applicationId packageName
minSdkVersion minSdk
targetSdkVersion targetSdk
versionCode 1
versionName "1.0"
externalNativeBuild {
cmake {
arguments = []
arguments.addAll(cmakeOptions)
cppFlags "-frtti -fexceptions -fsigned-char"
}
}
ndk {
abiFilters = __1K_ARCHS.split(':').collect{it as String}
}
}