Merge pull request #1500 from player-03/DeprecatedGradleFeatures

Fix warnings and errors in the Android build process
This commit is contained in:
player-03
2022-12-29 19:26:54 -05:00
committed by GitHub
10 changed files with 63 additions and 52 deletions

View File

@@ -215,7 +215,7 @@ jobs:
- uses: actions/setup-java@v1 - uses: actions/setup-java@v1
with: with:
java-version: 8 java-version: 11
- uses: krdlab/setup-haxe@v1 - uses: krdlab/setup-haxe@v1
with: with:
@@ -460,7 +460,7 @@ jobs:
- uses: actions/setup-java@v1 - uses: actions/setup-java@v1
with: with:
java-version: 8 java-version: 11
- uses: krdlab/setup-haxe@v1 - uses: krdlab/setup-haxe@v1
with: with:

View File

@@ -1,9 +1,9 @@
buildscript { buildscript {
repositories { repositories {
jcenter() mavenCentral()
google() google()
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:::ANDROID_GRADLE_PLUGIN::' classpath 'com.android.tools.build:gradle:::ANDROID_GRADLE_PLUGIN::'
} }
@@ -14,7 +14,7 @@ apply plugin: 'com.android.library'
android { android {
compileSdkVersion Integer.parseInt(project.ANDROID_BUILD_SDK_VERSION) compileSdkVersion Integer.parseInt(project.ANDROID_BUILD_SDK_VERSION)
buildToolsVersion project.ANDROID_BUILD_TOOLS_VERSION buildToolsVersion project.ANDROID_BUILD_TOOLS_VERSION
defaultConfig { defaultConfig {
minSdkVersion Integer.parseInt(project.ANDROID_BUILD_MIN_SDK_VERSION) minSdkVersion Integer.parseInt(project.ANDROID_BUILD_MIN_SDK_VERSION)
targetSdkVersion Integer.parseInt(project.ANDROID_BUILD_TARGET_SDK_VERSION) targetSdkVersion Integer.parseInt(project.ANDROID_BUILD_TARGET_SDK_VERSION)

View File

@@ -1,16 +1,22 @@
import groovy.swing.SwingBuilder import groovy.swing.SwingBuilder
import java.awt.GridBagLayout; import java.awt.GridBagLayout
import java.awt.GridBagConstraints; import java.awt.GridBagConstraints
import javax.swing.border.EmptyBorder; import javax.swing.border.EmptyBorder
apply plugin: 'com.android.application' apply plugin: 'com.android.application'
System.setProperty('java.awt.headless','false') System.setProperty('java.awt.headless','false')
//Uncomment to debug deprecation warnings.
/* tasks.withType(JavaCompile) {
options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"
} */
android { android {
compileSdkVersion Integer.parseInt(project.ANDROID_BUILD_SDK_VERSION) compileSdkVersion Integer.parseInt(project.ANDROID_BUILD_SDK_VERSION)
buildToolsVersion project.ANDROID_BUILD_TOOLS_VERSION buildToolsVersion project.ANDROID_BUILD_TOOLS_VERSION
::if (ANDROID_GRADLE_PLUGIN>="4.0")::ndkPath '::ANDROID_NDK_ROOT_ESCAPED::'::end::
defaultConfig { defaultConfig {
applicationId "::META_PACKAGE_NAME::" applicationId "::META_PACKAGE_NAME::"
minSdkVersion Integer.parseInt(project.ANDROID_BUILD_MIN_SDK_VERSION) minSdkVersion Integer.parseInt(project.ANDROID_BUILD_MIN_SDK_VERSION)
@@ -19,7 +25,7 @@ android {
versionName project.VERSION_NAME versionName project.VERSION_NAME
::if (languages != null)::resConfigs ::foreach languages::"::__current__::", ::end::""::end:: ::if (languages != null)::resConfigs ::foreach languages::"::__current__::", ::end::""::end::
} }
::if KEY_STORE:: ::if KEY_STORE::
signingConfigs { signingConfigs {
if (project.KEY_STORE_PASSWORD == 'null') { if (project.KEY_STORE_PASSWORD == 'null') {
@@ -27,11 +33,11 @@ android {
keyStoreFile = keyStoreFile[keyStoreFile.length - 1] keyStoreFile = keyStoreFile[keyStoreFile.length - 1]
project.KEY_STORE_PASSWORD = getPassword('\nPlease enter key password for ' + keyStoreFile + ':'); project.KEY_STORE_PASSWORD = getPassword('\nPlease enter key password for ' + keyStoreFile + ':');
} }
if (project.KEY_STORE_ALIAS_PASSWORD == 'null') { if (project.KEY_STORE_ALIAS_PASSWORD == 'null') {
project.KEY_STORE_ALIAS_PASSWORD = getPassword("\nPlease enter key alias password for alias " + project.KEY_STORE_ALIAS + ":") project.KEY_STORE_ALIAS_PASSWORD = getPassword("\nPlease enter key alias password for alias " + project.KEY_STORE_ALIAS + ":")
} }
release { release {
storeFile file(project.KEY_STORE) storeFile file(project.KEY_STORE)
storePassword project.KEY_STORE_PASSWORD storePassword project.KEY_STORE_PASSWORD
@@ -44,7 +50,7 @@ android {
if(signingFile.exists()) { if(signingFile.exists()) {
Properties signing = new Properties() Properties signing = new Properties()
signing.load(new FileInputStream(signingFile)) signing.load(new FileInputStream(signingFile))
signingConfigs { signingConfigs {
release { release {
storeFile file(signing["KEY_STORE"]) storeFile file(signing["KEY_STORE"])
@@ -59,14 +65,14 @@ android {
} }
} }
::end:: ::end::
buildTypes { buildTypes {
release { release {
minifyEnabled false minifyEnabled false
signingConfig signingConfigs.release signingConfig signingConfigs.release
} }
} }
android.applicationVariants.all { variant -> android.applicationVariants.all { variant ->
variant.outputs.all { output -> variant.outputs.all { output ->
if (outputFileName != null && outputFileName.endsWith('.apk')) { if (outputFileName != null && outputFileName.endsWith('.apk')) {
@@ -77,8 +83,8 @@ android {
} }
dependencies { dependencies {
api fileTree(dir: 'libs', include: ['*.jar']) implementation fileTree(dir: 'libs', include: ['*.jar'])
::if (ANDROID_LIBRARY_PROJECTS)::::foreach (ANDROID_LIBRARY_PROJECTS)::api project(':deps:::name::') ::if (ANDROID_LIBRARY_PROJECTS)::::foreach (ANDROID_LIBRARY_PROJECTS)::implementation project(':deps:::name::')
::end::::end:: ::end::::end::
} }
@@ -97,11 +103,11 @@ def getPassword(message) {
show: true show: true
) { ) {
lookAndFeel('system') lookAndFeel('system')
panel(border: new EmptyBorder(10, 10, 10, 10)) { panel(border: new EmptyBorder(10, 10, 10, 10)) {
gridBagLayout() gridBagLayout()
def gbc = new GridBagConstraints(); def gbc = new GridBagConstraints();
gbc.gridx = 0 gbc.gridx = 0
gbc.gridy = 0 gbc.gridy = 0
gbc.fill = GridBagConstraints.HORIZONTAL gbc.fill = GridBagConstraints.HORIZONTAL
@@ -113,10 +119,10 @@ def getPassword(message) {
'</body>' + '</body>' +
'</html>', '</html>',
constraints: gbc) constraints: gbc)
gbc.gridy = 1 gbc.gridy = 1
input = passwordField(constraints: gbc) input = passwordField(constraints: gbc)
gbc.gridy = 2 gbc.gridy = 2
gbc.fill = GridBagConstraints.NONE gbc.fill = GridBagConstraints.NONE
gbc.insets = [0, 0, 0, 0] gbc.insets = [0, 0, 0, 0]

View File

@@ -1,15 +1,13 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="::APP_PACKAGE::" android:versionCode="::APP_BUILD_NUMBER::" android:versionName="::APP_VERSION::" android:installLocation="::ANDROID_INSTALL_LOCATION::"> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="::APP_PACKAGE::" android:versionCode="::APP_BUILD_NUMBER::" android:versionName="::APP_VERSION::" android:installLocation="::ANDROID_INSTALL_LOCATION::">
<uses-feature android:glEsVersion="0x00020000" android:required="true" /> <uses-feature android:glEsVersion="0x00020000" android:required="true" />
<uses-feature android:name="android.hardware.touchscreen" android:required="false" /> <uses-feature android:name="android.hardware.touchscreen" android:required="false" />
::if (ANDROID_PERMISSIONS != null)::::foreach ANDROID_PERMISSIONS::<uses-permission android:name="::__current__::" /> ::if (ANDROID_PERMISSIONS != null)::::foreach ANDROID_PERMISSIONS::<uses-permission android:name="::__current__::" />
::end::::end:: ::end::::end::
<uses-sdk android:minSdkVersion="::ANDROID_MINIMUM_SDK_VERSION::" android:targetSdkVersion="::ANDROID_TARGET_SDK_VERSION::"/> <application android:label="::APP_TITLE::" ::if (HAS_ICON):: android:icon="@drawable/icon"::end:: android:allowBackup="true" android:theme="@android:style/Theme.NoTitleBar::if (WIN_FULLSCREEN)::.Fullscreen::end::" android:hardwareAccelerated="true" ::if (ANDROID_TARGET_SDK_VERSION>=30):: android:allowNativeHeapPointerTagging="false" ::end::>
<application android:label="::APP_TITLE::" ::if (HAS_ICON):: android:icon="@drawable/icon"::end:: android:allowBackup="true" android:theme="@android:style/Theme.NoTitleBar::if (WIN_FULLSCREEN)::.Fullscreen::end::" android:hardwareAccelerated="true">
::if (WIN_ORIENTATION=="portrait"):: ::if (WIN_ORIENTATION=="portrait")::
<meta-data android:name="SDL_ENV.SDL_IOS_ORIENTATIONS" android:value= "Portrait PortraitUpsideDown" /> <meta-data android:name="SDL_ENV.SDL_IOS_ORIENTATIONS" android:value= "Portrait PortraitUpsideDown" />
@@ -20,17 +18,17 @@
::end:: ::end::
<activity android:name="MainActivity" android:exported="true" android:launchMode="singleTask" android:label="::APP_TITLE::" android:configChanges="keyboardHidden|orientation|screenSize|screenLayout|uiMode"::if (WIN_ORIENTATION=="portrait"):: android:screenOrientation="sensorPortrait"::end::::if (WIN_ORIENTATION=="landscape"):: android:screenOrientation="sensorLandscape"::end::> <activity android:name="MainActivity" android:exported="true" android:launchMode="singleTask" android:label="::APP_TITLE::" android:configChanges="keyboardHidden|orientation|screenSize|screenLayout|uiMode"::if (WIN_ORIENTATION=="portrait"):: android:screenOrientation="sensorPortrait"::end::::if (WIN_ORIENTATION=="landscape"):: android:screenOrientation="sensorLandscape"::end::>
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" /> <category android:name="android.intent.category.LAUNCHER" />
<category android:name="tv.ouya.intent.category.GAME" /> <category android:name="tv.ouya.intent.category.GAME" />
</intent-filter> </intent-filter>
</activity> </activity>
</application> </application>
</manifest> </manifest>

View File

@@ -2,12 +2,12 @@
buildscript { buildscript {
repositories { repositories {
jcenter() mavenCentral()
google() google()
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:::ANDROID_GRADLE_PLUGIN::' classpath 'com.android.tools.build:gradle:::ANDROID_GRADLE_PLUGIN::'
// NOTE: Do not place your application dependencies here; they belong // NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files // in the individual module build.gradle files
} }
@@ -15,7 +15,7 @@ buildscript {
allprojects { allprojects {
repositories { repositories {
jcenter() mavenCentral()
google() google()
}::if ANDROID_GRADLE_BUILD_DIRECTORY:: }::if ANDROID_GRADLE_BUILD_DIRECTORY::
buildDir = "::ANDROID_GRADLE_BUILD_DIRECTORY::/::APP_FILE::/${project.name}"::end:: buildDir = "::ANDROID_GRADLE_BUILD_DIRECTORY::/::APP_FILE::/${project.name}"::end::
@@ -32,21 +32,22 @@ wrapper {
configure(subprojects.findAll {!it.file('build.gradle').exists() && it.file('build.xml').exists()}) { configure(subprojects.findAll {!it.file('build.gradle').exists() && it.file('build.xml').exists()}) {
buildscript { buildscript {
repositories { repositories {
jcenter() mavenCentral()
google() google()
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:::ANDROID_GRADLE_PLUGIN::' classpath 'com.android.tools.build:gradle:::ANDROID_GRADLE_PLUGIN::'
} }
} }
apply plugin: 'android-library' apply plugin: 'android-library'
android { android {
compileSdkVersion Integer.parseInt(project.ANDROID_BUILD_SDK_VERSION) compileSdkVersion Integer.parseInt(project.ANDROID_BUILD_SDK_VERSION)
buildToolsVersion project.ANDROID_BUILD_TOOLS_VERSION buildToolsVersion project.ANDROID_BUILD_TOOLS_VERSION
::if (ANDROID_GRADLE_PLUGIN>="4.0")::ndkPath '::ANDROID_NDK_ROOT_ESCAPED::'::end::
sourceSets { sourceSets {
main { main {
manifest.srcFile 'AndroidManifest.xml' manifest.srcFile 'AndroidManifest.xml'
@@ -55,9 +56,8 @@ configure(subprojects.findAll {!it.file('build.gradle').exists() && it.file('bui
} }
} }
} }
dependencies { dependencies {
api fileTree(dir: 'libs', include: ['*.jar']) implementation project(':deps:extension-api')
api project(':deps:extension-api')
} }
} }

View File

@@ -20,7 +20,10 @@ ANDROID_BUILD_TARGET_SDK_VERSION=::ANDROID_TARGET_SDK_VERSION::
ANDROID_BUILD_MIN_SDK_VERSION=::ANDROID_MINIMUM_SDK_VERSION:: ANDROID_BUILD_MIN_SDK_VERSION=::ANDROID_MINIMUM_SDK_VERSION::
ANDROID_BUILD_SDK_VERSION=::ANDROID_TARGET_SDK_VERSION:: ANDROID_BUILD_SDK_VERSION=::ANDROID_TARGET_SDK_VERSION::
ANDROID_BUILD_TOOLS_VERSION=::ANDROID_BUILD_TOOLS_VERSION:: ANDROID_BUILD_TOOLS_VERSION=::ANDROID_BUILD_TOOLS_VERSION::
::if (ANDROID_TARGET_SDK_VERSION>=28)::
android.useAndroidX=::ANDROID_USE_ANDROIDX::
android.enableJetifier=::ANDROID_ENABLE_JETIFIER::
::end::
::if KEY_STORE:: ::if KEY_STORE::
KEY_STORE=::KEY_STORE:: KEY_STORE=::KEY_STORE::
KEY_STORE_PASSWORD=::KEY_STORE_PASSWORD:: KEY_STORE_PASSWORD=::KEY_STORE_PASSWORD::

View File

@@ -4,4 +4,6 @@
# Location of the SDK. This is only used by Gradle. # Location of the SDK. This is only used by Gradle.
# #
sdk.dir=::ANDROID_SDK_ESCAPED:: sdk.dir=::ANDROID_SDK_ESCAPED::
::if (ANDROID_GRADLE_PLUGIN<"4.0")::
ndk.dir=::ANDROID_NDK_ROOT_ESCAPED:: ndk.dir=::ANDROID_NDK_ROOT_ESCAPED::
::end::

View File

@@ -1,9 +1,9 @@
buildscript { buildscript {
repositories { repositories {
jcenter() mavenCentral()
google() google()
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:::::if (1 == 1)::ANDROID_GRADLE_PLUGIN::end::::' classpath 'com.android.tools.build:gradle:::::if (1 == 1)::ANDROID_GRADLE_PLUGIN::end::::'
} }
@@ -17,5 +17,5 @@ android {
} }
dependencies { dependencies {
api project(':deps:extension-api') implementation project(':deps:extension-api')
} }

View File

@@ -451,7 +451,7 @@ class AndroidPlatform extends PlatformTarget
context.OUTPUT_DIR = targetDirectory; context.OUTPUT_DIR = targetDirectory;
context.ANDROID_INSTALL_LOCATION = project.config.getString("android.install-location", "auto"); context.ANDROID_INSTALL_LOCATION = project.config.getString("android.install-location", "auto");
context.ANDROID_MINIMUM_SDK_VERSION = project.config.getInt("android.minimum-sdk-version", 21); context.ANDROID_MINIMUM_SDK_VERSION = project.config.getInt("android.minimum-sdk-version", 21);
context.ANDROID_TARGET_SDK_VERSION = project.config.getInt("android.target-sdk-version", 28); context.ANDROID_TARGET_SDK_VERSION = project.config.getInt("android.target-sdk-version", 30);
context.ANDROID_EXTENSIONS = project.config.getArrayString("android.extension"); context.ANDROID_EXTENSIONS = project.config.getArrayString("android.extension");
context.ANDROID_PERMISSIONS = project.config.getArrayString("android.permission", [ context.ANDROID_PERMISSIONS = project.config.getArrayString("android.permission", [
"android.permission.WAKE_LOCK", "android.permission.WAKE_LOCK",
@@ -459,8 +459,10 @@ class AndroidPlatform extends PlatformTarget
"android.permission.VIBRATE", "android.permission.VIBRATE",
"android.permission.ACCESS_NETWORK_STATE" "android.permission.ACCESS_NETWORK_STATE"
]); ]);
context.ANDROID_GRADLE_VERSION = project.config.getString("android.gradle-version", "5.6.3"); context.ANDROID_GRADLE_VERSION = project.config.getString("android.gradle-version", "7.4.2");
context.ANDROID_GRADLE_PLUGIN = project.config.getString("android.gradle-plugin", "3.5.1"); context.ANDROID_GRADLE_PLUGIN = project.config.getString("android.gradle-plugin", "7.3.1");
context.ANDROID_USE_ANDROIDX = project.config.getString("android.useAndroidX", "true");
context.ANDROID_ENABLE_JETIFIER = project.config.getString("android.enableJetifier", "false");
context.ANDROID_LIBRARY_PROJECTS = []; context.ANDROID_LIBRARY_PROJECTS = [];

View File

@@ -589,7 +589,7 @@ class PlatformSetup
Log.println("\x1b[1mIn order to build applications for Android, you must have recent"); Log.println("\x1b[1mIn order to build applications for Android, you must have recent");
Log.println("versions of the Android SDK, Android NDK and Java JDK installed."); Log.println("versions of the Android SDK, Android NDK and Java JDK installed.");
Log.println(""); Log.println("");
Log.println("You must also install the Android SDK Platform-tools and API 19 using"); Log.println("You must also install the Android SDK Platform-tools and API 30 using");
Log.println("the SDK manager from Android Studio.\x1b[0m"); Log.println("the SDK manager from Android Studio.\x1b[0m");
Log.println(""); Log.println("");