Last active
August 15, 2023 04:11
-
-
Save engalar/ba065c94fcceaa425185c4c4788f335f to your computer and use it in GitHub Desktop.
native-template\android\build.gradle
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- native-template\android\app\src\main\AndroidManifest.xml --> | |
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:tools="http://schemas.android.com/tools" | |
package="com.mendix.nativetemplate"> | |
<!-- Remove the next line after update react-native-inappbrowser--> | |
<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES" tools:node="remove" | |
tools:ignore="QueryAllPackagesPermission"/> | |
<uses-permission android:name="android.permission.INTERNET" /> | |
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" /> | |
<uses-permission android:name="android.permission.READ_PHONE_STATE" /> | |
<uses-permission android:name="android.permission.CAMERA" /> | |
<uses-permission android:name="android.permission.RECORD_AUDIO" /> | |
<uses-permission android:name="android.permission.USE_FINGERPRINT" /> | |
<uses-permission android:name="android.permission.BLUETOOTH" android:maxSdkVersion="30" /> | |
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" android:maxSdkVersion="30" /> | |
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" /> | |
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" /> | |
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /> | |
<uses-permission android:name="android.permission.VIBRATE" /> | |
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> | |
<!-- Required for scheduling local notifications --> | |
<uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM" /> | |
<!-- Mark the following features as required to filter out devices missing these features. See: | |
https://developer.android.com/guide/topics/manifest/uses-feature-element --> | |
<uses-feature android:name="android.hardware.camera" android:required="false" /> | |
<uses-feature android:name="android.hardware.bluetooth_le" android:required="false" /> | |
<uses-feature android:name="android.hardware.nfc" android:required="false" /> | |
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> | |
<uses-permission android:name="android.permission.RECORD_AUDIO" /> | |
<queries> | |
<intent> | |
<action android:name="android.intent.action.VIEW" /> | |
<data android:scheme="https"/> | |
</intent> | |
<intent> | |
<action android:name="android.intent.action.VIEW"/> | |
<data android:scheme="tel"/> | |
</intent> | |
<intent> | |
<action android:name="android.intent.action.VIEW"/> | |
<data android:scheme="mailto"/> | |
</intent> | |
<intent> | |
<action android:name="android.intent.action.VIEW"/> | |
<data android:scheme="google.navigation"/> | |
</intent> | |
</queries> | |
<application | |
android:usesCleartextTraffic="true" | |
android:name=".MainApplication" | |
android:label="@string/app_name" | |
android:icon="@mipmap/ic_launcher" | |
android:roundIcon="@mipmap/ic_launcher_round" | |
android:allowBackup="false" | |
android:largeHeap="true" | |
android:theme="@style/AppTheme" | |
android:requestLegacyExternalStorage="true"> | |
<activity | |
android:name="com.mendix.nativetemplate.MainActivity" | |
android:label="@string/app_name" | |
android:screenOrientation="portrait" | |
android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode" | |
android:windowSoftInputMode="adjustPan" | |
android:exported="true"> | |
<intent-filter> | |
<action android:name="android.intent.action.MAIN" /> | |
<category android:name="android.intent.category.LAUNCHER" /> | |
</intent-filter> | |
</activity> | |
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" /> | |
<meta-data | |
android:name="com.google.android.geo.API_KEY" | |
android:value="" /> | |
<meta-data | |
android:name="pdftron_license_key" | |
android:value="${pdftronLicenseKey}" /> | |
</application> | |
</manifest> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// native-template\android\app\build.gradle | |
apply plugin: "com.android.application" | |
apply plugin: "kotlin-android" | |
import com.android.build.OutputFile | |
project.ext.react = [ | |
bundleForVariant: { def variant -> false }, | |
enableHermes : false // clean and rebuild if changing | |
] | |
apply from: file("../../node_modules/react-native/react.gradle") | |
/** | |
* Set this to true to create two separate APKs instead of one: | |
* - An APK that only works on ARM devices | |
* - An APK that only works on x86 devices | |
* The advantage is the size of the APK is reduced by about 4MB. | |
* Upload all the APKs to the Play Store and people will download | |
* the correct one based on the CPU architecture of their device. | |
*/ | |
def enableSeparateBuildPerCPUArchitecture = false | |
/** | |
* Run Proguard to shrink the Java bytecode in release builds. | |
*/ | |
def enableProguardInReleaseBuilds = false | |
/** | |
* The preferred build flavor of JavaScriptCore. | |
* | |
* For example, to use the international variant, you can use: | |
* `def jscFlavor = "org.webkit:android-jsc-intl:+"` | |
* | |
* The international variant includes ICU i18n library and necessary data | |
* allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that | |
* give correct results when using with locales other than en-US. Note that | |
* this variant is about 6MiB larger per architecture than default. | |
*/ | |
def jscFlavor = "org.webkit:android-jsc:+" | |
/** | |
* Whether to enable the Hermes VM. | |
* | |
* This should be set on project.ext.react and mirrored here. If it is not set | |
* on project.ext.react, JavaScript will not be compiled to Hermes Bytecode | |
* and the benefits of using Hermes will therefore be sharply reduced. | |
*/ | |
def enableHermes = project.ext.react.get("enableHermes", false); | |
android { | |
signingConfigs { | |
temp { | |
storeFile file('temp-release-key.jks') | |
storePassword 'mypass' | |
keyAlias 'temp' | |
keyPassword 'mypass' | |
} | |
} | |
// We use NDK 23 which has both M1 support and is the side-by-side NDK version from AGP. | |
ndkVersion = "23.1.7779620" | |
compileSdkVersion rootProject.ext.compileSdkVersion | |
compileOptions { | |
sourceCompatibility JavaVersion.VERSION_11 | |
targetCompatibility JavaVersion.VERSION_11 | |
} | |
namespace "com.mendix.nativetemplate" | |
defaultConfig { | |
multiDexEnabled true//pdftron | |
manifestPlaceholders = [pdftronLicenseKey:PDFTRON_LICENSE_KEY]//pdftron | |
applicationId "com.mendix.nativetemplate" | |
minSdkVersion rootProject.ext.minSdkVersion | |
targetSdkVersion rootProject.ext.targetSdkVersion | |
missingDimensionStrategy "react-native-camera", "general" | |
versionCode 1 | |
versionName "1.0" | |
testBuildType System.getProperty("testBuildType", "debug") | |
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" | |
resValue "string", "CODE_PUSH_APK_BUILD_TIME", String.format("\"%d\"", System.currentTimeMillis()) | |
} | |
splits { | |
abi { | |
reset() | |
enable enableSeparateBuildPerCPUArchitecture | |
universalApk false // If true, also generate a universal APK | |
include "armeabi-v7a", "x86", "arm64-v8a", "x86_64" | |
} | |
} | |
flavorDimensions "mode" | |
productFlavors { | |
appstore { | |
dimension "mode" | |
} | |
dev { | |
dimension "mode" | |
applicationIdSuffix ".developerapp" | |
versionNameSuffix "-developerApp" | |
} | |
} | |
buildTypes { | |
debug { | |
signingConfig signingConfigs.temp | |
} | |
release { | |
minifyEnabled enableProguardInReleaseBuilds | |
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro" | |
} | |
} | |
// applicationVariants are e.g. debug, release | |
applicationVariants.all { variant -> | |
variant.outputs.each { output -> | |
// For each separate APK per architecture, set a unique version code as described here: | |
// http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits | |
def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4] | |
def abi = output.getFilter(OutputFile.ABI) | |
if (abi != null) { // null for the universal-debug, universal-release variants | |
output.versionCodeOverride = | |
versionCodes.get(abi) * 1048576 + defaultConfig.versionCode | |
} | |
} | |
} | |
buildFeatures { | |
viewBinding true | |
} | |
packagingOptions { | |
pickFirst "**/libjsc.so" | |
pickFirst "**/libc++_shared.so" | |
} | |
} | |
dependencies { | |
implementation "androidx.multidex:multidex:2.0.1"//pdftron | |
implementation "androidx.core:core-ktx:1.3.2" | |
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" | |
implementation "com.facebook.react:react-native:+" // From node_modules | |
// Flipper debugger | |
debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") { | |
exclude group: "com.facebook.fbjni" | |
} | |
debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") { | |
exclude group: "com.facebook.flipper" | |
exclude group: "com.squareup.okhttp3", module: "okhttp" | |
} | |
debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") { | |
exclude group: "com.facebook.flipper" | |
} | |
// Javascript engine | |
if (enableHermes) { | |
def hermesPath = "../../node_modules/hermes-engine/android/"; | |
implementation files(hermesPath + "hermes-debug.aar") | |
} else { | |
implementation jscFlavor | |
} | |
implementation project(":react-native-splash-screen") | |
implementation project(":react-native-code-push") | |
implementation project(":mendixnative-release") | |
implementation fileTree(dir: "libs", include: ["*.jar"]) | |
implementation "org.webkit:android-jsc:r245459" | |
// Explicit add okhttp | |
implementation("com.squareup.okhttp3:okhttp:4.9.1") | |
implementation("com.squareup.okhttp3:okhttp-urlconnection:4.9.1") | |
// Required by MendixNative | |
implementation("com.fasterxml.jackson.core:jackson-core:2.11.3") | |
implementation("com.fasterxml.jackson.core:jackson-databind:2.11.3") | |
implementation("com.fasterxml.jackson.core:jackson-annotations:2.11.3") | |
implementation "androidx.security:security-crypto:1.1.0-alpha03" | |
// Required for Custom Dev Apps | |
devImplementation "androidx.constraintlayout:constraintlayout:2.0.4" | |
devImplementation "me.dm7.barcodescanner:zxing:1.9.8" | |
androidTestImplementation("com.wix:detox:+") { transitive = true } | |
androidTestImplementation "junit:junit:4.12" | |
} | |
configurations.all { | |
resolutionStrategy { | |
force "androidx.annotation:annotation:1.1.0" | |
} | |
} | |
// Run this once to be able to run the application with BUCK | |
// puts all compile dependencies into folder libs for BUCK to use | |
task copyDownloadableDepsToLibs(type: Copy) { | |
from configurations.implementation | |
into "libs" | |
} | |
apply from: file("../../node_modules/@mendix/native/android/mendix.gradle"); applyMendixGradle(project) | |
apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project) | |
apply from: "../../node_modules/react-native-vector-icons/fonts.gradle" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// native-template\android\build.gradle | |
// Top-level build file where you can add configuration options common to all sub-projects/modules. | |
buildscript { | |
ext { | |
buildToolsVersion = "31.0.0" | |
minSdkVersion = 21 | |
compileSdkVersion = 31 | |
targetSdkVersion = 31 | |
kotlin_version = "1.7.21" | |
excludeAppGlideModule = true | |
androidx_lifecycle_version = "2.3.1" | |
playServicesVersion = "18+" | |
firebaseMessagingVersion = "21.0.0" | |
androidXCore = "1.6.0" | |
androidXBrowser = "1.2.0" | |
} | |
repositories { | |
maven { | |
url "https://maven.aliyun.com/repository/public" | |
} | |
google() | |
mavenCentral() | |
maven { | |
url "https://maven.aliyun.com/repository/public" | |
} | |
maven { | |
url "https://packages.rnd.mendix.com/jcenter" | |
} | |
} | |
dependencies { | |
classpath "com.android.tools.build:gradle:7.2.1" | |
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" | |
apply from: file("../node_modules/@mendix/native/android/mendix.gradle"); applyMendixClassPaths(project) | |
// NOTE: Do not place your application dependencies here; they belong | |
// in the individual module build.gradle files | |
} | |
} | |
allprojects { | |
repositories { | |
all { repo -> | |
println repo.url.toString() | |
if (repo.url.toString().contains("jcenter.bintray.com") || repo.url.toString().contains("jitpack.io")) { | |
project.logger.warn "Repository ${repo.url} removed." | |
remove repo | |
google() | |
mavenCentral() | |
} | |
} | |
exclusiveContent { | |
filter { | |
includeGroup "com.facebook.react" | |
} | |
forRepository { | |
maven { | |
url "$rootDir/../node_modules/react-native/android" | |
} | |
} | |
} | |
maven { | |
url "$rootDir/../node_modules/react-native/android" | |
} | |
maven { | |
url "$rootDir/../node_modules/jsc-android/dist" | |
} | |
maven { | |
url "$rootDir/../node_modules/detox/Detox-android" | |
} | |
maven { | |
url "https://maven.aliyun.com/repository/public" | |
} | |
google() | |
mavenCentral { | |
content { | |
excludeGroup("com.facebook.react") | |
} | |
} | |
maven { | |
url "https://maven.fabric.io/repository/public" | |
} | |
maven { url "https://packages.rnd.mendix.com/jcenter" } | |
maven { url "https://www.jitpack.io" } | |
maven { | |
url "https://maven.scijava.org/content/repositories/public/" | |
} | |
maven { | |
url "https://maven.scijava.org/content/repositories/jitpack/" | |
} | |
maven { | |
url "https://maven.scijava.org/content/repositories/jcenter/" | |
} | |
} | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# native-template\android\gradle.properties | |
# Project-wide Gradle settings. | |
# IDE (e.g. Android Studio) users: | |
# Gradle settings configured through the IDE *will override* | |
# any settings specified in this file. | |
# For more details on how to configure your build environment visit | |
# http://www.gradle.org/docs/current/userguide/build_environment.html | |
# Specifies the JVM arguments used for the daemon process. | |
# The setting is particularly useful for tweaking memory settings. | |
# Default value: -Xmx10248m -XX:MaxPermSize=256m | |
org.gradle.jvmargs=-Xmx4608m -XX:MaxPermSize=1024m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 | |
# When configured, Gradle will run in incubating parallel mode. | |
# This option should only be used with decoupled projects. More details, visit | |
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects | |
# org.gradle.parallel=true | |
android.useAndroidX=true | |
android.enableJetifier=true | |
org.gradle.configureondemand=true | |
android.disableResourceValidation=true | |
FLIPPER_VERSION=0.125.0 | |
android.suppressUnsupportedCompileSdk=33 | |
#pdftron | |
PDFTRON_LICENSE_KEY= |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// native-template\android\app\src\main\java\com\mendix\nativetemplate\MainApplication.java | |
package com.mendix.nativetemplate; | |
import android.app.Activity; | |
import android.content.Context; | |
import androidx.annotation.NonNull; | |
import com.facebook.react.PackageList; | |
import com.facebook.react.ReactPackage; | |
import com.mendix.mendixnative.MendixReactApplication; | |
import com.mendix.mendixnative.react.splash.MendixSplashScreenPresenter; | |
import com.microsoft.codepush.react.CodePush; | |
import androidx.multidex.MultiDex; | |
import org.devio.rn.splashscreen.SplashScreen; | |
import java.util.List; | |
public class MainApplication extends MendixReactApplication { | |
@Override | |
protected void attachBaseContext(Context base) { | |
super.attachBaseContext(base); | |
// 如果需要使用MultiDex来支持多dex文件,可以在此初始化 | |
MultiDex.install(this); | |
} | |
@Override | |
public boolean getUseDeveloperSupport() { | |
return false; | |
} | |
@Override | |
public List<ReactPackage> getPackages() { | |
List<ReactPackage> packages = new PackageList(this).getPackages(); | |
packages.addAll(new MendixPackageList(this).getPackages()); | |
// Packages that cannot be autolinked yet can be added manually here, for example: | |
// packages.add(new MyReactNativePackage()); | |
packages.add(new CodePush(getCodePushKey(), getApplicationContext(), BuildConfig.DEBUG)); | |
return packages; | |
} | |
@Override | |
public MendixSplashScreenPresenter createSplashScreenPresenter() { | |
return new MendixSplashScreenPresenter() { | |
@Override | |
public void show(@NonNull Activity activity) { | |
hide(activity); | |
SplashScreen.show(activity, true); | |
} | |
@Override | |
public void hide(@NonNull Activity activity) { | |
SplashScreen.hide(activity); | |
} | |
}; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment