Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build architecture specific apk #15

Merged
merged 5 commits into from
Nov 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3
with:
gradle-version: 8.10.2
gradle-version: 8.8

- name: Install dependencies
run: yarn install
Expand All @@ -39,7 +39,9 @@ jobs:
run: yarn run prebuild:android

- name: Build Debug APK
run: cd android && ./gradlew app:packageDebugUniversalApk
run: |
cd android
./gradlew app:packageDebug

- name: Upload outputs
uses: actions/upload-artifact@v4
Expand Down
51 changes: 51 additions & 0 deletions app.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
const value = (prodValue, devValue) =>
process.env.NODE_ENV === 'production' ? prodValue : devValue;

module.exports = {
expo: {
name: 'fzuhelper-app',
slug: 'fzuhelper-app',
version: '7.0.0',
orientation: 'portrait',
icon: './assets/images/icon.png',
scheme: 'fzuhelper',
userInterfaceStyle: 'automatic',
splash: {
image: './assets/images/splash.png',
resizeMode: 'contain',
backgroundColor: '#ffffff',
},
ios: {
bundleIdentifier: 'FzuHelper.FzuHelper',
buildNumber: '7.0.0',
supportsTablet: true,
},
android: {
package: value(
'com.helper.west2ol.fzuhelper',
'com.helper.west2ol.fzuhelper.dev',
),
versionCode: 700001,
},
web: {
bundler: 'metro',
output: 'static',
favicon: './assets/images/icon.png',
},
plugins: [
'expo-router',
[
'expo-build-properties',
{
android: {
useLegacyPackaging: true,
enableProguardInReleaseBuilds: true,
},
},
],
],
experiments: {
typedRoutes: true,
},
},
};
34 changes: 0 additions & 34 deletions app.json

This file was deleted.

23 changes: 21 additions & 2 deletions docs/build/android.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,25 @@ android {
}
```

## 配置不同架构的分包

修改 `android\app\build.gradle`,添加以下内容:

```diff
android {
// ...

+ splits {
+ abi {
+ reset()
+ enable true
+ universalApk true
+ include "armeabi-v7a", "arm64-v8a", "x86_64"
+ }
+ }
}
```

## 修改构建版本号

修改 `app.json` 中的 `expo.android.versionCode` 字段,每次递增 1 即可。
Expand All @@ -66,7 +85,7 @@ android {

```bash
./gradlew app:bundleRelease
./gradlew app:packageReleaseUniversalApk
./gradlew app:packageRelease
```

第一个命令会构建出一个 `aab` 文件(`android\app\build\outputs\bundle\release\app-release.aab`),用于一些应用商店的上传;第二个命令会构建出一个 `apk` 文件(`android\app\build\outputs\apk_from_bundle\release\app-release-universal.apk`),用于另外一些应用商店的上传和官网发布。
第一个命令会构建出一个 `aab` 文件(`android\app\build\outputs\bundle\release\app-release.aab`),用于一些应用商店的上传;第二个命令会构建出一些 `apk` 文件(`android\app\build\outputs\apk\release\` 目录下),用于另外一些应用商店的上传和官网发布。
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"@tailwindcss/forms": "^0.5.9",
"@tailwindcss/typography": "^0.5.15",
"expo": "~51.0.28",
"expo-build-properties": "~0.12.5",
"expo-constants": "~16.0.2",
"expo-font": "~12.0.9",
"expo-linking": "~6.3.1",
Expand Down
10 changes: 9 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2671,7 +2671,7 @@ ajv@^6.12.4:
json-schema-traverse "^0.4.1"
uri-js "^4.2.2"

ajv@^8.0.0, ajv@^8.9.0:
ajv@^8.0.0, ajv@^8.11.0, ajv@^8.9.0:
version "8.17.1"
resolved "https://registry.yarnpkg.com/ajv/-/ajv-8.17.1.tgz#37d9a5c776af6bc92d7f4f9510eba4c0a60d11a6"
integrity sha512-B/gBuNg5SiMTrPkC+A2+cW0RszwxYmn6VYxB/inlBStS5nx6xHIt/ehKRhIMhqusl7a8LjQoZnjCs5vhwxOQ1g==
Expand Down Expand Up @@ -4521,6 +4521,14 @@ expo-asset@~10.0.10:
invariant "^2.2.4"
md5-file "^3.2.3"

expo-build-properties@~0.12.5:
version "0.12.5"
resolved "https://registry.yarnpkg.com/expo-build-properties/-/expo-build-properties-0.12.5.tgz#4d6232389f00c846ba37ca5df2c0b5527c2d94ca"
integrity sha512-donC1le0PYfLKCPKRMGQoixuWuwDWCngzXSoQXUPsgHTDHQUKr8aw+lcWkTwZcItgNovcnk784I0dyfYDcxybA==
dependencies:
ajv "^8.11.0"
semver "^7.6.0"

expo-constants@~16.0.0, expo-constants@~16.0.2:
version "16.0.2"
resolved "https://registry.yarnpkg.com/expo-constants/-/expo-constants-16.0.2.tgz#eb5a1bddb7308fd8cadac8fc44decaf4784cac5e"
Expand Down