Skip to content

Commit 28e3acc

Browse files
authored
🐛 Fix miscellaneous configuration regarding the Android module (#1282)
Fixes #1198
1 parent 3d05aa0 commit 28e3acc

File tree

11 files changed

+174
-297
lines changed

11 files changed

+174
-297
lines changed

.github/workflows/build-example-apk.yml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
11
name: Build example apk
22

3+
concurrency:
4+
group: ${{ github.workflow }}-${{ github.ref }}
5+
cancel-in-progress: true
6+
37
on:
48
release:
59
types:
610
- created
711

12+
permissions:
13+
contents: write
14+
815
env:
916
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1017

@@ -15,9 +22,9 @@ jobs:
1522
- uses: actions/checkout@v4
1623
- uses: actions/setup-java@v4
1724
with:
18-
distribution: 'adopt'
25+
distribution: 'zulu'
1926
java-version: '17'
20-
- uses: subosito/flutter-action@v2
27+
- uses: flutter-actions/setup-flutter@v4
2128
with:
2229
channel: 'stable'
2330
cache: true
@@ -32,6 +39,3 @@ jobs:
3239
echo "Show apk download url: "
3340
gh release view ${{ github.event.release.tag_name }} --json assets --jq '.assets.[].url'
3441
working-directory: ${{ github.workspace }}/example
35-
36-
permissions:
37-
contents: write

.github/workflows/check-compatibility.yml

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
name: Add library to new flutter project
22

3+
concurrency:
4+
group: ${{ github.workflow }}-${{ github.ref }}
5+
cancel-in-progress: true
6+
37
on:
48
pull_request:
5-
branches:
9+
branches:
610
- main
711
push:
8-
branches:
12+
branches:
913
- main
1014
- 2.x
1115

@@ -15,14 +19,16 @@ jobs:
1519
runs-on: ubuntu-latest
1620
steps:
1721
- uses: actions/checkout@v4
18-
- uses: subosito/flutter-action@v2
22+
- uses: flutter-actions/setup-flutter@v4
1923
with:
2024
channel: 'stable'
2125
cache: true
2226
- uses: actions/setup-java@v4
2327
with:
24-
distribution: 'adopt'
28+
distribution: 'zulu'
2529
java-version: '17'
30+
- name: Set up Android SDK
31+
uses: android-actions/setup-android@v3
2632
- run: flutter doctor -v
2733
name: Flutter info
2834
- run: flutter create new_project --platforms=android
@@ -41,7 +47,7 @@ jobs:
4147
runs-on: macos-latest
4248
steps:
4349
- uses: actions/checkout@v4
44-
- uses: subosito/flutter-action@v2
50+
- uses: flutter-actions/setup-flutter@v4
4551
with:
4652
channel: 'stable'
4753
cache: true
@@ -68,7 +74,7 @@ jobs:
6874
runs-on: ubuntu-latest
6975
steps:
7076
- uses: actions/checkout@v4
71-
- uses: subosito/flutter-action@v2
77+
- uses: flutter-actions/setup-flutter@v4
7278
with:
7379
channel: 'stable'
7480
cache: true
@@ -90,7 +96,7 @@ jobs:
9096
runs-on: ubuntu-latest
9197
steps:
9298
- uses: actions/checkout@v4
93-
- uses: subosito/flutter-action@v2
99+
- uses: flutter-actions/setup-flutter@v4
94100
with:
95101
channel: 'stable'
96102
cache: true
@@ -118,7 +124,7 @@ jobs:
118124
runs-on: macos-latest
119125
steps:
120126
- uses: actions/checkout@v4
121-
- uses: subosito/flutter-action@v2
127+
- uses: flutter-actions/setup-flutter@v4
122128
with:
123129
channel: 'stable'
124130
cache: true
@@ -145,7 +151,7 @@ jobs:
145151
runs-on: windows-latest
146152
steps:
147153
- uses: actions/checkout@v4
148-
- uses: subosito/flutter-action@v2
154+
- uses: flutter-actions/setup-flutter@v4
149155
with:
150156
channel: 'stable'
151157
cache: true

.github/workflows/runnable.yml

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
name: Runnable (stable)
22

3+
concurrency:
4+
group: ${{ github.workflow }}-${{ github.ref }}
5+
cancel-in-progress: true
6+
37
on:
48
push:
59
branches:
@@ -23,8 +27,8 @@ jobs:
2327
- uses: actions/checkout@v4
2428
- uses: actions/setup-java@v4
2529
with:
26-
distribution: "adopt"
27-
java-version: "17"
30+
distribution: 'zulu'
31+
java-version: '17'
2832
- uses: subosito/flutter-action@v2
2933
with:
3034
channel: "stable"
@@ -57,8 +61,8 @@ jobs:
5761
- uses: actions/checkout@v4
5862
- uses: actions/setup-java@v4
5963
with:
60-
distribution: "adopt"
61-
java-version: "17"
64+
distribution: 'zulu'
65+
java-version: '17'
6266
- uses: subosito/flutter-action@v2
6367
with:
6468
channel: "stable"
@@ -93,8 +97,8 @@ jobs:
9397
- uses: actions/checkout@v4
9498
- uses: actions/setup-java@v4
9599
with:
96-
java-version: "17"
97-
distribution: "adopt"
100+
distribution: 'zulu'
101+
java-version: '17'
98102
- uses: subosito/flutter-action@v2
99103
with:
100104
channel: "stable"
@@ -135,8 +139,8 @@ jobs:
135139
- uses: actions/checkout@v4
136140
- uses: actions/setup-java@v4
137141
with:
138-
java-version: "17"
139-
distribution: "adopt"
142+
distribution: 'zulu'
143+
java-version: '17'
140144
- uses: subosito/flutter-action@v2
141145
with:
142146
channel: "stable"
@@ -156,8 +160,8 @@ jobs:
156160
- uses: actions/checkout@v4
157161
- uses: actions/setup-java@v4
158162
with:
159-
java-version: "17"
160-
distribution: "adopt"
163+
distribution: 'zulu'
164+
java-version: '17'
161165
- uses: subosito/flutter-action@v2
162166
with:
163167
channel: "stable"
@@ -177,12 +181,11 @@ jobs:
177181
- uses: actions/checkout@v4
178182
- uses: actions/setup-java@v4
179183
with:
180-
distribution: "adopt"
181-
java-version: "17"
182-
- uses: subosito/flutter-action@v2
184+
distribution: 'zulu'
185+
java-version: '17'
186+
- uses: flutter-actions/setup-flutter@v4
183187
with:
184-
channel: "stable"
185-
architecture: x64
188+
channel: 'stable'
186189
cache: true
187190
- run: flutter doctor -v
188191
- run: flutter pub get

android/build.gradle

Lines changed: 7 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import java.util.regex.Matcher
2-
import java.util.regex.Pattern
31

42
group 'com.fluttercandies.photo_manager'
53
version '1.0-SNAPSHOT'
@@ -26,117 +24,24 @@ rootProject.allprojects {
2624
apply plugin: 'com.android.library'
2725
apply plugin: 'kotlin-android'
2826

29-
void log(Object msg) {
30-
logger.log(LogLevel.INFO, "[PhotoManager] $msg")
31-
}
32-
33-
/**
34-
* Get java version from JAVA_HOME
35-
* @param path JAVA_HOME path
36-
* @return java version
37-
*/
38-
JavaVersion getJavaFromHome(String path) {
39-
def releaseFile = new File(path, "release")
40-
41-
if (releaseFile.exists()) {
42-
def pattern = Pattern.compile("JAVA_VERSION=\"(\\d+)\"")
43-
def matcher = pattern.matcher(releaseFile.text)
44-
if (matcher.find()) {
45-
def version = matcher.group(1)
46-
log("Get java version from release file: $version")
47-
return JavaVersion.toVersion(version)
48-
}
49-
} else {
50-
def javaBin = new File("${path}/bin/java")
51-
if (javaBin.exists()) {
52-
return JavaVersion.VERSION_1_8
53-
} else if (new File("${path}/bin/java.exe").exists()) {
54-
return JavaVersion.VERSION_1_8
55-
}
56-
57-
return null
58-
}
59-
}
60-
61-
JavaVersion getJavaVersion() {
62-
try {
63-
// 0. Get java.version property from project's gradle.properties
64-
// The version value is like 1.8, 11, 17, 21, etc.
65-
// Also see: https://docs.gradle.org/current/javadoc/org/gradle/api/JavaVersion.html#toVersion-java.lang.Object-
66-
JavaVersion res
67-
68-
def javaVersion = project.rootProject.findProperty("java.version")
69-
if (javaVersion != null) {
70-
res = JavaVersion.toVersion(javaVersion)
71-
log("Get java version from project's gradle.properties: $javaVersion")
72-
if (res != null) {
73-
return res
74-
}
75-
}
76-
77-
String javaHome
78-
// 1. read from JAVA_HOME environment variable
79-
javaHome = System.getenv("JAVA_HOME")
80-
if (res == null && javaHome != null) {
81-
res = getJavaFromHome(javaHome)
82-
log("Get java version from JAVA_HOME: $javaHome")
83-
if (res != null) {
84-
return res
85-
}
86-
}
87-
88-
// 2. read gradle.properties
89-
javaHome = project.rootProject.findProperty("java.home")
90-
if (res == null && javaHome != null) {
91-
res = getJavaFromHome(javaHome)
92-
log("Get java version from gradle.properties: $javaHome")
93-
if (res != null) {
94-
return res
95-
}
96-
}
97-
98-
// 3. read from property with java.home
99-
javaHome = System.getProperty("java.home")
100-
if (res == null && javaHome != null) {
101-
res = getJavaFromHome(javaHome)
102-
log("Get java version from java.home: $javaHome")
103-
if (res != null) {
104-
return res
105-
}
106-
}
107-
108-
if (res != null) {
109-
return res
110-
}
111-
} catch (Exception e) {
112-
e.printStackTrace()
113-
}
114-
115-
// last, use default version with current
116-
return JavaVersion.current()
117-
}
118-
11927
android {
120-
if (project.android.hasProperty('namespace') ||
121-
getGradle().getGradleVersion().substring(0, 1).toInteger() >= 8) {
28+
if (project.android.hasProperty('namespace')) {
12229
namespace 'com.flutterandies.photo_manager'
12330
}
12431

12532
compileSdkVersion 34
12633

127-
sourceSets {
128-
main.java.srcDirs += 'src/main/kotlin'
34+
defaultConfig {
35+
minSdkVersion 16
12936
}
13037

13138
compileOptions {
132-
def version = getJavaVersion()
133-
sourceCompatibility = version
134-
targetCompatibility = version
39+
sourceCompatibility JavaVersion.VERSION_17
40+
targetCompatibility JavaVersion.VERSION_17
13541
}
13642

137-
defaultConfig {
138-
minSdkVersion 16
139-
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
43+
sourceSets {
44+
main.java.srcDirs += 'src/main/kotlin'
14045
}
14146
}
14247

android/gradle.properties

Lines changed: 0 additions & 2 deletions
This file was deleted.

android/gradle/wrapper/gradle-wrapper.properties

Lines changed: 0 additions & 6 deletions
This file was deleted.

0 commit comments

Comments
 (0)