feat(android): add foss flavor build without gms services (#3666)

This commit is contained in:
Huang Xin
2026-03-28 12:36:09 +08:00
committed by GitHub
parent 966f5e2acd
commit bbfc82e50d
6 changed files with 48 additions and 9 deletions
@@ -38,8 +38,9 @@ if grep -q 'MANAGE_EXTERNAL_STORAGE' "$MANIFEST"; then
fi
fi
echo "🚀 Running: pnpm tauri android build"
# pnpm tauri android build --config src-tauri/tauri.playstore.conf.json
source .env.google-play.local
echo "🚀 Running: pnpm tauri android build (googleplay flavor)"
ORG_GRADLE_PROJECT_storeFlavor=googleplay pnpm tauri android build --config src-tauri/tauri.playstore.conf.json
# --- ADD PERMISSION BACK AFTER BUILD ---
if ! grep -q 'REQUEST_INSTALL_PACKAGES' "$MANIFEST"; then
@@ -56,7 +57,6 @@ if ! grep -q 'MANAGE_EXTERNAL_STORAGE' "$MANIFEST"; then
" "$MANIFEST"
fi
source .env.google-play.local
if [[ -z "$GOOGLE_PLAY_JSON_KEY_FILE" ]]; then
echo "❌ GOOGLE_PLAY_JSON_KEY_FILE is not set"
exit 1
@@ -29,6 +29,8 @@ android {
targetSdk = 36
versionCode = tauriProperties.getProperty("tauri.android.versionCode", "1").toInt()
versionName = tauriProperties.getProperty("tauri.android.versionName", "1.0")
val storeFlavor = project.findProperty("storeFlavor")?.toString() ?: "foss"
missingDimensionStrategy("store", storeFlavor)
}
signingConfigs {
if (keystorePropertiesFile.exists()) {
@@ -30,11 +30,6 @@ class MainActivity : TauriActivity(), KeyDownInterceptor {
override fun onWebViewCreate(webView: WebView) {
wv = webView
// Disable native long-click on the WebView to prevent the system image context menu.
// On Android 8.0 (Oreo), the native image context menu can freeze the entire touch system,
// requiring a forced reboot. Text selection still works as it's handled by WebView internally.
webView.isLongClickable = false
webView.setOnLongClickListener { true }
}
private val keyEventMap = mapOf(
@@ -30,10 +30,21 @@ android {
kotlinOptions {
jvmTarget = "1.8"
}
flavorDimensions += "store"
productFlavors {
create("foss") {
dimension = "store"
}
create("googleplay") {
dimension = "store"
}
}
}
dependencies {
implementation("com.android.billingclient:billing-ktx:7.1.1")
"googleplayImplementation"("com.android.billingclient:billing-ktx:7.1.1")
"googleplayImplementation"("com.google.android.gms:play-services-base:18.5.0")
implementation("androidx.core:core-ktx:1.12.0")
implementation("androidx.appcompat:appcompat:1.6.1")
implementation("androidx.browser:browser:1.8.0")
@@ -0,0 +1,31 @@
package com.readest.native_bridge
import android.app.Activity
import android.util.Log
class BillingManager(private val activity: Activity) {
companion object {
private const val TAG = "BillingManager"
}
fun isBillingAvailable(): Boolean {
return false
}
fun initialize(callback: (Boolean) -> Unit) {
Log.d(TAG, "Google Play billing not available in this build")
callback(false)
}
fun fetchProducts(productIds: List<String>, callback: (List<ProductData>) -> Unit) {
callback(emptyList())
}
fun purchaseProduct(productId: String, callback: (PurchaseData?) -> Unit) {
callback(null)
}
fun restorePurchases(callback: (List<PurchaseData>) -> Unit) {
callback(emptyList())
}
}