Skip to content

Commit

Permalink
Android 2024 template (#7991)
Browse files Browse the repository at this point in the history
  • Loading branch information
dimitre committed May 24, 2024
1 parent bfe8be8 commit 24d98aa
Show file tree
Hide file tree
Showing 47 changed files with 1,161 additions and 0 deletions.
22 changes: 22 additions & 0 deletions scripts/templates/android2024/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
ext {
//var = 'signExample.keystore'
}// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.4.2'
}
}

allprojects {
repositories {
google()
mavenCentral()
}
ext {

}
}
10 changes: 10 additions & 0 deletions scripts/templates/android2024/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
android.useAndroidX=true
android.enableJetifier=false
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
kotlin.code.style=official
android.prefabVersion=1.0.+
android.buildFeatures.prefab=true
#ndkBuild=false
# https://issuetracker.google.com/149575364
android.enableParallelJsonGen=false
#googleplay=true
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#Mon Jun 12 01:17:57 AEST 2023
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
8 changes: 8 additions & 0 deletions scripts/templates/android2024/local.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
## This file must *NOT* be checked into Version Control Systems,
# as it contains information specific to your local configuration.
#
# Location of the SDK. This is only used by Gradle.
# For customization when using a Version Control System, please read the
# header note.
#Wed May 08 13:54:16 CEST 2024
sdk.dir=/Users/thierry/Library/Android/sdk
182 changes: 182 additions & 0 deletions scripts/templates/android2024/ofApp/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
plugins {
id 'com.android.application'
}

def CMAKELIST_PATH = './src/main/cpp'
def CPP_SOURCE = './src/main/cpp'
def JAVA_SOURCE = './src/main/java'

// pointing to cmake's source code for the same project
def PRJ_SRC_ROOT = './src/main'
def ofRoot(){ return '../../../../' }
final ofSource = ofRoot() + 'libs/openFrameworks'
final ofLibs = ofRoot() + 'libs'
final addons = ofRoot() + 'addons'
final ofLibOutput = ofRoot() + 'libs/openFrameworksCompiled/lib/android'
def OFX_ANDROID = ofRoot() + 'addons/ofxAndroid'
//def OF_ADDONS_ARGUMENTS = "${OF_ADDONS}"
def enableProguardInReleaseBuilds = true
def enableProguardInDebugBuilds = false

task wrapper(type: Wrapper) {
gradleVersion = '7.3.3'
}
tasks.register("prepareKotlinBuildScriptModel"){
}

evaluationDependsOn(':openFrameworksProject')

tasks.whenTaskAdded { task ->
if (task.name == 'assemble') {
task.dependsOn(':openFrameworksProject:assemble')
}
}


android {
compileSdkVersion 34
buildToolsVersion '32.0.0'
//ndkPath "/Users/x/android-ndk-r21e" // Point to your own NDK if needed
ndkVersion '24.0.8215888' // use android studio side loaded ndk
buildFeatures {
prefab true
}
signingConfigs {
debug {
}
release {
storeFile new File("${System.properties['user.home']}/.android/debug.keystore")
storePassword 'android'
storeType "jks"
keyAlias 'androiddebugkey'
keyPassword 'android'
}
}
defaultConfig {
applicationId "cc.openframeworks.emptyExample" // IMPORTANT : THIS DEFINES THE ID OF THE APK
minSdkVersion 21
targetSdkVersion 34
versionCode 12
versionName '12.0'
ndk.abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86' //, 'x86_64'

externalNativeBuild {
if (!project.hasProperty("ndkBuild")) {
cmake {
arguments "-DANDROID_STL=c++_shared",
"-DANDROID_ARM_NEON=TRUE",
"-DANDROID_TOOLCHAIN=clang",
//"${OF_ADDONS_ARGUMENTS}",
"-DTARGET_OPENGLES=TRUE"

version '3.22.1'
}
}
}
multiDexEnabled false
}
buildTypes {
release {
signingConfig signingConfigs.release
jniDebuggable false
debuggable false
minifyEnabled false
shrinkResources false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
}
debug {
jniDebuggable true
debuggable true
minifyEnabled false
shrinkResources false
signingConfig signingConfigs.debug
}
}
flavorDimensions "version"
productFlavors {
playstore {
applicationIdSuffix ""
signingConfig signingConfigs.release
}
// humble {
// applicationIdSuffix ".humble"
// }
// amazon {
// applicationIdSuffix ".amazon"
// }
// samsung {
// applicationIdSuffix ".samsung"
// }
// oppo {
// applicationIdSuffix ".oppo"
// }
}
sourceSets {
main {
manifest.srcFile "${PRJ_SRC_ROOT}/AndroidManifest.xml"
java.srcDirs = ["${PRJ_SRC_ROOT}/java",
"${OFX_ANDROID}/Java"]
res.srcDirs = ["${PRJ_SRC_ROOT}/res"]
// jniLibs.srcDirs = ["${OF_ANDROID_OUTPUT}", "lib"] // Pre Android Studio 2022.2.1
assets {
srcDirs 'src/main/assets', 'src/main/bin/data'
}
}
}
externalNativeBuild {
if (!project.hasProperty("ndkBuild")) {
cmake {
path "${CMAKELIST_PATH}/CMakeLists.txt"
}
} else {
ndkBuild {
path "${CMAKELIST_PATH}/Android.mk"
}
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
androidResources {
noCompress ''
}
dependenciesInfo {
includeInApk false
includeInBundle false
}
// testOptions {
// devices {
// pixel2api29 (com.android.build.api.dsl.ManagedVirtualDevice) {
// // Use device profiles you typically see in
// // Android Studio
// device = "Pixel 2"
// apiLevel = 29
// // You can also specify "aosp" if you don’t require
// // Google Play Services.
// systemImageSource = "google"
// abi = "x86"
// }
// }
// }
}


dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation "com.getkeepsafe.relinker:relinker:1.4.5"
implementation 'com.google.android.material:material:1.9.0'
if (project.hasProperty("googleplay")) {
implementation "com.google.android.gms:play-services-games:22.0.1"
implementation "com.google.android.gms:play-services-auth:20.0.1"
implementation "com.google.android.gms:play-services-base:18.0.1"
implementation "com.google.android.gms:play-services-basement:18.0.0"
implementation "com.google.android.gms:play-services-instantapps:18.0.1"
implementation "com.google.android.gms:play-services-appset:16.0.2"
}
}

11 changes: 11 additions & 0 deletions scripts/templates/android2024/ofApp/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
android.useAndroidX=true
android.enableJetifier=true
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
kotlin.code.style=official
android.prefabVersion=1.0.+
# Workaround bug in AGP where the prefab dependency is being resolved from a
# non-Gradle thread when enableParallelJsonGen is enabled.
# https://issuetracker.google.com/149575364
android.enableParallelJsonGen=false
android.buildFeatures.prefab = true
vectorDrawables.useSupportLibrary = true
127 changes: 127 additions & 0 deletions scripts/templates/android2024/ofApp/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

-dontoptimize
-dontshrink
#-dontusemixedcaseclassnames
#-dontskipnonpubliclibraryclasses
#-dontpreverify
#-verbose
#
-optimizationpasses 7 # use for final build
-dontusemixedcaseclassnames
#-dontskipnonpubliclibraryclasses
#-dontpreverify
-verbose

# custom app activity proguard
-keep public class cc.openframeworks.android.OFActivity { public <methods>; }
-keep public class cc.openframeworks.android.R { public <methods>; }


#-dontobfuscate android classes
-keep public class * extends android.app.Activity
-keep public class * extends android.app.Application
-keep public class * extends android.app.Service
-keep public class * extends android.content.BroadcastReceiver
-keep public class * extends android.content.ContentProvider
-keep public class * extends android.app.backup.BackupAgentHelper
-keep public class * extends android.preference.Preference

#-dontobfuscate openFrameworks android classes
-keep public class cc.openframeworks.OFAndroid { public <methods>; }
-keep public class cc.openframeworks.OFAndroidLifeCycleHelper { public <methods>; }
-keep public class cc.openframeworks.OFAndroidWindow { public <methods>; }
-keep public class cc.openframeworks.OFAndroidSoundPlayer { public <methods>; }
-keep public class cc.openframeworks.OFGLSurfaceView { public <methods>; }
-keep public class cc.openframeworks.OFAndroidLifeCycle { public <methods>; }
-keep public class cc.openframeworks.OFActivity { public <methods>; }
-keep public class cc.openframeworks.ContextFactory { public <methods>; }
-keep public class cc.openframeworks.OFEGLConfigChooser { public <methods>; }
-keep public class cc.openframeworks.OFGestureListener { public <methods>; }
-keep public class cc.openframeworks.OFAndroidController { public <methods>; }

#-dontobfuscate GooglePlay Games android classes if used
-keep class com.google.android.gms.games.leaderboard.** { *; }
-keep class com.google.android.gms.games.snapshot.** { *; }
-keep class com.google.android.gms.games.achievement.** { *; }
-keep class com.google.android.gms.games.event.** { *; }
-keep class com.google.android.gms.games.stats.** { *; }
-keep class com.google.android.gms.games.video.** { *; }
-keep class com.google.android.gms.games.* { *; }
-keep class com.google.android.gms.signin.** { *; }
-keep class com.google.android.gms.dynamic.** { *; }
-keep class com.google.android.gms.dynamite.** { *; }
-keep class com.google.android.gms.tasks.** { *; }
-keep class com.google.android.gms.security.** { *; }
-keep class com.google.android.gms.base.** { *; }
-keep class com.google.android.gms.actions.** { *; }
-keep class com.google.games.bridge.** { *; }
-keep class com.google.android.gms.common.api.** { *; }
-keep class com.google.android.gms.games.quest.** { *; }
-keep class com.google.android.gms.nearby.** { *; }

-keepclasseswithmembernames class * {
native <methods>;
}

-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet);
}

-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet, int);
}

# note that <methods> means any method
-keepclasseswithmembernames,includedescriptorclasses class * {
native <methods>;
}

-keepclassmembers class * extends android.app.Activity {
public void *(android.view.View);
}

-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}

-keep class * implements android.os.Parcelable {
public static final android.os.Parcelable$Creator *;
}


# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
Loading

0 comments on commit 24d98aa

Please sign in to comment.