Skip to content

Commit

Permalink
Gradle version testing and iOS patch (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
laves authored Feb 8, 2024
1 parent 57a0d5c commit c9ac353
Show file tree
Hide file tree
Showing 22 changed files with 594 additions and 141 deletions.
35 changes: 30 additions & 5 deletions .github/workflows/flutter-example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,25 +25,50 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
flutter-version: ['2.8.1', '3.0.4']
flutter-version: ['2.8.1', '3.0.4', '3.10.6']
include:
- flutter-version: 2.8.1
gradle-version: 6.5
agp-version: 4.1.3
java-version: 11
- flutter-version: 3.0.4
gradle-version: 7.5
agp-version: 7.4.2
java-version: 11
- flutter-version: 3.10.6
gradle-version: 8.2
agp-version: 8.2.2
java-version: 17

steps:
- uses: actions/checkout@v3

- name: Set up JDK 11
uses: actions/setup-java@v3
- name: Set up JDK ${{ matrix.java-version }}
uses: actions/setup-java@v4
with:
java-version: '11'
java-version: ${{ matrix.java-version }}
distribution: 'temurin'

- name: Install Flutter ${{ matrix.flutter-version }}
uses: subosito/flutter-action@v2
with:
flutter-version: ${{ matrix.flutter-version }}

- uses: gradle/actions/setup-gradle@v3
with:
gradle-version: ${{ matrix.gradle-version }}

- name: Inject AGP version
run: echo agpVersion="${{ matrix.agp-version }}" >> local.properties
working-directory: example/android

- name: Install dependencies
run: flutter pub get

- name: Generate gradle wrapper
run: gradle wrapper --gradle-version ${{ matrix.gradle-version }} --distribution-type all
working-directory: example/android

- name: Build
run: flutter build apk

Expand All @@ -52,7 +77,7 @@ jobs:
runs-on: macos-latest
strategy:
matrix:
flutter-version: ['2.8.1', '3.0.4']
flutter-version: ['2.8.1', '3.0.4', '3.10.6']

steps:
- uses: actions/checkout@v3
Expand Down
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,7 @@

## [1.1.0] - 2023-08-03
* Improved API
* Changed native recorders
* Changed native recorders

## [1.1.1] - 2024-02-07
* iOS channel events to main thread
12 changes: 11 additions & 1 deletion 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:4.1.3'
classpath 'com.android.tools.build:gradle:7.4.2'
}
}

Expand All @@ -22,6 +22,16 @@ rootProject.allprojects {
apply plugin: 'com.android.library'

android {
def agpVersion = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION
if (agpVersion.tokenize('.')[0].toInteger() >= 7) {
namespace "ai.picovoice.flutter.voiceprocessor"
}

if (agpVersion.tokenize('.')[0].toInteger() >= 8) {
buildFeatures {
buildConfig = true
}
}
compileSdkVersion 31

defaultConfig {
Expand Down
2 changes: 1 addition & 1 deletion android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Mon Jul 31 11:07:10 PDT 2023
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
3 changes: 0 additions & 3 deletions example/android/.gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
gradle-wrapper.jar
/.gradle
/captures/
/gradlew
/gradlew.bat
/local.properties
GeneratedPluginRegistrant.java

Expand Down
39 changes: 13 additions & 26 deletions example/android/app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,30 +1,17 @@
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'
}

apply plugin: 'com.android.application'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
apply from: "$defaultFlutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
def agpVersion = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION
if (agpVersion.tokenize('.')[0].toInteger() >= 7) {
namespace "ai.picovoice.flutter.voiceprocessorexample"
}

if (agpVersion.tokenize('.')[0].toInteger() >= 8) {
buildFeatures {
buildConfig = true
}
}
compileSdk 33

lintOptions {
Expand All @@ -35,8 +22,8 @@ android {
applicationId "ai.picovoice.flutter.voiceprocessorexample"
minSdkVersion 21
targetSdkVersion 33
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
versionCode defaultFlutterVersionCode.toInteger()
versionName defaultFlutterVersionName
}

buildTypes {
Expand Down
38 changes: 37 additions & 1 deletion example/android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,47 @@


buildscript {
repositories {
google()
jcenter()
}

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'
}

def agpVersion = localProperties.getProperty('agpVersion')
if (agpVersion == null) {
agpVersion = '7.4.2'
}

ext {
defaultFlutterRoot = flutterRoot
defaultFlutterVersionCode = flutterVersionCode
defaultFlutterVersionName = flutterVersionName
}

dependencies {
classpath 'com.android.tools.build:gradle:7.4.2'
classpath "com.android.tools.build:gradle:$agpVersion"
}
}

Expand Down
Binary file added example/android/gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
5 changes: 3 additions & 2 deletions example/android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#Fri Jun 23 08:50:38 CEST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
Loading

0 comments on commit c9ac353

Please sign in to comment.