Skip to content

Commit 24c783f

Browse files
authored
Merge pull request #6 from kkgit2008/fresh-new_03
run it on github action
2 parents a3fc947 + 294a499 commit 24c783f

6 files changed

Lines changed: 182 additions & 7 deletions

File tree

.github/workflows/build.yml

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
name: Android Build
2+
3+
### To build from subfolder,just modify the 'ANDROID_DIR'
4+
5+
on:
6+
push:
7+
# branches: [ "main","master","dev","release" ]
8+
### Start build only on these branches
9+
workflow_dispatch:
10+
### Support manual build in 'Actions/workflow'
11+
12+
env:
13+
ANDROID_DIR: .
14+
### Build from project root (when 'app' folder is just at project root)
15+
# ANDROID_DIR: android
16+
### Build from 'android' folder (when 'app' folder is in 'project/android' folder), modify it as you need.
17+
NDK_VERSION: 29.0.13599879
18+
19+
permissions:
20+
contents: write
21+
22+
jobs:
23+
build_apk:
24+
strategy:
25+
matrix:
26+
build_type: ['debug', 'release']
27+
# build_type: ['debug']
28+
name: Build APK
29+
runs-on: ubuntu-latest
30+
steps:
31+
32+
- name: Cancel previous runs
33+
uses: styfle/cancel-workflow-action@0.12.1
34+
with:
35+
access_token: ${{ github.token }}
36+
37+
- name: Checkout code
38+
uses: actions/checkout@v4
39+
40+
- name: Cache NDK
41+
uses: actions/cache@v3
42+
id: cache-ndk
43+
with:
44+
path: /usr/local/lib/android/sdk/ndk/${{ env.NDK_VERSION }}
45+
key: ${{ runner.os }}-ndk-${{ env.NDK_VERSION }}
46+
47+
- name: Accept Android licenses and install NDK
48+
if: steps.cache-ndk.outputs.cache-hit != 'true'
49+
run: |
50+
sudo apt-get update && sudo apt-get install -y expect
51+
expect -c '
52+
set timeout 300
53+
spawn /usr/local/lib/android/sdk/cmdline-tools/latest/bin/sdkmanager --licenses
54+
### step1: handle Review licenses that have not been accepted (y/N)?"
55+
expect {
56+
"Review licenses that have not been accepted (y/N)?" {
57+
send "y\r"
58+
exp_continue
59+
}
60+
}
61+
### step2: handle all licences
62+
while {[expect {
63+
"Accept? (y/N):" {
64+
send "y\r"
65+
exp_continue
66+
}
67+
### ignore info of progress bar
68+
-re "\[.*\] \d+%.*" {
69+
exp_continue
70+
}
71+
### when finished
72+
eof {
73+
return 1
74+
}
75+
}]} {}
76+
'
77+
### install NDK
78+
/usr/local/lib/android/sdk/cmdline-tools/latest/bin/sdkmanager "ndk;${{ env.NDK_VERSION }}"
79+
shell: bash
80+
81+
82+
- name: Set up JDK 17
83+
uses: actions/setup-java@v4
84+
with:
85+
java-version: '17'
86+
distribution: 'temurin'
87+
88+
- name: Cache Gradle and build outputs
89+
uses: actions/cache@v3
90+
with:
91+
path: |
92+
~/.gradle/caches
93+
~/.gradle/wrapper
94+
${{ env.ANDROID_DIR }}/app/build
95+
${{ env.ANDROID_DIR }}/app/.cxx ### NDK cache dir
96+
key: ${{ runner.os }}-gradle-${{ hashFiles('**/gradle-wrapper.properties', '**/build.gradle', '**/CMakeLists.txt') }}
97+
restore-keys: |
98+
${{ runner.os }}-gradle-
99+
100+
- name: Increase Gradle memory
101+
working-directory: ${{ env.ANDROID_DIR }}
102+
run: |
103+
printf "\norg.gradle.jvmargs=-Xmx4g -XX:MaxMetaspaceSize=1g\n" >> gradle.properties
104+
105+
- name: Make gradlew executable
106+
working-directory: ${{ env.ANDROID_DIR }}
107+
run: |
108+
if [ ! -f "gradlew" ]; then gradle wrapper; fi
109+
chmod +x gradlew
110+
111+
- name: Build ${{ matrix.build_type }} APK
112+
working-directory: ${{ env.ANDROID_DIR }}
113+
run: |
114+
build_type=${{ matrix.build_type }}
115+
./gradlew assemble${build_type^}
116+
117+
- name: Show apk paths
118+
run: |
119+
echo ">>${{ env.ANDROID_DIR }}/app/build/outputs/apk/${{ matrix.build_type }}:"
120+
ls -la ${{ env.ANDROID_DIR }}/app/build/outputs/apk/${{ matrix.build_type }}
121+
122+
- name: Copy ${{ matrix.build_type }} APK
123+
run: |
124+
cp ${{ env.ANDROID_DIR }}/app/build/outputs/apk/${{ matrix.build_type }}/*.apk ./
125+
126+
- name: Upload ${{ matrix.build_type }} APK
127+
uses: actions/upload-artifact@v4
128+
with:
129+
name: apk-${{ matrix.build_type }}
130+
path: app-${{ matrix.build_type }}.apk

ai-core/build.gradle.kts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,6 @@ android {
5252
)
5353
}
5454
}
55-
externalNativeBuild {
56-
cmake {
57-
path("src/main/cpp/CMakeLists.txt")
58-
version = "3.22.1"
59-
}
60-
}
6155
compileOptions {
6256
sourceCompatibility = JavaVersion.VERSION_11
6357
targetCompatibility = JavaVersion.VERSION_11

app/build.gradle.kts

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,52 @@ android {
3333
abiFilters += listOf("arm64-v8a")
3434
}
3535
}
36+
37+
// ****** sign apk ******
38+
signingConfigs {
39+
create("releaseee") {
40+
val localProperties = Properties()
41+
val localPropertiesFile = rootProject.file("local.properties")
42+
enableV1Signing = true
43+
enableV2Signing = true
44+
enableV3Signing = true
45+
if (localPropertiesFile.exists()) {
46+
localProperties.load(FileInputStream(localPropertiesFile))
47+
48+
val storeFilePath = localProperties.getProperty("storeFile")
49+
val storePasswordValue = localProperties.getProperty("storePassword")
50+
val keyAliasValue = localProperties.getProperty("keyAlias")
51+
val keyPasswordValue = localProperties.getProperty("keyPassword")
52+
53+
if (storeFilePath != null && storePasswordValue != null &&
54+
keyAliasValue != null && keyPasswordValue != null) {
55+
storeFile = file(storeFilePath)
56+
storePassword = storePasswordValue
57+
keyAlias = keyAliasValue
58+
keyPassword = keyPasswordValue
59+
} else {
60+
logger.error("There is sth wrong with file content:local.properties !")
61+
}
62+
} else {
63+
logger.error("File not exist:local.properties !")
64+
}
65+
}
66+
}
67+
68+
buildTypes {
69+
debug {
70+
//signingConfig = signingConfigs.getByName("releaseee")
71+
//applicationIdSuffix '.debug'
72+
versionNameSuffix = "-debug"
73+
}
74+
release {
75+
signingConfig = signingConfigs.getByName("releaseee")
76+
77+
}
78+
}
79+
// ****** sign apk ******
80+
81+
3682
buildTypes {
3783
release {
3884
isMinifyEnabled = false // Enable code shrinking

debug.keystore

2.16 KB
Binary file not shown.

local.properties

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
storeFile=../debug.keystore
2+
storePassword=android
3+
keyAlias=androiddebugkey
4+
keyPassword=android

updateManager/build.gradle.kts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ dependencies {
4444
implementation(libs.okhttp)
4545
implementation(libs.androidx.core.ktx)
4646
implementation(libs.androidx.appcompat)
47-
implementation(libs.androidx.material3)
47+
//implementation(libs.androidx.material3)
48+
implementation(libs.androidx.material)
4849
implementation(libs.androidx.work.runtime.ktx)
4950
testImplementation(libs.junit)
5051
androidTestImplementation(libs.androidx.junit)

0 commit comments

Comments
 (0)