Skip to content

Commit

Permalink
fix/android-build
Browse files Browse the repository at this point in the history
  • Loading branch information
jsamol authored and godenzim committed Jun 6, 2023
1 parent 775d6ed commit 0d9797a
Show file tree
Hide file tree
Showing 44 changed files with 1,479 additions and 479 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ airgap_cordova_secure_storage_deploy.pub
Thumbs.db
UserInterfaceState.xcuserstate

src/assets/libs/**/coinlib-all.js
src/assets/libs/**/*.browserify.js
src/assets/protocol_modules/

Expand Down
8 changes: 5 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,21 @@ COPY apply-diagnostic-modules.js /app
COPY fix-qrscanner-gradle.js /app
COPY patch-dependency-versions.js /app
COPY patch-coinlib.js /app
COPY copy-builtin-modules.js /app
COPY browserify-coinlib.js /app

# install dependencies
RUN npm install

# install static webserver
RUN npm install node-static -g

# browserify coin-lib
RUN npm run browserify-coinlib

# Bundle app source
COPY . /app

# browserify coin-lib
RUN npm run browserify-coinlib

# set to production
RUN export NODE_ENV=production

Expand Down
16 changes: 10 additions & 6 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'

android {
namespace "it.airgap.wallet"
compileSdkVersion project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 31
defaultConfig {
applicationId "it.airgap.wallet"
Expand All @@ -17,12 +18,15 @@ android {
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
buildFeatures {
buildConfig true
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = '11'
jvmTarget = '17'
}

flavorDimensions "repository"
Expand Down Expand Up @@ -59,8 +63,8 @@ dependencies {
implementation "androidx.coordinatorlayout:coordinatorlayout:$androidxCoordinatorLayoutVersion"
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.6.0"
implementation 'androidx.webkit:webkit:1.6.0'
implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.6.1"
implementation 'androidx.webkit:webkit:1.7.0'
implementation project(':capacitor-android')
testImplementation "junit:junit:$junitVersion"
androidTestImplementation "androidx.test:core:$androidxTestCoreVersion"
Expand All @@ -78,7 +82,7 @@ dependencies {

implementation "org.bouncycastle:bcprov-jdk15on:1.70"

implementation "androidx.javascriptengine:javascriptengine:1.0.0-alpha04"
implementation "androidx.javascriptengine:javascriptengine:1.0.0-alpha05"
implementation 'com.google.guava:listenablefuture:1.0'
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-guava:$coroutinesVersion"
}
Expand Down
6 changes: 3 additions & 3 deletions android/app/capacitor.build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

android {
compileOptions {
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}
}

Expand All @@ -22,7 +22,7 @@ dependencies {
implementation project(':capacitor-status-bar')
implementation project(':capawesome-capacitor-file-picker')
implementation "androidx.legacy:legacy-support-v4:1.0.0"
implementation "androidx.appcompat:appcompat:1.4.2"
implementation "androidx.appcompat:appcompat:1.6.1"
}
apply from: "../../node_modules/cordova-plugin-qrscanner-11/src/android/qrscanner.gradle"

Expand Down
12 changes: 7 additions & 5 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
<?xml version="1.0" encoding="utf-8" ?>
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="it.airgap.wallet">
xmlns:tools="http://schemas.android.com/tools">

<uses-sdk tools:overrideLibrary="androidx.javascriptengine" />

<uses-feature android:name="android.hardware.camera" android:required="false" />

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />

<application
android:allowBackup="false"
android:icon="@mipmap/ic_launcher"
Expand Down Expand Up @@ -56,7 +61,4 @@
<meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/file_paths" />
</provider>
</application>

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CAMERA" />
</manifest>
3 changes: 3 additions & 0 deletions android/app/src/main/assets/capacitor.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
"androidSplashResourceName": "screen"
}
},
"server": {
"androidScheme": "http"
},
"android": {
"allowMixedContent": true
}
Expand Down
6 changes: 3 additions & 3 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
ext.kotlin_version = '1.8.10'
ext.kotlin_version = '1.8.20'

repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.2.2'
classpath 'com.google.gms:google-services:4.3.14'
classpath 'com.android.tools.build:gradle:8.0.0'
classpath 'com.google.gms:google-services:4.3.15'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

// NOTE: Do not place your application dependencies here; they belong
Expand Down
4 changes: 2 additions & 2 deletions android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#Mon Oct 10 13:37:00 CEST 2022
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.2-all.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
distributionSha256Sum=e6d864e3b5bc05cc62041842b306383fc1fefcec359e70cebb1d470a6094ca82
distributionSha256Sum=47a5bfed9ef814f90f8debcbbb315e8e7c654109acd224595ea39fca95c5d4da
20 changes: 10 additions & 10 deletions android/variables.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@ ext {
minSdkVersion = 22
compileSdkVersion = 33
targetSdkVersion = 33
androidxActivityVersion = '1.4.0'
androidxAppCompatVersion = '1.4.2'
androidxBrowserVersion = '1.4.0'
androidxActivityVersion = '1.7.0'
androidxAppCompatVersion = '1.6.1'
androidxBrowserVersion = '1.5.0'
androidxCoordinatorLayoutVersion = '1.2.0'
androidxCoreVersion = '1.8.0'
androidxFragmentVersion = '1.4.1'
firebaseMessagingVersion = '23.0.5'
androidxCoreVersion = '1.10.0'
androidxFragmentVersion = '1.5.6'
firebaseMessagingVersion = '23.1.2'
junitVersion = '4.13.2'
androidxTestCoreVersion = '1.4.0'
androidxJunitVersion = '1.1.3'
androidxEspressoCoreVersion = '3.4.0'
androidxJunitVersion = '1.1.5'
androidxEspressoCoreVersion = '3.5.1'
cordovaAndroidVersion = '10.1.1'
coreSplashScreenVersion = '1.0.0-rc01'
androidxWebkitVersion = '1.4.0'
coreSplashScreenVersion = '1.0.0'
androidxWebkitVersion = '1.6.1'
}
82 changes: 82 additions & 0 deletions browserify-coinlib.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
const fs = require('fs')
const path = require('path')

const browserify = require('browserify')
const esmify = require('esmify')

const rootdir = './'
const assetsdir = path.join(rootdir, 'src/assets')
const modules = [
{
import: '../../../node_modules/@airgap/coinlib-core'
},
{
namespace: 'aeternity',
import: '../../../node_modules/@airgap/aeternity'
},
{
namespace: 'astar',
import: '../../../node_modules/@airgap/astar'
},
{
namespace: 'bitcoin',
import: '../../../node_modules/@airgap/bitcoin'
},
{
namespace: 'coreum',
import: '../../../node_modules/@airgap/coreum'
},
{
namespace: 'cosmos',
import: '../../../node_modules/@airgap/cosmos'
},
{
namespace: 'ethereum',
import: '../../../node_modules/@airgap/ethereum'
},
{
namespace: 'groestlcoin',
import: '../../../node_modules/@airgap/groestlcoin'
},
{
namespace: 'icp',
import: '../../../node_modules/@airgap/icp'
},
{
namespace: 'moonbeam',
import: '../../../node_modules/@airgap/moonbeam'
},
{
namespace: 'optimism',
import: '../../../node_modules/@airgap/optimism'
},
{
namespace: 'polkadot',
import: '../../../node_modules/@airgap/polkadot'
},
{
namespace: 'tezos',
import: '../../../node_modules/@airgap/tezos'
}
]

function browserifyModules(modules) {
const outputDir = path.join(assetsdir, `libs`)
const combinedSourceFile = 'coinlib-all.js'
const combinedSource = modules.map((module) =>
module.namespace
? `import * as ${module.namespace} from '${module.import}';\nexport { ${module.namespace} };`
: `export * from '${module.import}';`
).join('\n')

fs.mkdirSync(outputDir, { recursive: true })
fs.writeFileSync(path.join(outputDir, combinedSourceFile), combinedSource, 'utf-8')

browserify(`${outputDir}/${combinedSourceFile}`, { standalone: 'airgapCoinLib' })
.plugin(esmify)
.bundle()
.pipe(fs.createWriteStream(path.join(outputDir, 'airgap-coin-lib.browserify.js')))
}


browserifyModules(modules)
12 changes: 7 additions & 5 deletions build/android/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@ RUN apt-get update -y && apt-get install -y \
pkg-config \
libjpeg-dev \
libcairo2-dev \
openjdk-11-jdk-headless
openjdk-17-jdk-headless

ENV JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64
ENV JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64

# create app directory
RUN mkdir /app
WORKDIR /app

RUN npm install -g npm@7.7.6 @capacitor/core@3.2.5 @capacitor/android@3.2.5 @capacitor/cli@3.2.5
RUN npm install -g npm@8.19.3 @capacitor/core@5.0.4 @capacitor/android@5.0.4 @capacitor/cli@5.0.4
RUN npm cache clean -f
RUN npm install -g n
RUN n 15.14.0
RUN n 16.19.1

# Install app dependencies, using wildcard if package-lock exists
COPY package.json /app
Expand All @@ -27,9 +27,11 @@ COPY apply-diagnostic-modules.js /app
COPY fix-qrscanner-gradle.js /app
COPY patch-dependency-versions.js /app
COPY patch-coinlib.js /app
COPY copy-builtin-modules.js /app
COPY browserify-coinlib.js /app

# install dependencies
RUN npm i
RUN npm i --legacy-peer-deps

# copy capacitor configs and ionic configs
COPY capacitor.config.ts /app/capacitor.config.ts
Expand Down
13 changes: 8 additions & 5 deletions capacitor.config.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
import { CapacitorConfig } from '@capacitor/cli'

const config: CapacitorConfig = {
appId: "it.airgap.wallet",
appName: "AirGap Wallet",
appId: 'it.airgap.wallet',
appName: 'AirGap Wallet',
bundledWebRuntime: false,
webDir: "www",
webDir: 'www',
plugins: {
PushNotifications: {
presentationOptions: ["alert"]
presentationOptions: ['alert']
},
SplashScreen: {
launchAutoHide: false,
androidSplashResourceName: "screen"
androidSplashResourceName: 'screen'
}
},
server: {
androidScheme: 'http'
},
android: {
allowMixedContent: true
}
Expand Down
6 changes: 6 additions & 0 deletions copy-builtin-modules.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ const modules = [
android: 'webview'
}
},
{
path: path.join(rootdir, 'node_modules/@airgap/optimism'),
jsenv: {
android: 'webview'
}
},
{
path: path.join(rootdir, 'node_modules/@airgap/polkadot'),
jsenv: {
Expand Down
3 changes: 2 additions & 1 deletion ios/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
App/build
App/Pods
App/App/public
App/Podfile.lock
DerivedData
xcuserdata

# Cordova plugins for Capacitor
capacitor-cordova-ios-plugins



Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading

0 comments on commit 0d9797a

Please sign in to comment.