Skip to content

Commit bb75f88

Browse files
committed
feat: add android build
1 parent ac61b57 commit bb75f88

File tree

58 files changed

+1460
-2
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+1460
-2
lines changed

android/.gitignore

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
# NPM renames .gitignore to .npmignore
2+
# In order to prevent that, we remove the initial "."
3+
# And the CLI then renames it
4+
5+
# Using Android gitignore template: https://github.com/github/gitignore/blob/master/Android.gitignore
6+
7+
# Built application files
8+
*.apk
9+
*.ap_
10+
*.aab
11+
12+
# Files for the ART/Dalvik VM
13+
*.dex
14+
15+
# Java class files
16+
*.class
17+
18+
# Generated files
19+
bin/
20+
gen/
21+
out/
22+
release/
23+
24+
# Gradle files
25+
.gradle/
26+
build/
27+
28+
# Local configuration file (sdk path, etc)
29+
local.properties
30+
31+
# Proguard folder generated by Eclipse
32+
proguard/
33+
34+
# Log Files
35+
*.log
36+
37+
# Android Studio Navigation editor temp files
38+
.navigation/
39+
40+
# Android Studio captures folder
41+
captures/
42+
43+
# IntelliJ
44+
*.iml
45+
.idea/workspace.xml
46+
.idea/tasks.xml
47+
.idea/gradle.xml
48+
.idea/assetWizardSettings.xml
49+
.idea/dictionaries
50+
.idea/libraries
51+
# Android Studio 3 in .gitignore file.
52+
.idea/caches
53+
.idea/modules.xml
54+
# Comment next line if keeping position of elements in Navigation Editor is relevant for you
55+
.idea/navEditor.xml
56+
57+
# Keystore files
58+
# Uncomment the following lines if you do not want to check your keystore files in.
59+
#*.jks
60+
#*.keystore
61+
62+
# External native build folder generated in Android Studio 2.2 and later
63+
.externalNativeBuild
64+
65+
# Freeline
66+
freeline.py
67+
freeline/
68+
freeline_project_description.json
69+
70+
# fastlane
71+
fastlane/report.xml
72+
fastlane/Preview.html
73+
fastlane/screenshots
74+
fastlane/test_output
75+
fastlane/readme.md
76+
77+
# Version control
78+
vcs.xml
79+
80+
# lint
81+
lint/intermediates/
82+
lint/generated/
83+
lint/outputs/
84+
lint/tmp/
85+
# lint/reports/
86+
87+
# Cordova plugins for Capacitor
88+
capacitor-cordova-android-plugins
89+
90+
# Copied web assets
91+
app/src/main/assets/public

android/app/.npmignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/build/*
2+
!/build/.npmkeep

android/app/build.gradle

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
apply plugin: 'com.android.application'
2+
3+
android {
4+
compileSdkVersion rootProject.ext.compileSdkVersion
5+
defaultConfig {
6+
applicationId "org.task_json.app"
7+
minSdkVersion rootProject.ext.minSdkVersion
8+
targetSdkVersion rootProject.ext.targetSdkVersion
9+
versionCode 1
10+
versionName "1.0"
11+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
12+
}
13+
buildTypes {
14+
release {
15+
minifyEnabled false
16+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
17+
}
18+
}
19+
}
20+
21+
repositories {
22+
flatDir{
23+
dirs '../capacitor-cordova-android-plugins/src/main/libs', 'libs'
24+
}
25+
}
26+
27+
dependencies {
28+
implementation fileTree(include: ['*.jar'], dir: 'libs')
29+
implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
30+
implementation project(':capacitor-android')
31+
testImplementation "junit:junit:$junitVersion"
32+
androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
33+
androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
34+
implementation project(':capacitor-cordova-android-plugins')
35+
}
36+
37+
apply from: 'capacitor.build.gradle'
38+
39+
try {
40+
def servicesJSON = file('google-services.json')
41+
if (servicesJSON.text) {
42+
apply plugin: 'com.google.gms.google-services'
43+
}
44+
} catch(Exception e) {
45+
logger.warn("google-services.json not found, google-services plugin not applied. Push Notifications won't work")
46+
}

android/app/capacitor.build.gradle

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// DO NOT EDIT THIS FILE! IT IS GENERATED EACH TIME "capacitor update" IS RUN
2+
3+
android {
4+
compileOptions {
5+
sourceCompatibility JavaVersion.VERSION_1_8
6+
targetCompatibility JavaVersion.VERSION_1_8
7+
}
8+
}
9+
10+
apply from: "../capacitor-cordova-android-plugins/cordova.variables.gradle"
11+
dependencies {
12+
13+
14+
}
15+
16+
17+
if (hasProperty('postBuildExtras')) {
18+
postBuildExtras()
19+
}

android/app/proguard-rules.pro

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Add project specific ProGuard rules here.
2+
# You can control the set of applied configuration files using the
3+
# proguardFiles setting in build.gradle.
4+
#
5+
# For more details, see
6+
# http://developer.android.com/guide/developing/tools/proguard.html
7+
8+
# If your project uses WebView with JS, uncomment the following
9+
# and specify the fully qualified class name to the JavaScript interface
10+
# class:
11+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12+
# public *;
13+
#}
14+
15+
# Uncomment this to preserve the line number information for
16+
# debugging stack traces.
17+
#-keepattributes SourceFile,LineNumberTable
18+
19+
# If you keep the line number information, uncomment this to
20+
# hide the original source file name.
21+
#-renamesourcefileattribute SourceFile
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package com.getcapacitor.myapp;
2+
3+
import android.content.Context;
4+
5+
import androidx.test.platform.app.InstrumentationRegistry;
6+
import androidx.test.ext.junit.runners.AndroidJUnit4;
7+
8+
import org.junit.Test;
9+
import org.junit.runner.RunWith;
10+
11+
import static org.junit.Assert.*;
12+
13+
/**
14+
* Instrumented test, which will execute on an Android device.
15+
*
16+
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
17+
*/
18+
@RunWith(AndroidJUnit4.class)
19+
public class ExampleInstrumentedTest {
20+
@Test
21+
public void useAppContext() throws Exception {
22+
// Context of the app under test.
23+
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
24+
25+
assertEquals("com.getcapacitor.app", appContext.getPackageName());
26+
}
27+
}
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="org.task_json.app">
4+
5+
<application
6+
android:allowBackup="true"
7+
android:icon="@mipmap/ic_launcher"
8+
android:label="@string/app_name"
9+
android:roundIcon="@mipmap/ic_launcher_round"
10+
android:supportsRtl="true"
11+
android:theme="@style/AppTheme">
12+
13+
<activity
14+
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|smallestScreenSize|screenLayout|uiMode"
15+
android:name="org.task_json.app.MainActivity"
16+
android:label="@string/title_activity_main"
17+
android:theme="@style/AppTheme.NoActionBarLaunch"
18+
android:launchMode="singleTask">
19+
20+
<intent-filter>
21+
<action android:name="android.intent.action.MAIN" />
22+
<category android:name="android.intent.category.LAUNCHER" />
23+
</intent-filter>
24+
25+
<intent-filter>
26+
<action android:name="android.intent.action.VIEW" />
27+
<category android:name="android.intent.category.DEFAULT" />
28+
<category android:name="android.intent.category.BROWSABLE" />
29+
<data android:scheme="@string/custom_url_scheme" />
30+
</intent-filter>
31+
32+
</activity>
33+
34+
<provider
35+
android:name="androidx.core.content.FileProvider"
36+
android:authorities="${applicationId}.fileprovider"
37+
android:exported="false"
38+
android:grantUriPermissions="true">
39+
<meta-data
40+
android:name="android.support.FILE_PROVIDER_PATHS"
41+
android:resource="@xml/file_paths"></meta-data>
42+
</provider>
43+
</application>
44+
45+
<!-- Permissions -->
46+
47+
<uses-permission android:name="android.permission.INTERNET" />
48+
<!-- Camera, Photos, input file -->
49+
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
50+
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
51+
<!-- Geolocation API -->
52+
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
53+
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
54+
<uses-feature android:name="android.hardware.location.gps" />
55+
<!-- Network API -->
56+
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
57+
<!-- Navigator.getUserMedia -->
58+
<!-- Video -->
59+
<uses-permission android:name="android.permission.CAMERA" />
60+
<!-- Audio -->
61+
<uses-permission android:name="android.permission.RECORD_AUDIO" />
62+
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS"/>
63+
</manifest>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"appId": "org.task_json.app",
3+
"appName": "task.json",
4+
"bundledWebRuntime": false,
5+
"npmClient": "npm",
6+
"webDir": "build/",
7+
"plugins": {
8+
"SplashScreen": {
9+
"launchShowDuration": 0
10+
}
11+
},
12+
"cordova": {}
13+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package org.task_json.app;
2+
3+
import android.os.Bundle;
4+
5+
import com.getcapacitor.BridgeActivity;
6+
import com.getcapacitor.Plugin;
7+
8+
import java.util.ArrayList;
9+
10+
public class MainActivity extends BridgeActivity {
11+
@Override
12+
public void onCreate(Bundle savedInstanceState) {
13+
super.onCreate(savedInstanceState);
14+
15+
// Initializes the Bridge
16+
this.init(savedInstanceState, new ArrayList<Class<? extends Plugin>>() {{
17+
// Additional plugins you've installed go here
18+
// Ex: add(TotallyAwesomePlugin.class);
19+
}});
20+
}
21+
}
7.52 KB
Loading

0 commit comments

Comments
 (0)