From c5ee68a647871ca7bc8044a96759e7c00f9188db Mon Sep 17 00:00:00 2001 From: ilotterytea Date: Tue, 8 Oct 2024 01:54:47 +0500 Subject: feat: Android support (again) --- android/AndroidManifest.xml | 29 +++++++ android/build.gradle | 89 +++++++++++++++++++++ android/ic_launcher-web.png | Bin 0 -> 22195 bytes android/proguard-rules.pro | 43 ++++++++++ android/project.properties | 9 +++ android/res/drawable-anydpi-v26/ic_launcher.xml | 6 ++ .../drawable-anydpi-v26/ic_launcher_foreground.xml | 40 +++++++++ android/res/drawable-hdpi/ic_launcher.png | Bin 0 -> 16820 bytes android/res/drawable-mdpi/ic_launcher.png | Bin 0 -> 16124 bytes android/res/drawable-xhdpi/ic_launcher.png | Bin 0 -> 17915 bytes android/res/drawable-xxhdpi/ic_launcher.png | Bin 0 -> 18746 bytes android/res/drawable-xxxhdpi/ic_launcher.png | Bin 0 -> 19448 bytes android/res/values-v21/styles.xml | 6 ++ android/res/values/color.xml | 4 + android/res/values/strings.xml | 6 ++ android/res/values/styles.xml | 6 ++ .../java/kz/ilotterytea/maxon/AndroidLauncher.java | 15 ++++ 17 files changed, 253 insertions(+) create mode 100644 android/AndroidManifest.xml create mode 100644 android/build.gradle create mode 100644 android/ic_launcher-web.png create mode 100644 android/proguard-rules.pro create mode 100644 android/project.properties create mode 100644 android/res/drawable-anydpi-v26/ic_launcher.xml create mode 100644 android/res/drawable-anydpi-v26/ic_launcher_foreground.xml create mode 100644 android/res/drawable-hdpi/ic_launcher.png create mode 100644 android/res/drawable-mdpi/ic_launcher.png create mode 100644 android/res/drawable-xhdpi/ic_launcher.png create mode 100644 android/res/drawable-xxhdpi/ic_launcher.png create mode 100644 android/res/drawable-xxxhdpi/ic_launcher.png create mode 100644 android/res/values-v21/styles.xml create mode 100644 android/res/values/color.xml create mode 100644 android/res/values/strings.xml create mode 100644 android/res/values/styles.xml create mode 100644 android/src/main/java/kz/ilotterytea/maxon/AndroidLauncher.java (limited to 'android') diff --git a/android/AndroidManifest.xml b/android/AndroidManifest.xml new file mode 100644 index 0000000..352f4c1 --- /dev/null +++ b/android/AndroidManifest.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + diff --git a/android/build.gradle b/android/build.gradle new file mode 100644 index 0000000..1b3a289 --- /dev/null +++ b/android/build.gradle @@ -0,0 +1,89 @@ +android { + namespace "kz.ilotterytea.maxon" + buildToolsVersion "35.0.0" + compileSdkVersion 35 + sourceSets { + main { + manifest.srcFile 'AndroidManifest.xml' + java.srcDirs = ['src'] + aidl.srcDirs = ['src'] + renderscript.srcDirs = ['src'] + res.srcDirs = ['res'] + assets.srcDirs = ['../assets'] + jniLibs.srcDirs = ['libs'] + } + + } + packagingOptions { + exclude 'META-INF/robovm/ios/robovm.xml' + } + defaultConfig { + applicationId "kz.ilotterytea.maxon" + minSdkVersion 19 + targetSdkVersion 35 + versionCode 1 + versionName "1.0" + } + buildTypes { + release { + minifyEnabled true + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } +} + + +// called every time gradle gets executed, takes the native dependencies of +// the natives configuration, and extracts them to the proper libs/ folders +// so they get packed with the APK. +tasks.register('copyAndroidNatives') { + doFirst { + file("libs/armeabi-v7a/").mkdirs() + file("libs/arm64-v8a/").mkdirs() + file("libs/x86_64/").mkdirs() + file("libs/x86/").mkdirs() + + configurations.natives.copy().files.each { jar -> + def outputDir = null + if (jar.name.endsWith("natives-arm64-v8a.jar")) outputDir = file("libs/arm64-v8a") + if (jar.name.endsWith("natives-armeabi-v7a.jar")) outputDir = file("libs/armeabi-v7a") + if (jar.name.endsWith("natives-x86_64.jar")) outputDir = file("libs/x86_64") + if (jar.name.endsWith("natives-x86.jar")) outputDir = file("libs/x86") + if (outputDir != null) { + copy { + from zipTree(jar) + into outputDir + include "*.so" + } + } + } + } +} + +tasks.matching { it.name.contains("merge") && it.name.contains("JniLibFolders") }.configureEach { packageTask -> + packageTask.dependsOn 'copyAndroidNatives' +} + +tasks.register('run', Exec) { + def path + def localProperties = project.file("../local.properties") + if (localProperties.exists()) { + Properties properties = new Properties() + localProperties.withInputStream { instr -> + properties.load(instr) + } + def sdkDir = properties.getProperty('sdk.dir') + if (sdkDir) { + path = sdkDir + } else { + path = "$System.env.ANDROID_HOME" + } + } else { + path = "$System.env.ANDROID_HOME" + } + + def adb = path + "/platform-tools/adb" + commandLine "$adb", 'shell', 'am', 'start', '-n', 'kz.ilotterytea.maxon/kz.ilotterytea.maxon.AndroidLauncher' +} + +eclipse.project.name = appName + "-android" diff --git a/android/ic_launcher-web.png b/android/ic_launcher-web.png new file mode 100644 index 0000000..8f0110d Binary files /dev/null and b/android/ic_launcher-web.png differ diff --git a/android/proguard-rules.pro b/android/proguard-rules.pro new file mode 100644 index 0000000..bd5dddb --- /dev/null +++ b/android/proguard-rules.pro @@ -0,0 +1,43 @@ +# To enable ProGuard in your project, edit project.properties +# to define the proguard.config property as described in that file. +# +# Add project specific ProGuard rules here. +# By default, the flags in this file are appended to flags specified +# in ${sdk.dir}/tools/proguard/proguard-android.txt +# You can edit the include path and order by changing the ProGuard +# include property in project.properties. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# Add any project specific keep options here: + +# 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 *; +#} + +-verbose + +-dontwarn com.badlogic.gdx.backends.android.AndroidFragmentApplication + +# Required if using libGDX Scene2d Skins (JSON Skin descriptors) +-keep public class com.badlogic.gdx.scenes.scene2d.** { *; } +-keep public class com.badlogic.gdx.graphics.g2d.BitmapFont { *; } +-keep public class com.badlogic.gdx.graphics.Color { *; } + +# Required if using Gdx-Controllers extension +# -keep class com.badlogic.gdx.controllers.android.AndroidControllers + +# Required if using Box2D extension +-keepclassmembers class com.badlogic.gdx.physics.box2d.World { + boolean contactFilter(long, long); + void beginContact(long); + void endContact(long); + void preSolve(long, long); + void postSolve(long, long); + boolean reportFixture(long); + float reportRayFixture(long, float, float, float, float, float); +} diff --git a/android/project.properties b/android/project.properties new file mode 100644 index 0000000..3fefa92 --- /dev/null +++ b/android/project.properties @@ -0,0 +1,9 @@ +# This file is used by the Eclipse ADT plugin. It is unnecessary for IDEA and Android Studio projects, which +# configure Proguard and the Android target via the build.gradle file. + +# To enable ProGuard to work with Eclipse ADT, uncomment this (available properties: sdk.dir, user.home) +# and ensure proguard.jar in the Android SDK is up to date (or alternately reduce the android target to 23 or lower): +# proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-rules.pro + +# Project target. +target=android-19 diff --git a/android/res/drawable-anydpi-v26/ic_launcher.xml b/android/res/drawable-anydpi-v26/ic_launcher.xml new file mode 100644 index 0000000..6c7313a --- /dev/null +++ b/android/res/drawable-anydpi-v26/ic_launcher.xml @@ -0,0 +1,6 @@ + + + + + diff --git a/android/res/drawable-anydpi-v26/ic_launcher_foreground.xml b/android/res/drawable-anydpi-v26/ic_launcher_foreground.xml new file mode 100644 index 0000000..5916ee8 --- /dev/null +++ b/android/res/drawable-anydpi-v26/ic_launcher_foreground.xml @@ -0,0 +1,40 @@ + + + + + + + + + diff --git a/android/res/drawable-hdpi/ic_launcher.png b/android/res/drawable-hdpi/ic_launcher.png new file mode 100644 index 0000000..91f696b Binary files /dev/null and b/android/res/drawable-hdpi/ic_launcher.png differ diff --git a/android/res/drawable-mdpi/ic_launcher.png b/android/res/drawable-mdpi/ic_launcher.png new file mode 100644 index 0000000..c1ab239 Binary files /dev/null and b/android/res/drawable-mdpi/ic_launcher.png differ diff --git a/android/res/drawable-xhdpi/ic_launcher.png b/android/res/drawable-xhdpi/ic_launcher.png new file mode 100644 index 0000000..2011cc0 Binary files /dev/null and b/android/res/drawable-xhdpi/ic_launcher.png differ diff --git a/android/res/drawable-xxhdpi/ic_launcher.png b/android/res/drawable-xxhdpi/ic_launcher.png new file mode 100644 index 0000000..25fcef0 Binary files /dev/null and b/android/res/drawable-xxhdpi/ic_launcher.png differ diff --git a/android/res/drawable-xxxhdpi/ic_launcher.png b/android/res/drawable-xxxhdpi/ic_launcher.png new file mode 100644 index 0000000..d109946 Binary files /dev/null and b/android/res/drawable-xxxhdpi/ic_launcher.png differ diff --git a/android/res/values-v21/styles.xml b/android/res/values-v21/styles.xml new file mode 100644 index 0000000..fcc6217 --- /dev/null +++ b/android/res/values-v21/styles.xml @@ -0,0 +1,6 @@ + + + + diff --git a/android/res/values/color.xml b/android/res/values/color.xml new file mode 100644 index 0000000..933353e --- /dev/null +++ b/android/res/values/color.xml @@ -0,0 +1,4 @@ + + + #FFFFFFFF + diff --git a/android/res/values/strings.xml b/android/res/values/strings.xml new file mode 100644 index 0000000..cbe6c20 --- /dev/null +++ b/android/res/values/strings.xml @@ -0,0 +1,6 @@ + + + + Maxon Petting Simulator + + diff --git a/android/res/values/styles.xml b/android/res/values/styles.xml new file mode 100644 index 0000000..77377af --- /dev/null +++ b/android/res/values/styles.xml @@ -0,0 +1,6 @@ + + + + diff --git a/android/src/main/java/kz/ilotterytea/maxon/AndroidLauncher.java b/android/src/main/java/kz/ilotterytea/maxon/AndroidLauncher.java new file mode 100644 index 0000000..94f678e --- /dev/null +++ b/android/src/main/java/kz/ilotterytea/maxon/AndroidLauncher.java @@ -0,0 +1,15 @@ +package kz.ilotterytea.maxon; + +import android.os.Bundle; + +import com.badlogic.gdx.backends.android.AndroidApplication; +import com.badlogic.gdx.backends.android.AndroidApplicationConfiguration; + +public class AndroidLauncher extends AndroidApplication { + @Override + protected void onCreate (Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + AndroidApplicationConfiguration config = new AndroidApplicationConfiguration(); + initialize(MaxonGame.getInstance(), config); + } +} -- cgit v1.2.3