Skip to content

Commit

Permalink
Merge pull request #552 from ably/ECO-5020/fix-build-gradle
Browse files Browse the repository at this point in the history
[ECO-5020] fix: update AGP plugin
  • Loading branch information
ttypic authored Oct 9, 2024
2 parents c6a780f + cc89958 commit e7d74cf
Show file tree
Hide file tree
Showing 33 changed files with 339 additions and 372 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4

- uses: subosito/flutter-action@v2
with:
flutter-version: '3.0.x'
flutter-version: '3.24'
cache: true

# This step requires fetch of test_integration packages because flutter format and
Expand All @@ -25,7 +25,7 @@ jobs:
cd test_integration && flutter pub get
- name: 'Check formatting issues in the code'
run: flutter format --set-exit-if-changed .
run: dart format --set-exit-if-changed .

- name: 'Statically analyze the Dart code for any errors'
run: 'flutter analyze --no-pub .'
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ jobs:
deployments: write
id-token: write
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- uses: subosito/flutter-action@v2
with:
flutter-version: '3.0.x'
flutter-version: '3.24'
cache: true

- name: Use Intro Blurb As Homepage
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/flutter_example_app.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ jobs:
ios:
runs-on: "macos-latest"
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: subosito/flutter-action@v2
with:
flutter-version: "3.0.x"
flutter-version: "3.24"
cache: true

- name: "Build example app for iOS"
Expand All @@ -23,16 +23,16 @@ jobs:
android:
runs-on: "ubuntu-latest"
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: actions/setup-java@v3
- uses: actions/setup-java@v4
with:
distribution: "temurin"
java-version: "11"
java-version: "17"

- uses: subosito/flutter-action@v2
with:
flutter-version: "3.0.x"
flutter-version: "3.24"
cache: true

- name: "Build example app for Android"
Expand Down
29 changes: 17 additions & 12 deletions .github/workflows/flutter_integration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,21 @@ jobs:
strategy:
matrix:
device: # Device names must be shown in `xcrun simctl list devices`
- 'iPhone 12' # we are not specifying the iOS version as it tends to change
- 'iPhone 15' # we are not specifying the iOS version as it tends to change
fail-fast: false
runs-on: 'macos-11'
runs-on: macos-latest
steps:
- name: 'List Simulators'
run: 'xcrun simctl list devices'

- name: 'Start Simulator'
run: xcrun simctl boot "${{ matrix.device }}"

- uses: actions/checkout@v2
- uses: actions/checkout@v4

- uses: subosito/flutter-action@v2
with:
flutter-version: '3.0.x'
flutter-version: '3.24'
cache: true

# test_integration package depends on ably_flutter, so before we run integration
Expand All @@ -38,24 +38,29 @@ jobs:
cd test_integration && ./run_integration_tests.sh
android:
runs-on: ubuntu-latest
strategy:
matrix:
api-level: [24, 29]
fail-fast: false

runs-on: 'macos-11'

steps:
- uses: actions/checkout@v3
- name: checkout
uses: actions/checkout@v4

- uses: actions/setup-java@v3
- uses: actions/setup-java@v4
with:
distribution: 'corretto'
java-version: '11'
distribution: "temurin"
java-version: "17"

- name: Enable KVM
run: |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm
- uses: subosito/flutter-action@v2
with:
flutter-version: '3.0.x'
flutter-version: '3.24'
cache: true

- name: 'Run Flutter Driver tests'
Expand Down
4 changes: 0 additions & 4 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ linter:
rules:
- always_declare_return_types
- always_put_required_named_parameters_first
- always_require_non_null_named_parameters
- always_use_package_imports
- avoid_bool_literals_in_conditional_expressions
- avoid_catches_without_on_clauses
Expand All @@ -44,8 +43,6 @@ linter:
- avoid_relative_lib_imports
- avoid_renaming_method_parameters
- avoid_return_types_on_setters
- avoid_returning_null
- avoid_returning_null_for_future
- avoid_returning_null_for_void
- avoid_returning_this
- avoid_setters_without_getters
Expand All @@ -66,7 +63,6 @@ linter:
- do_not_use_environment
- empty_constructor_bodies
- hash_and_equals
- invariant_booleans
- join_return_with_assignment
- leading_newlines_in_multiline_strings
- lines_longer_than_80_chars
Expand Down
12 changes: 10 additions & 2 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:7.2.0'
classpath 'com.android.tools.build:gradle:7.4.0'
}
}

Expand All @@ -33,7 +33,12 @@ dependencies {
}

android {
compileSdkVersion 32
compileSdkVersion 34

// Conditional for compatibility with AGP <4.2.
if (project.android.hasProperty("namespace")) {
namespace 'io.ably.flutter.plugin'
}

// Require Java language level 8 so we can use Method References (used with Lambdas)
compileOptions {
Expand All @@ -56,6 +61,9 @@ android {
lintOptions {
disable 'InvalidPackage'
}
buildFeatures {
buildConfig true
}
}

apply from: file("./ably-agent.gradle")
Binary file modified android/gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
3 changes: 2 additions & 1 deletion android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
18 changes: 14 additions & 4 deletions android/gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
Expand All @@ -80,10 +80,10 @@ do
esac
done

APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit

APP_NAME="Gradle"
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
Expand Down Expand Up @@ -143,12 +143,16 @@ fi
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
Expand Down Expand Up @@ -205,6 +209,12 @@ set -- \
org.gradle.wrapper.GradleWrapperMain \
"$@"

# Stop when "xargs" is not available.
if ! command -v xargs >/dev/null 2>&1
then
die "xargs is not available"
fi

# Use "xargs" to parse quoted args.
#
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
Expand Down
15 changes: 9 additions & 6 deletions android/gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
@rem limitations under the License.
@rem

@if "%DEBUG%" == "" @echo off
@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
Expand All @@ -25,7 +25,8 @@
if "%OS%"=="Windows_NT" setlocal

set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
if "%DIRNAME%"=="" set DIRNAME=.
@rem This is normally unused
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%

Expand All @@ -40,7 +41,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome

set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto execute
if %ERRORLEVEL% equ 0 goto execute

echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Expand Down Expand Up @@ -75,13 +76,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar

:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
if %ERRORLEVEL% equ 0 goto mainEnd

:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
set EXIT_CODE=%ERRORLEVEL%
if %EXIT_CODE% equ 0 set EXIT_CODE=1
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
exit /b %EXIT_CODE%

:mainEnd
if "%OS%"=="Windows_NT" endlocal
Expand Down
61 changes: 22 additions & 39 deletions example/android/app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,63 +1,46 @@
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}

def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
}

def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.0'
plugins {
id "com.android.application"
id "kotlin-android"
// The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins.
id "dev.flutter.flutter-gradle-plugin"
}

apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
compileSdkVersion 32
namespace = "io.ably.flutter.example"
compileSdk = flutter.compileSdkVersion
ndkVersion = flutter.ndkVersion

// Require Java language level 8 so we can use Method References (used with Lambdas)
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}

lintOptions {
disable 'InvalidPackage'
kotlinOptions {
jvmTarget = JavaVersion.VERSION_1_8
}

defaultConfig {
applicationId "io.ably.flutter.example"
minSdkVersion 19
targetSdkVersion 32
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId = "io.ably.flutter.example"
// You can update the following values to match your application needs.
// For more information, see: https://flutter.dev/to/review-gradle-config.
minSdk = flutter.minSdkVersion
targetSdk = flutter.targetSdkVersion
versionCode = flutter.versionCode
versionName = flutter.versionName
}

buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.debug
signingConfig = signingConfigs.debug
}
}
}

flutter {
source '../..'
source = "../.."
}

dependencies {
Expand Down
Loading

0 comments on commit e7d74cf

Please sign in to comment.