Skip to content

Commit ba97c4a

Browse files
feat. added build script
1 parent 54a6eae commit ba97c4a

7 files changed

Lines changed: 227 additions & 50 deletions

File tree

.vscode/plugins.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"plugins":["cordova-plugin-consent","admob-plus-cordova"]}

android/app/capacitor.build.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ android {
1010
apply from: "../capacitor-cordova-android-plugins/cordova.variables.gradle"
1111
dependencies {
1212

13+
implementation "com.google.android.gms:play-services-ads:20.6.0"
14+
implementation "com.google.android.ump:user-messaging-platform:1.0.0+"
1315
implementation "androidx.webkit:webkit:1.4.0"
1416
implementation "commons-net:commons-net:3.11.1"
1517
implementation "com.android.billingclient:billing:6.0.1"

package-lock.json

Lines changed: 143 additions & 41 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@
55
"description": "Acode is a code editor for android",
66
"scripts": {
77
"lang": "node ./utils/lang.js",
8-
"build": "sh scripts/gradlew-link assembleDebug",
9-
"build-debug": "sh scripts/gradlew-link assembleDebug",
10-
"build-release": "sh scripts/gradlew-link assembleRelease",
8+
"build": "sh scripts/build.sh",
119
"clean": "sh scripts/gradlew-link clean",
1210
"plugin": "sh utils/scripts/plugin.sh",
1311
"setup": "npx cap sync",
@@ -37,6 +35,11 @@
3735
"cordova-plugin-system": {},
3836
"cordova-plugin-advanced-http": {
3937
"ANDROIDBLACKLISTSECURESOCKETPROTOCOLS": "SSLv3,TLSv1"
38+
},
39+
"cordova-plugin-consent": {},
40+
"admob-plus-cordova": {
41+
"APP_ID_ANDROID": "ca-app-pub-5911839694379275~4255791238",
42+
"PLAY_SERVICES_VERSION": "21.5.0"
4043
}
4144
},
4245
"platforms": [
@@ -94,8 +97,10 @@
9497
"@capacitor/android": "^7.2.0",
9598
"@deadlyjack/ajax": "^1.2.6",
9699
"@ungap/custom-elements": "^1.3.0",
100+
"admob-plus-cordova": "1.28.0",
97101
"autosize": "^6.0.1",
98102
"cordova": "12.0.0",
103+
"cordova-plugin-consent": "2.4.0",
99104
"core-js": "^3.37.1",
100105
"crypto-js": "^4.2.0",
101106
"dompurify": "^3.2.4",
@@ -117,4 +122,4 @@
117122
"yargs": "^17.7.2"
118123
},
119124
"browserslist": "cover 100%,not android < 5"
120-
}
125+
}

readme.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ To build the APK, ensure you have Node.js, NPM, and Apache Cordova installed on
5555

5656
```shell
5757
npm install
58+
npm run sync
5859
```
5960

6061
2. Build the project:

scripts/build.sh

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
#! /bin/bash
2+
3+
set -e #exit on error
4+
5+
appFreePaid="$1"
6+
mode="$2"
7+
8+
function info(){
9+
echo -e "\e[34;1m[*] \e[37m$1\e[0m"
10+
}
11+
12+
function success(){
13+
echo -e "\e[32;1m[+] \e[37m$1\e[0m"
14+
}
15+
16+
17+
if [ -z "$mode" ]
18+
then
19+
mode="d"
20+
fi
21+
22+
if [ -z "$appFreePaid" ]
23+
then
24+
appFreePaid="paid"
25+
fi
26+
27+
info "Building app with type: $appFreePaid"
28+
info "Building app with mode: $mode"
29+
30+
31+
# AD ID
32+
AD_APP_ID="ca-app-pub-5911839694379275~4255791238"
33+
PROJECT_ROOT=$(npm prefix)
34+
35+
if [ "$appFreePaid" = "p" ] || [ "$appFreePaid" = "paid" ]; then
36+
info "Removing Admob plugins if installed"
37+
38+
if cordova plugin ls | grep -q "cordova-plugin-consent"; then
39+
cordova plugin remove cordova-plugin-consent --save
40+
fi
41+
42+
if cordova plugin ls | grep -q "admob-plus-cordova"; then
43+
cordova plugin remove admob-plus-cordova --save
44+
fi
45+
else
46+
info "Adding Admob plugins"
47+
cordova plugin add cordova-plugin-consent@2.4.0 --save
48+
cordova plugin add admob-plus-cordova@1.28.0 --save --variable APP_ID_ANDROID="${AD_APP_ID}" --variable PLAY_SERVICES_VERSION="21.5.0"
49+
fi
50+
51+
52+
if [ "$mode" = "p" ] || [ "$mode" = "prod" ]
53+
then
54+
webpack --progress --mode production
55+
node ./utils/loadStyles.js
56+
npm run sync
57+
sh "$PROJECT_ROOT"/scripts/gradlew-link assembleRelease
58+
else
59+
webpack --progress --mode development
60+
node ./utils/loadStyles.js
61+
npm run sync
62+
sh "$PROJECT_ROOT"/scripts/gradlew-link assembleDebug
63+
fi
64+
65+
success "Build finished"
66+
success "Output path: $PROJECT_ROOT/android/app/build/outputs/apk/"

0 commit comments

Comments
 (0)