init
This commit is contained in:
41
scripts/android/files/AndroidManifest.xml
Normal file
41
scripts/android/files/AndroidManifest.xml
Normal file
@ -0,0 +1,41 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="tw.DDNet">
|
||||
<uses-feature
|
||||
android:glEsVersion="0x00030000" />
|
||||
|
||||
<!-- Teeworlds does broadcasts over local networks -->
|
||||
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
|
||||
<uses-permission android:name="android.permission.CHANGE_WIFI_MULTICAST_STATE"/>
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
|
||||
|
||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
|
||||
<!-- usesCleartextTraffic because unencrypted UDP packets -->
|
||||
<application
|
||||
android:usesCleartextTraffic="true"
|
||||
android:label="@string/app_name"
|
||||
android:hasCode="true"
|
||||
android:extractNativeLibs="true"
|
||||
android:supportsRtl="true"
|
||||
android:isGame="true"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
>
|
||||
<activity
|
||||
android:name=".NativeMain"
|
||||
android:configChanges="orientation|screenSize|screenLayout|keyboardHidden">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
<meta-data android:name="android.app.lib_name"
|
||||
android:value="DDNet" />
|
||||
</activity>
|
||||
</application>
|
||||
|
||||
</manifest>
|
80
scripts/android/files/build.gradle
Normal file
80
scripts/android/files/build.gradle
Normal file
@ -0,0 +1,80 @@
|
||||
apply plugin: 'com.android.application'
|
||||
|
||||
apply plugin: 'kotlin-android'
|
||||
|
||||
buildscript {
|
||||
ext.kotlin_version = '+'
|
||||
repositories {
|
||||
google()
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:7.2.1'
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||
}
|
||||
}
|
||||
|
||||
android {
|
||||
compileSdkVersion 30
|
||||
buildToolsVersion "30.0.3"
|
||||
ndkVersion "TW_NDK_VERSION"
|
||||
defaultConfig {
|
||||
applicationId "tw.DDNet"
|
||||
minSdkVersion 24
|
||||
targetSdkVersion 30
|
||||
versionCode TW_VERSION_CODE
|
||||
versionName "TW_VERSION_NAME"
|
||||
}
|
||||
signingConfigs {
|
||||
release {
|
||||
storeFile file("TW_KEY_NAME")
|
||||
storePassword "TW_KEY_PW"
|
||||
keyAlias "TW_KEY_ALIAS"
|
||||
keyPassword "TW_KEY_PW"
|
||||
}
|
||||
}
|
||||
buildTypes {
|
||||
release {
|
||||
signingConfig signingConfigs.release
|
||||
minifyEnabled true
|
||||
shrinkResources true
|
||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
debug {
|
||||
minifyEnabled false
|
||||
shrinkResources false
|
||||
}
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
main {
|
||||
assets.srcDirs = ['assets']
|
||||
jniLibs.srcDirs = ['lib']
|
||||
//TW_ENABLE_RESOURCESresources.srcDirs = ['resources']
|
||||
}
|
||||
}
|
||||
|
||||
lintOptions {
|
||||
abortOnError false
|
||||
}
|
||||
}
|
||||
|
||||
allprojects {
|
||||
repositories {
|
||||
google()
|
||||
mavenCentral()
|
||||
}
|
||||
gradle.projectsEvaluated {
|
||||
tasks.withType(JavaCompile) {
|
||||
options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
|
||||
implementation 'androidx.appcompat:appcompat:1.1.0'
|
||||
implementation 'androidx.core:core-ktx:1.3.0'
|
||||
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
|
||||
}
|
88
scripts/android/files/build.sh
Normal file
88
scripts/android/files/build.sh
Normal file
@ -0,0 +1,88 @@
|
||||
#!/bin/bash
|
||||
|
||||
[ "$1" == "" ] && {
|
||||
printf '\e[31mDid not pass ANDROID_SDK_ROOT to build script\e[30m\n'
|
||||
exit 1
|
||||
}
|
||||
|
||||
[ "$2" == "" ] && {
|
||||
printf '\e[31mDid not pass APK name to build script\e[30m\n'
|
||||
exit 1
|
||||
}
|
||||
|
||||
[ "$3" == "" ] && {
|
||||
printf '\e[31mDid not pass build type to build script\e[30m\n'
|
||||
exit 1
|
||||
}
|
||||
|
||||
_APK_BASENAME="$2"
|
||||
|
||||
sed -i "s/DDNet/${2}/g" settings.gradle
|
||||
|
||||
_REPLACE_PACKAGE_NAME_STR="tw.${2,,}"
|
||||
|
||||
sed -i "s/tw.DDNet/${_REPLACE_PACKAGE_NAME_STR}/g" build.gradle
|
||||
|
||||
TW_KEY_NAME_ESCAPED=$(echo "$TW_KEY_NAME"|sed 's/\//\\\//g')
|
||||
TW_KEY_PW_ESCAPED=$(echo "$TW_KEY_PW"|sed 's/\//\\\//g')
|
||||
TW_KEY_ALIAS_ESCAPED=$(echo "$TW_KEY_ALIAS"|sed 's/\//\\\//g')
|
||||
|
||||
sed -i "s/TW_KEY_NAME/${TW_KEY_NAME_ESCAPED}/g" build.gradle
|
||||
sed -i "s/TW_KEY_PW/${TW_KEY_PW_ESCAPED}/g" build.gradle
|
||||
sed -i "s/TW_KEY_ALIAS/${TW_KEY_ALIAS_ESCAPED}/g" build.gradle
|
||||
|
||||
sed -i "s/DDNet/${2}/g" src/main/res/values/strings.xml
|
||||
|
||||
sed -i "s/\"DDNet\"/\"${2}\"/g" src/main/AndroidManifest.xml
|
||||
sed -i "s/tw.DDNet/${_REPLACE_PACKAGE_NAME_STR}/g" src/main/AndroidManifest.xml
|
||||
|
||||
__TW_HOME_DIR=$(echo "$HOME"|sed 's/\//\\\//g')
|
||||
|
||||
sed -i "s/TW_HOME_DIR/${__TW_HOME_DIR}/g" local.properties
|
||||
sed -i "s/TW_NDK_VERSION/${ANDROID_NDK_VERSION}/g" build.gradle
|
||||
sed -i "s/TW_VERSION_CODE/${TW_VERSION_CODE}/g" build.gradle
|
||||
sed -i "s/TW_VERSION_NAME/${TW_VERSION_NAME}/g" build.gradle
|
||||
|
||||
mv src/main/java/tw/DDNet src/main/java/tw/"${2}"
|
||||
|
||||
sed -i "s/tw.DDNet/${_REPLACE_PACKAGE_NAME_STR}/g" src/main/java/tw/"${2}"/NativeMain.java
|
||||
sed -i "s/tw.DDNet/${_REPLACE_PACKAGE_NAME_STR}/g" proguard-rules.pro
|
||||
|
||||
# disable hid manager for now
|
||||
sed -i "s/mHIDDeviceManager = HIDDeviceManager.acquire(this);/mHIDDeviceManager=null;/g" src/main/java/org/libsdl/app/SDLActivity.java
|
||||
|
||||
if [[ "${3}" == "Debug" ]]; then
|
||||
sed -i "s/android.enableR8.fullMode=true/android.enableR8.fullMode=false/g" gradle.properties
|
||||
fi
|
||||
|
||||
if [[ -z ${GE_NO_APK_BUILD} || "${GE_NO_APK_BUILD}" != "1" ]]; then
|
||||
_RELEASE_TYPE_NAME=debug
|
||||
_RELEASE_TYPE_APK_NAME=
|
||||
if [[ "${3}" == "Debug" ]]; then
|
||||
_RELEASE_TYPE_NAME=debug
|
||||
fi
|
||||
|
||||
if [[ "${3}" == "Release" ]]; then
|
||||
_RELEASE_TYPE_NAME=release
|
||||
_RELEASE_TYPE_APK_NAME=
|
||||
fi
|
||||
|
||||
APP_BASE_NAME=Gradle
|
||||
CLASSPATH=gradle-wrapper.jar
|
||||
java "-Dorg.gradle.appname=${APP_BASE_NAME}" -classpath "${CLASSPATH}" org.gradle.wrapper.GradleWrapperMain --warning-mode all
|
||||
if [[ "${3}" == "Debug" ]]; then
|
||||
java "-Dorg.gradle.appname=${APP_BASE_NAME}" -classpath "${CLASSPATH}" org.gradle.wrapper.GradleWrapperMain --warning-mode all builddebug
|
||||
java "-Dorg.gradle.appname=${APP_BASE_NAME}" -classpath "${CLASSPATH}" org.gradle.wrapper.GradleWrapperMain --warning-mode all assembleDebug
|
||||
else
|
||||
java "-Dorg.gradle.appname=${APP_BASE_NAME}" -classpath "${CLASSPATH}" org.gradle.wrapper.GradleWrapperMain --warning-mode all buildrelease
|
||||
java "-Dorg.gradle.appname=${APP_BASE_NAME}" -classpath "${CLASSPATH}" org.gradle.wrapper.GradleWrapperMain --warning-mode all assembleRelease
|
||||
fi
|
||||
cp build/outputs/apk/"$_RELEASE_TYPE_NAME"/"$_APK_BASENAME"-"$_RELEASE_TYPE_NAME""$_RELEASE_TYPE_APK_NAME".apk "$_APK_BASENAME".apk
|
||||
|
||||
|
||||
if [[ "${3}" == "Release" ]]; then
|
||||
java "-Dorg.gradle.appname=${APP_BASE_NAME}" -classpath "${CLASSPATH}" org.gradle.wrapper.GradleWrapperMain --warning-mode all bundleRelease
|
||||
|
||||
cp build/outputs/bundle/"$_RELEASE_TYPE_NAME"/"$_APK_BASENAME"-"$_RELEASE_TYPE_NAME""$_RELEASE_TYPE_APK_NAME".aab "$_APK_BASENAME".aab
|
||||
fi
|
||||
fi
|
BIN
scripts/android/files/gradle-wrapper.jar
Normal file
BIN
scripts/android/files/gradle-wrapper.jar
Normal file
Binary file not shown.
5
scripts/android/files/gradle-wrapper.properties
Normal file
5
scripts/android/files/gradle-wrapper.properties
Normal file
@ -0,0 +1,5 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
22
scripts/android/files/gradle.properties
Normal file
22
scripts/android/files/gradle.properties
Normal file
@ -0,0 +1,22 @@
|
||||
# Project-wide Gradle settings.
|
||||
# IDE (e.g. Android Studio) users:
|
||||
# Gradle settings configured through the IDE *will override*
|
||||
# any settings specified in this file.
|
||||
# For more details on how to configure your build environment visit
|
||||
# http://www.gradle.org/docs/current/userguide/build_environment.html
|
||||
# Specifies the JVM arguments used for the daemon process.
|
||||
# The setting is particularly useful for tweaking memory settings.
|
||||
org.gradle.jvmargs=-Xmx3536m
|
||||
# When configured, Gradle will run in incubating parallel mode.
|
||||
# This option should only be used with decoupled projects. More details, visit
|
||||
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
|
||||
# org.gradle.parallel=true
|
||||
# AndroidX package structure to make it clearer which packages are bundled with the
|
||||
# Android operating system, and which are packaged with your app's APK
|
||||
# https://developer.android.com/topic/libraries/support-library/androidx-rn
|
||||
android.useAndroidX=true
|
||||
# Automatically convert third-party libraries to use AndroidX
|
||||
android.enableJetifier=true
|
||||
# Kotlin code style for this project: "official" or "obsolete":
|
||||
kotlin.code.style=official
|
||||
android.enableR8.fullMode=true
|
27
scripts/android/files/java/tw/DDNet/NativeMain.java
Normal file
27
scripts/android/files/java/tw/DDNet/NativeMain.java
Normal file
@ -0,0 +1,27 @@
|
||||
package tw.DDNet;
|
||||
import android.app.NativeActivity;
|
||||
import org.libsdl.app.SDLActivity;
|
||||
import android.os.Bundle;
|
||||
import android.content.pm.ActivityInfo;
|
||||
|
||||
public class NativeMain extends SDLActivity {
|
||||
static {
|
||||
System.loadLibrary("DDNet");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String[] getLibraries() {
|
||||
return new String[] {
|
||||
// disable hid API for now
|
||||
// "hidapi",
|
||||
// "SDL2",
|
||||
"DDNet",
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle SavedInstanceState) {
|
||||
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
|
||||
super.onCreate(SavedInstanceState);
|
||||
}
|
||||
}
|
10
scripts/android/files/local.properties
Normal file
10
scripts/android/files/local.properties
Normal file
@ -0,0 +1,10 @@
|
||||
## This file is automatically generated by Android Studio.
|
||||
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
|
||||
#
|
||||
# This file should *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.
|
||||
sdk.dir="TW_HOME_DIR/Android/Sdk"
|
35
scripts/android/files/proguard-rules.pro
vendored
Normal file
35
scripts/android/files/proguard-rules.pro
vendored
Normal file
@ -0,0 +1,35 @@
|
||||
# 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
|
||||
|
||||
# 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
|
||||
|
||||
-keepclassmembers, allowoptimization public class tw.DDNet.NativeMain {
|
||||
*;
|
||||
}
|
||||
|
||||
-keepclassmembers, allowoptimization public class org.libsdl.app.* {
|
||||
*;
|
||||
}
|
||||
|
||||
# If you keep the line number information, uncomment this to
|
||||
# hide the original source file name.
|
||||
#-renamesourcefileattribute SourceFile
|
||||
############################################
|
||||
## OUR
|
||||
############################################
|
||||
############################################
|
||||
## OTHER
|
||||
############################################
|
4
scripts/android/files/res/values/strings.xml
Normal file
4
scripts/android/files/res/values/strings.xml
Normal file
@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="app_name">DDNet</string>
|
||||
</resources>
|
1
scripts/android/files/settings.gradle
Normal file
1
scripts/android/files/settings.gradle
Normal file
@ -0,0 +1 @@
|
||||
rootProject.name='DDNet'
|
Reference in New Issue
Block a user