Skip to content

Commit d76be15

Browse files
committed
Android Template Update
1 parent d357d06 commit d76be15

9 files changed

Lines changed: 81 additions & 100 deletions

File tree

scripts/templates/android2024/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ buildscript {
77
mavenCentral()
88
}
99
dependencies {
10-
classpath 'com.android.tools.build:gradle:7.4.2'
10+
classpath 'com.android.tools.build:gradle:8.9.0'
1111
}
1212
}
1313

scripts/templates/android2024/gradle.properties

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@ android.useAndroidX=true
22
android.enableJetifier=false
33
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
44
kotlin.code.style=official
5-
android.prefabVersion=1.0.+
5+
android.prefabVersion=2.1.+
66
android.buildFeatures.prefab=true
7-
#ndkBuild=false
8-
# https://issuetracker.google.com/149575364
97
android.enableParallelJsonGen=false
10-
#googleplay=true
8+
android.defaults.buildfeatures.buildconfig=true
9+
android.nonTransitiveRClass=false
10+
android.nonFinalResIds=false
11+
googleplay=false
-9.82 KB
Binary file not shown.
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
#Mon Jun 12 01:17:57 AEST 2023
21
distributionBase=GRADLE_USER_HOME
32
distributionPath=wrapper/dists
4-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip
4+
networkTimeout=10000
5+
validateDistributionUrl=true
56
zipStoreBase=GRADLE_USER_HOME
67
zipStorePath=wrapper/dists

scripts/templates/android2024/local.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@
44
# Location of the SDK. This is only used by Gradle.
55
# For customization when using a Version Control System, please read the
66
# header note.
7-
#Wed May 08 13:54:16 CEST 2024
8-
sdk.dir=/Users/thierry/Library/Android/sdk
7+
#Thu Mar 06 00:08:45 AEDT 2025
8+
sdk.dir=/Users/one/Library/Android/sdk

scripts/templates/android2024/ofApp/build.gradle

Lines changed: 16 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,8 @@ plugins {
55
def CMAKELIST_PATH = './src/main/cpp'
66
def CPP_SOURCE = './src/main/cpp'
77
def JAVA_SOURCE = './src/main/java'
8-
9-
// pointing to cmake's source code for the same project
108
def PRJ_SRC_ROOT = './src/main'
11-
def ofRoot(){ return '../../../../' }
9+
static def ofRoot(){ return '../../../../' }
1210
final ofSource = ofRoot() + 'libs/openFrameworks'
1311
final ofLibs = ofRoot() + 'libs'
1412
final addons = ofRoot() + 'addons'
@@ -19,7 +17,7 @@ def enableProguardInReleaseBuilds = true
1917
def enableProguardInDebugBuilds = false
2018

2119
task wrapper(type: Wrapper) {
22-
gradleVersion = '7.3.3'
20+
gradleVersion = '8.9.0'
2321
}
2422
tasks.register("prepareKotlinBuildScriptModel"){
2523
}
@@ -32,12 +30,11 @@ tasks.whenTaskAdded { task ->
3230
}
3331
}
3432

35-
3633
android {
3734
compileSdkVersion 34
38-
buildToolsVersion '32.0.0'
35+
buildToolsVersion '35.0.0'
3936
//ndkPath "/Users/x/android-ndk-r21e" // Point to your own NDK if needed
40-
ndkVersion '24.0.8215888' // use android studio side loaded ndk
37+
ndkVersion '28.0.13004108' // use android studio side loaded ndk
4138
buildFeatures {
4239
prefab true
4340
}
@@ -46,19 +43,19 @@ android {
4643
}
4744
release {
4845
storeFile new File("${System.properties['user.home']}/.android/debug.keystore")
49-
storePassword 'android'
5046
storeType "jks"
5147
keyAlias 'androiddebugkey'
52-
keyPassword 'android'
48+
// storePassword 'android' // <- UPDATE THIS
49+
// keyPassword 'android' // <- UPDATE THIS
5350
}
5451
}
5552
defaultConfig {
5653
applicationId "cc.openframeworks.emptyExample" // IMPORTANT : THIS DEFINES THE ID OF THE APK
57-
minSdkVersion 21
54+
minSdkVersion 24
5855
targetSdkVersion 34
5956
versionCode 12
6057
versionName '12.0'
61-
ndk.abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86' //, 'x86_64'
58+
ndk.abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86_64'
6259

6360
externalNativeBuild {
6461
if (!project.hasProperty("ndkBuild")) {
@@ -118,22 +115,16 @@ android {
118115
java.srcDirs = ["${PRJ_SRC_ROOT}/java",
119116
"${OFX_ANDROID}/Java"]
120117
res.srcDirs = ["${PRJ_SRC_ROOT}/res"]
121-
// jniLibs.srcDirs = ["${OF_ANDROID_OUTPUT}", "lib"] // Pre Android Studio 2022.2.1
122118
assets {
123119
srcDirs 'src/main/assets', 'src/main/bin/data'
124120
}
125121
}
126122
}
127123
externalNativeBuild {
128-
if (!project.hasProperty("ndkBuild")) {
129-
cmake {
130-
path "${CMAKELIST_PATH}/CMakeLists.txt"
131-
}
132-
} else {
133-
ndkBuild {
134-
path "${CMAKELIST_PATH}/Android.mk"
135-
}
136-
}
124+
cmake {
125+
path "${CMAKELIST_PATH}/CMakeLists.txt"
126+
}
127+
137128
}
138129
compileOptions {
139130
sourceCompatibility JavaVersion.VERSION_1_8
@@ -146,6 +137,7 @@ android {
146137
includeInApk false
147138
includeInBundle false
148139
}
140+
namespace 'cc.openframeworks.android'
149141
// testOptions {
150142
// devices {
151143
// pixel2api29 (com.android.build.api.dsl.ManagedVirtualDevice) {
@@ -165,11 +157,11 @@ android {
165157

166158
dependencies {
167159
implementation fileTree(dir: 'libs', include: ['*.jar'])
168-
implementation 'androidx.appcompat:appcompat:1.6.1'
169-
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
160+
implementation 'androidx.appcompat:appcompat:1.7.0'
161+
implementation 'androidx.constraintlayout:constraintlayout:2.2.1'
170162
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
171163
implementation "com.getkeepsafe.relinker:relinker:1.4.5"
172-
implementation 'com.google.android.material:material:1.9.0'
164+
implementation 'com.google.android.material:material:1.12.0'
173165
if (project.hasProperty("googleplay")) {
174166
implementation "com.google.android.gms:play-services-games:22.0.1"
175167
implementation "com.google.android.gms:play-services-auth:20.0.1"

scripts/templates/android2024/ofApp/src/main/AndroidManifest.xml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3-
package="cc.openframeworks.android"
43
xmlns:tools="http://schemas.android.com/tools"
54
android:versionCode="1"
65
android:versionName="1.0" >
@@ -58,7 +57,7 @@
5857
<meta-data
5958
android:name="android.max_aspect"
6059
android:value="2.4" />
61-
<!-- Google Play Game Services -->
60+
<!-- Google Play Game Services -->
6261
<!-- <meta-data-->
6362
<!-- android:name="com.google.android.gms.games.APP_ID"-->
6463
<!-- android:value="@string/app_id" />-->
@@ -86,4 +85,4 @@
8685
</intent-filter>
8786
</activity>
8887
</application>
89-
</manifest>
88+
</manifest>

scripts/templates/android2024/ofApp/src/main/cpp/CMakeLists.txt

Lines changed: 42 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,19 @@
22
# library.
33
cmake_minimum_required(VERSION 3.22.1)
44

5-
project(ofapp LANGUAGES CXX)
5+
project(ofApp LANGUAGES CXX)
66
set(TARGET_ANDROID TRUE)
77

88
set(LOCAL_PATH ${CMAKE_SOURCE_DIR})
99
set(PRJ_OF_ROOT ${LOCAL_PATH}/../../../../../../../)
10-
1110
set(PURE_OF_ROOT ${LOCAL_PATH}/../../../../../../../)
1211
set(CORE_OF_ROOT ${PURE_OF_ROOT}/libs/openFrameworks)
1312
set(LIBS_ROOT ${PURE_OF_ROOT}/libs)
14-
1513
set(PRJ_ADDONS_PATH ${PURE_OF_ROOT}/addons)
1614
set(PRJ_SOURCE_PATH ${LIBS_ROOT}/openFrameworks)
1715
set(PRJ_LIBS_ROOT ${PURE_OF_ROOT}/libs)
18-
1916
set(OF_ANDROID ${PURE_OF_ROOT}/libs/openFrameworksCompiled/project/android)
2017
set(OF_ANDROID_OUTPUT ${PURE_OF_ROOT}/libs/openFrameworksCompiled/lib/android)
21-
2218
set(PRJ_OFX_ANDROID_PATH ${PRJ_ADDONS_PATH}/ofxAndroid)
2319
set(PRJ_OFX_ANDROID_CPP_PATH ${PRJ_OFX_ANDROID_PATH}/src)
2420

@@ -47,31 +43,30 @@ function(check_library)
4743
endif ()
4844
endfunction()
4945

50-
set(CMAKE_CXX_STANDARD 17)
46+
set(CMAKE_C_STANDARD 17)
47+
set(CMAKE_CXX_STANDARD 23)
5148
set(CMAKE_CXX_STANDARD_REQUIRED ON)
52-
set(CMAKE_CXX_EXTENSIONS ON)
49+
set(CMAKE_CXX_EXTENSIONS OFF)
5350
set(TARGET_ANDROID ON)
54-
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c17 -Oz -DNDEBUG -frtti --warn-uninitialized -fno-short-enums -Wextra -fPIE -fPIC -fuse-ld=gold -fexceptions -ffunction-sections -fdata-sections -Wall -Wextra -Wfloat-equal -Wundef -Werror -fverbose-asm -Wint-to-pointer-cast -Wshadow -Wpointer-arith -Wcast-align -Wstrict-prototypes -Wcast-qual -Wmissing-prototypes -Wstrict-overflow=5 -Wwrite-strings -Wconversion --pedantic-errors")
55-
set(CMAKE_CPP_FLAGS "${CMAKE_C_FLAGS} -std=c++17 -Oz -DNDEBUG -stdlib=libc++ --warn-uninitialized -frtti -Wextra -fno-short-enums -fPIE -fPIC -fuse-ld=gold -fexceptions -ffunction-sections -fdata-sections -Wall -Wextra -Wfloat-equal -Wundef -Werror -fverbose-asm -Wint-to-pointer-cast -Wshadow -Wpointer-arith -Wcast-align -Wstrict-prototypes -Wcast-qual -Wmissing-prototypes -Wstrict-overflow=5 -Wwrite-strings -Wconversion --pedantic-errors")
51+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -ferror-limit=0 -std=c17 -Oz -Wall -fno-short-enums -fPIE -fPIC -fexceptions -ffunction-sections -fdata-sections")
52+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ferror-limit=0 -std=c++23 -Oz -stdlib=libc++ -Wall -fno-short-enums -fPIE -fPIC -fexceptions -ffunction-sections -fdata-sections")
5653
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-export-dynamic")
57-
5854
print_all_variables()
59-
60-
# Creates the project's shared lib: libnative-lib.so.
61-
# The lib is loaded by this project's Java code in MainActivity.java:
62-
# System.loadLibrary("native-lib");
63-
# The lib name in both places must match.
64-
add_library( ofapp #name
65-
SHARED # type of library
55+
set(OF_LIBRARY_TYPE "SHARED") # or "STATIC"
56+
if(OF_LIBRARY_TYPE STREQUAL "SHARED")
57+
set(LIB_EXTENSION ".so")
58+
elseif(OF_LIBRARY_TYPE STREQUAL "STATIC")
59+
set(LIB_EXTENSION ".a")
60+
endif()
61+
62+
add_library( ofApp
63+
${OF_LIBRARY_TYPE}
6664
# src files for project (just c/cpp)
6765
${CMAKE_SOURCE_DIR}/main.cpp
6866
${CMAKE_SOURCE_DIR}/ofApp.cpp
69-
)
70-
67+
)
7168

72-
# Specifies a path to native header files
7369
include_directories(
74-
# openFrameworks headers
7570
${PRJ_SOURCE_PATH}/3d
7671
${PRJ_SOURCE_PATH}/app
7772
${PRJ_SOURCE_PATH}/communication
@@ -84,59 +79,54 @@ include_directories(
8479
${PRJ_SOURCE_PATH}/utils
8580
${PRJ_SOURCE_PATH}/video
8681
${PRJ_SOURCE_PATH}
87-
# openFrameworks addons includes
82+
${PRJ_OFX_ANDROID_CPP_PATH}/
8883
${PURE_OF_ROOT}/addons/ofxAndroid/src
8984
${PURE_OF_ROOT}/addons/ofxAccelerometer/src
90-
${PURE_OF_ROOT}/addons/ofxXmlSettings/src
91-
${PURE_OF_ROOT}/addons/ofxXmlSettings/libs
92-
# openFrameworks Libs includes
9385
${PRJ_LIBS_ROOT}/FreeImage/include
9486
${PRJ_LIBS_ROOT}/freetype/include
9587
${PRJ_LIBS_ROOT}/freetype/include/freetype2
9688
${PRJ_LIBS_ROOT}/freetype/include/freetype2/freetype/config
9789
${PRJ_LIBS_ROOT}/freetype/include/freetype2/freetype/internal
9890
${PRJ_LIBS_ROOT}/freetype/include/freetype2/freetype/internal/services
9991
${PRJ_LIBS_ROOT}/glm/include
92+
${PRJ_LIBS_ROOT}/brotli/include
93+
${PRJ_LIBS_ROOT}/json/include
94+
${PRJ_LIBS_ROOT}/libpng/include
95+
${PRJ_LIBS_ROOT}/fmt/include
10096
${PRJ_LIBS_ROOT}/pugixml/include
10197
${PRJ_LIBS_ROOT}/json/include
10298
${PRJ_LIBS_ROOT}/tess2/include
10399
${PRJ_LIBS_ROOT}/utf8/include
100+
${PRJ_LIBS_ROOT}/tess2/include
101+
${PRJ_LIBS_ROOT}/zlib/include
104102
${PRJ_LIBS_ROOT}/uriparser/include
103+
${PRJ_LIBS_ROOT}/openssl/include
104+
${PRJ_LIBS_ROOT}/curl/include
105105
${CMAKE_SOURCE_DIR}/
106106
${CMAKE_SOURCE_DIR}/
107107
${OF_ANDROID}
108108
)
109109

110-
find_library(android-lib android)
111-
find_library(log-lib log)
112-
find_library(GLES2-lib GLESv2)
113-
114-
#find_library(GLES1-lib GLESv1_CM)
115-
#find_library(GLES3-lib GLESv3)
116-
110+
find_library(ANDROID_LIB NAMES android)
111+
find_library(LOG_LIB NAMES log)
112+
find_library(GLES1_LIB NAMES GLESv1_CM)
113+
find_library(GLES2_LIB NAMES GLESv2)
114+
find_library(GLES3_LIB NAMES GLESv3)
117115

118-
target_link_libraries(ofapp
119-
EGL
120-
GLESv2
116+
target_link_libraries(ofApp
117+
android
121118
log
122-
c
123119
m
124120
z
125121
dl
126-
# GLESv3
127-
)
128-
129-
target_link_libraries( ofapp
130-
${android-lib} )
131-
target_link_libraries( ofapp
132-
${GLES2-lib} )
133-
target_link_libraries( ofapp
134-
${log-lib} )
135-
#target_link_libraries( ofApp
136-
# ${GLES3-lib} )
137-
#target_link_libraries( ofApp
138-
# ${GLES1-lib} )
122+
)
123+
target_link_libraries(ofApp
124+
${ANDROID_LIB}
125+
${GLES2_LIB}
126+
${GLES3_LIB}
127+
${GLES1_LIB}
128+
${LOG_LIB}
129+
)
139130

140-
# Finally link in openFrameworks Library for each ABI
141-
target_link_libraries( ofapp
142-
${OF_ANDROID_OUTPUT}/${ANDROID_ABI}/libopenFrameworksAndroid.so)
131+
target_link_libraries( ofApp
132+
${OF_ANDROID_OUTPUT}/${ANDROID_ABI}/libopenFrameworksAndroid${LIB_EXTENSION})

scripts/templates/android2024/ofApp/src/main/java/cc/openframeworks/android/OFActivity.java

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,27 +22,25 @@
2222

2323
public class OFActivity extends cc.openframeworks.OFActivity {
2424

25-
private static final String appName = "ofapp"; // modify this to target appName (ofApp etc)
25+
private static final String appName = "ofApp"; // modify this to target appName (ofApp etc)
2626
private static final String LOG_TAG = appName + "::OFActivity";
2727

28-
private ReLinker.Logger logcatLogger = new ReLinker.Logger() {
29-
@Override
30-
public void log(String message) {
31-
Log.d("ReLinker", message);
32-
}
33-
};
34-
private OFActivity thisActivity;
35-
3628

37-
// Extremely important
29+
// Extremely important
3830
public OFActivity() {
3931
OFAndroidLifeCycle.coreLibraryLoaded = true;
4032

4133
OFAndroid.maxSamples = 4;
4234
OFAndroid.maximumFrameRate = 144;
4335

44-
thisActivity = this;
45-
ReLinker.log(logcatLogger)
36+
OFActivity thisActivity = this;
37+
ReLinker.Logger logcatLogger = new ReLinker.Logger() {
38+
@Override
39+
public void log(String message) {
40+
Log.d("ReLinker", message);
41+
}
42+
};
43+
ReLinker.log(logcatLogger)
4644
.force()
4745
.recursively()
4846
.loadLibrary(this, appName, new ReLinker.LoadListener() {

0 commit comments

Comments
 (0)