1 plugins {
2 id 'com.android.application'
3 }
4
5 def keystorePropertiesFile = rootProject.file('local.properties')
6 def keystoreProperties = new Properties()
7 if (keystorePropertiesFile.exists()) {
8 keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
9 }
10
11 android {
12 compileSdk 34
13 namespace "com.jcrguidepro.app"
14
15 defaultConfig {
16 applicationId "com.jcrguidepro.app"
17 minSdk 23
18 targetSdk 34
19 versionCode 4
20 versionName "1.3.0"
21 }
22
23 signingConfigs {
24 release {
25 if (keystoreProperties.containsKey('release.keystore')) {
26 storeFile file(keystoreProperties['release.keystore'])
27 storePassword keystoreProperties['release.keystore.password']
28 keyAlias keystoreProperties['release.key.alias']
29 keyPassword keystoreProperties['release.key.password']
30 }
31 }
32 }
33
34 buildTypes {
35 debug {
36 debuggable true
37 }
38 release {
39 minifyEnabled true
40 shrinkResources true
41 proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
42 if (keystoreProperties.containsKey('release.keystore')) {
43 signingConfig signingConfigs.release
44 }
45 }
46 }
47
48 compileOptions {
49 sourceCompatibility JavaVersion.VERSION_11
50 targetCompatibility JavaVersion.VERSION_11
51 }
52
53 lint {
54 disable "BidiSpoofing"
55 }
56 }
57
58 // Comprehensive task to copy web assets and clean up HTML for Hybrid mode
59 tasks.register('copyWebAssets', Copy) {
60 from "../../dist/public"
61 into "src/main/assets"
62 duplicatesStrategy = DuplicatesStrategy.INCLUDE
63
64 // Use an aggressive regex filter to fix paths and remove problematic code
65 filter { line ->
66 // 1. Fix absolute paths to relative
67 String result = line.replaceAll('src="/assets/', 'src="./assets/')
68 .replaceAll('href="/assets/', 'href="./assets/')
69 .replaceAll('src="/manifest.json"', 'src="./manifest.json"')
70 .replaceAll('href="/manifest.json"', 'href="./manifest.json"')
71 .replaceAll('href="/icon-', 'href="./icon-')
72 .replaceAll('src="/icon-', 'src="./icon-')
73
74 // 2. Remove 'crossorigin' attribute (often causes load failures in local WebViews)
75 result = result.replaceAll(/\bcrossorigin\b/, "")
76
77 // 3. Remove Replit development scripts entirely
78 result = result.replaceAll(/<script.*replit-dev-banner.js.*<\/script>/, "")
79
80 return result
81 }
82 }
83
84 // Ensure assets are synchronized before every build
85 preBuild.dependsOn copyWebAssets
86
87 dependencies {
88 implementation 'androidx.appcompat:appcompat:1.6.1'
89 implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
90 implementation 'androidx.webkit:webkit:1.11.0'
91 }