Skip to content

Commit 24d98aa

Browse files
authored
Android 2024 template (#7991)
1 parent bfe8be8 commit 24d98aa

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+1161
-0
lines changed
+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
ext {
2+
//var = 'signExample.keystore'
3+
}// Top-level build file where you can add configuration options common to all sub-projects/modules.
4+
buildscript {
5+
repositories {
6+
google()
7+
mavenCentral()
8+
}
9+
dependencies {
10+
classpath 'com.android.tools.build:gradle:7.4.2'
11+
}
12+
}
13+
14+
allprojects {
15+
repositories {
16+
google()
17+
mavenCentral()
18+
}
19+
ext {
20+
21+
}
22+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
android.useAndroidX=true
2+
android.enableJetifier=false
3+
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
4+
kotlin.code.style=official
5+
android.prefabVersion=1.0.+
6+
android.buildFeatures.prefab=true
7+
#ndkBuild=false
8+
# https://issuetracker.google.com/149575364
9+
android.enableParallelJsonGen=false
10+
#googleplay=true
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#Mon Jun 12 01:17:57 AEST 2023
2+
distributionBase=GRADLE_USER_HOME
3+
distributionPath=wrapper/dists
4+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
5+
zipStoreBase=GRADLE_USER_HOME
6+
zipStorePath=wrapper/dists
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
## This file must *NOT* be checked into Version Control Systems,
2+
# as it contains information specific to your local configuration.
3+
#
4+
# Location of the SDK. This is only used by Gradle.
5+
# For customization when using a Version Control System, please read the
6+
# header note.
7+
#Wed May 08 13:54:16 CEST 2024
8+
sdk.dir=/Users/thierry/Library/Android/sdk
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,182 @@
1+
plugins {
2+
id 'com.android.application'
3+
}
4+
5+
def CMAKELIST_PATH = './src/main/cpp'
6+
def CPP_SOURCE = './src/main/cpp'
7+
def JAVA_SOURCE = './src/main/java'
8+
9+
// pointing to cmake's source code for the same project
10+
def PRJ_SRC_ROOT = './src/main'
11+
def ofRoot(){ return '../../../../' }
12+
final ofSource = ofRoot() + 'libs/openFrameworks'
13+
final ofLibs = ofRoot() + 'libs'
14+
final addons = ofRoot() + 'addons'
15+
final ofLibOutput = ofRoot() + 'libs/openFrameworksCompiled/lib/android'
16+
def OFX_ANDROID = ofRoot() + 'addons/ofxAndroid'
17+
//def OF_ADDONS_ARGUMENTS = "${OF_ADDONS}"
18+
def enableProguardInReleaseBuilds = true
19+
def enableProguardInDebugBuilds = false
20+
21+
task wrapper(type: Wrapper) {
22+
gradleVersion = '7.3.3'
23+
}
24+
tasks.register("prepareKotlinBuildScriptModel"){
25+
}
26+
27+
evaluationDependsOn(':openFrameworksProject')
28+
29+
tasks.whenTaskAdded { task ->
30+
if (task.name == 'assemble') {
31+
task.dependsOn(':openFrameworksProject:assemble')
32+
}
33+
}
34+
35+
36+
android {
37+
compileSdkVersion 34
38+
buildToolsVersion '32.0.0'
39+
//ndkPath "/Users/x/android-ndk-r21e" // Point to your own NDK if needed
40+
ndkVersion '24.0.8215888' // use android studio side loaded ndk
41+
buildFeatures {
42+
prefab true
43+
}
44+
signingConfigs {
45+
debug {
46+
}
47+
release {
48+
storeFile new File("${System.properties['user.home']}/.android/debug.keystore")
49+
storePassword 'android'
50+
storeType "jks"
51+
keyAlias 'androiddebugkey'
52+
keyPassword 'android'
53+
}
54+
}
55+
defaultConfig {
56+
applicationId "cc.openframeworks.emptyExample" // IMPORTANT : THIS DEFINES THE ID OF THE APK
57+
minSdkVersion 21
58+
targetSdkVersion 34
59+
versionCode 12
60+
versionName '12.0'
61+
ndk.abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86' //, 'x86_64'
62+
63+
externalNativeBuild {
64+
if (!project.hasProperty("ndkBuild")) {
65+
cmake {
66+
arguments "-DANDROID_STL=c++_shared",
67+
"-DANDROID_ARM_NEON=TRUE",
68+
"-DANDROID_TOOLCHAIN=clang",
69+
//"${OF_ADDONS_ARGUMENTS}",
70+
"-DTARGET_OPENGLES=TRUE"
71+
72+
version '3.22.1'
73+
}
74+
}
75+
}
76+
multiDexEnabled false
77+
}
78+
buildTypes {
79+
release {
80+
signingConfig signingConfigs.release
81+
jniDebuggable false
82+
debuggable false
83+
minifyEnabled false
84+
shrinkResources false
85+
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
86+
signingConfig signingConfigs.release
87+
}
88+
debug {
89+
jniDebuggable true
90+
debuggable true
91+
minifyEnabled false
92+
shrinkResources false
93+
signingConfig signingConfigs.debug
94+
}
95+
}
96+
flavorDimensions "version"
97+
productFlavors {
98+
playstore {
99+
applicationIdSuffix ""
100+
signingConfig signingConfigs.release
101+
}
102+
// humble {
103+
// applicationIdSuffix ".humble"
104+
// }
105+
// amazon {
106+
// applicationIdSuffix ".amazon"
107+
// }
108+
// samsung {
109+
// applicationIdSuffix ".samsung"
110+
// }
111+
// oppo {
112+
// applicationIdSuffix ".oppo"
113+
// }
114+
}
115+
sourceSets {
116+
main {
117+
manifest.srcFile "${PRJ_SRC_ROOT}/AndroidManifest.xml"
118+
java.srcDirs = ["${PRJ_SRC_ROOT}/java",
119+
"${OFX_ANDROID}/Java"]
120+
res.srcDirs = ["${PRJ_SRC_ROOT}/res"]
121+
// jniLibs.srcDirs = ["${OF_ANDROID_OUTPUT}", "lib"] // Pre Android Studio 2022.2.1
122+
assets {
123+
srcDirs 'src/main/assets', 'src/main/bin/data'
124+
}
125+
}
126+
}
127+
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+
}
137+
}
138+
compileOptions {
139+
sourceCompatibility JavaVersion.VERSION_1_8
140+
targetCompatibility JavaVersion.VERSION_1_8
141+
}
142+
androidResources {
143+
noCompress ''
144+
}
145+
dependenciesInfo {
146+
includeInApk false
147+
includeInBundle false
148+
}
149+
// testOptions {
150+
// devices {
151+
// pixel2api29 (com.android.build.api.dsl.ManagedVirtualDevice) {
152+
// // Use device profiles you typically see in
153+
// // Android Studio
154+
// device = "Pixel 2"
155+
// apiLevel = 29
156+
// // You can also specify "aosp" if you don’t require
157+
// // Google Play Services.
158+
// systemImageSource = "google"
159+
// abi = "x86"
160+
// }
161+
// }
162+
// }
163+
}
164+
165+
166+
dependencies {
167+
implementation fileTree(dir: 'libs', include: ['*.jar'])
168+
implementation 'androidx.appcompat:appcompat:1.6.1'
169+
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
170+
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
171+
implementation "com.getkeepsafe.relinker:relinker:1.4.5"
172+
implementation 'com.google.android.material:material:1.9.0'
173+
if (project.hasProperty("googleplay")) {
174+
implementation "com.google.android.gms:play-services-games:22.0.1"
175+
implementation "com.google.android.gms:play-services-auth:20.0.1"
176+
implementation "com.google.android.gms:play-services-base:18.0.1"
177+
implementation "com.google.android.gms:play-services-basement:18.0.0"
178+
implementation "com.google.android.gms:play-services-instantapps:18.0.1"
179+
implementation "com.google.android.gms:play-services-appset:16.0.2"
180+
}
181+
}
182+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
android.useAndroidX=true
2+
android.enableJetifier=true
3+
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
4+
kotlin.code.style=official
5+
android.prefabVersion=1.0.+
6+
# Workaround bug in AGP where the prefab dependency is being resolved from a
7+
# non-Gradle thread when enableParallelJsonGen is enabled.
8+
# https://issuetracker.google.com/149575364
9+
android.enableParallelJsonGen=false
10+
android.buildFeatures.prefab = true
11+
vectorDrawables.useSupportLibrary = true
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
# Add project specific ProGuard rules here.
2+
# You can control the set of applied configuration files using the
3+
# proguardFiles setting in build.gradle.
4+
#
5+
# For more details, see
6+
# http://developer.android.com/guide/developing/tools/proguard.html
7+
8+
-dontoptimize
9+
-dontshrink
10+
#-dontusemixedcaseclassnames
11+
#-dontskipnonpubliclibraryclasses
12+
#-dontpreverify
13+
#-verbose
14+
#
15+
-optimizationpasses 7 # use for final build
16+
-dontusemixedcaseclassnames
17+
#-dontskipnonpubliclibraryclasses
18+
#-dontpreverify
19+
-verbose
20+
21+
# custom app activity proguard
22+
-keep public class cc.openframeworks.android.OFActivity { public <methods>; }
23+
-keep public class cc.openframeworks.android.R { public <methods>; }
24+
25+
26+
#-dontobfuscate android classes
27+
-keep public class * extends android.app.Activity
28+
-keep public class * extends android.app.Application
29+
-keep public class * extends android.app.Service
30+
-keep public class * extends android.content.BroadcastReceiver
31+
-keep public class * extends android.content.ContentProvider
32+
-keep public class * extends android.app.backup.BackupAgentHelper
33+
-keep public class * extends android.preference.Preference
34+
35+
#-dontobfuscate openFrameworks android classes
36+
-keep public class cc.openframeworks.OFAndroid { public <methods>; }
37+
-keep public class cc.openframeworks.OFAndroidLifeCycleHelper { public <methods>; }
38+
-keep public class cc.openframeworks.OFAndroidWindow { public <methods>; }
39+
-keep public class cc.openframeworks.OFAndroidSoundPlayer { public <methods>; }
40+
-keep public class cc.openframeworks.OFGLSurfaceView { public <methods>; }
41+
-keep public class cc.openframeworks.OFAndroidLifeCycle { public <methods>; }
42+
-keep public class cc.openframeworks.OFActivity { public <methods>; }
43+
-keep public class cc.openframeworks.ContextFactory { public <methods>; }
44+
-keep public class cc.openframeworks.OFEGLConfigChooser { public <methods>; }
45+
-keep public class cc.openframeworks.OFGestureListener { public <methods>; }
46+
-keep public class cc.openframeworks.OFAndroidController { public <methods>; }
47+
48+
#-dontobfuscate GooglePlay Games android classes if used
49+
-keep class com.google.android.gms.games.leaderboard.** { *; }
50+
-keep class com.google.android.gms.games.snapshot.** { *; }
51+
-keep class com.google.android.gms.games.achievement.** { *; }
52+
-keep class com.google.android.gms.games.event.** { *; }
53+
-keep class com.google.android.gms.games.stats.** { *; }
54+
-keep class com.google.android.gms.games.video.** { *; }
55+
-keep class com.google.android.gms.games.* { *; }
56+
-keep class com.google.android.gms.signin.** { *; }
57+
-keep class com.google.android.gms.dynamic.** { *; }
58+
-keep class com.google.android.gms.dynamite.** { *; }
59+
-keep class com.google.android.gms.tasks.** { *; }
60+
-keep class com.google.android.gms.security.** { *; }
61+
-keep class com.google.android.gms.base.** { *; }
62+
-keep class com.google.android.gms.actions.** { *; }
63+
-keep class com.google.games.bridge.** { *; }
64+
-keep class com.google.android.gms.common.api.** { *; }
65+
-keep class com.google.android.gms.games.quest.** { *; }
66+
-keep class com.google.android.gms.nearby.** { *; }
67+
68+
-keepclasseswithmembernames class * {
69+
native <methods>;
70+
}
71+
72+
-keepclasseswithmembers class * {
73+
public <init>(android.content.Context, android.util.AttributeSet);
74+
}
75+
76+
-keepclasseswithmembers class * {
77+
public <init>(android.content.Context, android.util.AttributeSet, int);
78+
}
79+
80+
# note that <methods> means any method
81+
-keepclasseswithmembernames,includedescriptorclasses class * {
82+
native <methods>;
83+
}
84+
85+
-keepclassmembers class * extends android.app.Activity {
86+
public void *(android.view.View);
87+
}
88+
89+
-keepclassmembers enum * {
90+
public static **[] values();
91+
public static ** valueOf(java.lang.String);
92+
}
93+
94+
-keep class * implements android.os.Parcelable {
95+
public static final android.os.Parcelable$Creator *;
96+
}
97+
98+
99+
# If your project uses WebView with JS, uncomment the following
100+
# and specify the fully qualified class name to the JavaScript interface
101+
# class:
102+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
103+
# public *;
104+
#}
105+
106+
# Uncomment this to preserve the line number information for
107+
# debugging stack traces.
108+
#-keepattributes SourceFile,LineNumberTable
109+
110+
# If you keep the line number information, uncomment this to
111+
# hide the original source file name.
112+
#-renamesourcefileattribute SourceFile
113+
114+
# If your project uses WebView with JS, uncomment the following
115+
# and specify the fully qualified class name to the JavaScript interface
116+
# class:
117+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
118+
# public *;
119+
#}
120+
121+
# Uncomment this to preserve the line number information for
122+
# debugging stack traces.
123+
-keepattributes SourceFile,LineNumberTable
124+
125+
# If you keep the line number information, uncomment this to
126+
# hide the original source file name.
127+
#-renamesourcefileattribute SourceFile

0 commit comments

Comments
 (0)