From b84b393903676e4bc99033cf76651cde01a7fb2a Mon Sep 17 00:00:00 2001 From: Birkir Gudjonsson Date: Fri, 8 Mar 2019 11:47:18 -0500 Subject: [PATCH] fix android builds --- android/app/build.gradle | 195 +++++++----------- android/app/src/main/AndroidManifest.xml | 1 + .../reactnativestarter/MainApplication.java | 8 - android/build.gradle | 86 -------- index.js | 2 +- 5 files changed, 79 insertions(+), 213 deletions(-) diff --git a/android/app/build.gradle b/android/app/build.gradle index 79f5dd6..dabec81 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -1,8 +1,8 @@ apply plugin: "com.android.application" exec { - commandLine './scripts/build-env.sh' - workingDir '../../' + commandLine './scripts/build-env.sh' + workingDir '../../' } apply from: project(':react-native-config').projectDir.getPath() + "/dotenv.gradle" @@ -39,145 +39,104 @@ def enableSeparateBuildPerCPUArchitecture = false def enableProguardInReleaseBuilds = false android { - compileSdkVersion 28 - - defaultConfig { - applicationId "com.ueno.reactnativestarter" - minSdkVersion 19 - targetSdkVersion 28 - versionCode 1 - versionName "1.0.0" - ndk { - abiFilters "armeabi-v7a", "x86" - } - multiDexEnabled true - missingDimensionStrategy "minReactNative", "minReactNative46" - missingDimensionStrategy "RNN.reactNativeVersion", "reactNative57_5" - testBuildType System.getProperty('testBuildType', 'debug') - testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" + compileSdkVersion 28 + + defaultConfig { + applicationId "com.ueno.reactnativestarter" + minSdkVersion 19 + targetSdkVersion 28 + versionCode 1 + versionName "1.0.0" + ndk { + abiFilters "armeabi-v7a", "x86" + } + multiDexEnabled true + missingDimensionStrategy "minReactNative", "minReactNative46" + missingDimensionStrategy "RNN.reactNativeVersion", "reactNative57_5" + testBuildType System.getProperty('testBuildType', 'debug') + testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } signingConfigs { - release { - storeFile file("keystore.jks") - storePassword "12345678" - keyAlias "key0" - keyPassword "12345678" - } + release { + storeFile file("keystore.jks") + storePassword "12345678" + keyAlias "key0" + keyPassword "12345678" + } } compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 } splits { - abi { - reset() - enable enableSeparateBuildPerCPUArchitecture - universalApk false // If true, also generate a universal APK - include "armeabi-v7a", "x86" - } + abi { + reset() + enable enableSeparateBuildPerCPUArchitecture + universalApk false // If true, also generate a universal APK + include "armeabi-v7a", "x86" + } } buildTypes { - release { - minifyEnabled enableProguardInReleaseBuilds - proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro" - signingConfig signingConfigs.release - matchingFallbacks = ['release'] - } - debug { - matchingFallbacks = ['debug'] - } + release { + minifyEnabled enableProguardInReleaseBuilds + proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro" + signingConfig signingConfigs.release + matchingFallbacks = ['release'] + } + debug { + matchingFallbacks = ['debug'] + } } 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] - 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 - } + 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] + 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 } + } } - packagingOptions { - exclude 'META-INF/proguard/androidx-annotations.pro' - exclude 'META-INF/-no-jdk.kotlin_module' - exclude 'META-INF/DEPENDENCIES' - exclude 'META-INF/NOTICE' - exclude 'META-INF/LICENSE' - exclude 'META-INF/LICENSE.txt' - exclude 'META-INF/NOTICE.txt' + exclude 'META-INF/proguard/androidx-annotations.pro' + exclude 'META-INF/-no-jdk.kotlin_module' + exclude 'META-INF/DEPENDENCIES' + exclude 'META-INF/NOTICE' + exclude 'META-INF/LICENSE' + exclude 'META-INF/LICENSE.txt' + exclude 'META-INF/NOTICE.txt' } } dependencies { - implementation "com.facebook.react:react-native:+" - implementation fileTree(dir: "libs", include: ["*.jar"]) - - implementation project(':react-native-version-number') - implementation project(':react-native-sentry') - implementation project(':react-native-navigation') - implementation project(':react-native-code-push') - implementation project(':react-native-config') - implementation(project(':react-native-firebase')) { - transitive = false - } - - implementation 'com.android.support:design:27.1.1' - - androidTestImplementation project(path: ":detox") - androidTestImplementation 'junit:junit:4.12' - androidTestImplementation 'com.android.support.test:runner:1.0.2' - androidTestImplementation 'com.android.support.test:rules:1.0.2' + implementation "com.facebook.react:react-native:+" + implementation 'com.android.support:design:27.1.1' + + implementation fileTree(dir: "libs", include: ["*.jar"]) + + implementation project(':react-native-version-number') + implementation project(':react-native-sentry') + implementation project(':react-native-navigation') + implementation project(':react-native-code-push') + implementation project(':react-native-config') + implementation(project(':react-native-firebase')) { + transitive = false + } + + androidTestImplementation project(path: ":detox") + androidTestImplementation 'junit:junit:4.12' + androidTestImplementation 'com.android.support.test:runner:1.0.2' + androidTestImplementation 'com.android.support.test:rules:1.0.2' } // 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.compile - into 'libs' + from configurations.compile + into 'libs' } apply plugin: 'com.google.gms.google-services' com.google.gms.googleservices.GoogleServicesPlugin.config.disableVersionCheck = true - -// dependencies { -// // Local implementations -// implementation fileTree(dir: "libs", include: ["*.jar"]) - -// // Ueno RNS: Add your modules here -// implementation project(':react-native-version-number') -// implementation project(':react-native-sentry') -// implementation project(':react-native-navigation') -// implementation project(':react-native-code-push') -// implementation project(':react-native-config') -// implementation(project(':react-native-firebase')) { -// transitive = false -// } - -// // implementation "com.google.android.gms:play-services-base:16.0.1" -// // implementation "com.google.firebase:firebase-core:16.0.1" - -// // Other implementations -// implementation "com.android.support:design:27.0.2" -// implementation "com.android.support:appcompat-v7:27.0.2" -// implementation "com.android.support:support-annotations:27.0.2" -// implementation "com.android.support:multidex:1.0.1" -// implementation "com.facebook.react:react-native:+" - -// // Test implementations -// androidTestImplementation project(":detox") -// androidTestImplementation 'junit:junit:4.12' -// androidTestImplementation 'com.android.support.test:runner:1.0.2' -// androidTestImplementation 'com.android.support.test:rules:1.0.2' -// } - -// // 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.compile -// into 'libs' -// } - -// apply plugin: 'com.google.gms.google-services' diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 48dff89..3a15b12 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -8,6 +8,7 @@ diff --git a/android/app/src/main/java/com/ueno/reactnativestarter/MainApplication.java b/android/app/src/main/java/com/ueno/reactnativestarter/MainApplication.java index 159fd0c..7f6adb1 100644 --- a/android/app/src/main/java/com/ueno/reactnativestarter/MainApplication.java +++ b/android/app/src/main/java/com/ueno/reactnativestarter/MainApplication.java @@ -1,8 +1,6 @@ package com.ueno.reactnativestarter; import android.app.Application; -// import android.content.Context; -// import android.support.multidex.MultiDex; import java.util.Arrays; import java.util.List; @@ -29,12 +27,6 @@ public class MainApplication extends NavigationApplication { - // @Override - // protected void attachBaseContext(Context base) { - // super.attachBaseContext(base); - // MultiDex.install(this); - // } - @Override protected ReactGateway createReactGateway() { ReactNativeHost host = new NavigationReactNativeHost(this, isDebug(), createAdditionalReactPackages()) { diff --git a/android/build.gradle b/android/build.gradle index 1ff2a0e..f7f7f1c 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -88,89 +88,3 @@ task wrapper(type: Wrapper) { gradleVersion = '4.10.2' distributionUrl = distributionUrl.replace("bin", "all") } - -// // Top-level build file where you can add configuration options common to all sub-projects/modules. - -// project.ext { -// minSdkVersion = 21 -// compileSdkVersion = 27 -// targetSdkVersion = 27 -// buildToolsVersion = '28.0.3' -// } - -// buildscript { -// ext.kotlinVersion = '1.3.0' - -// repositories { -// google() -// jcenter() -// mavenLocal() -// mavenCentral() -// } -// dependencies { -// classpath 'com.android.tools.build:gradle:3.3.0' -// classpath 'com.google.gms:google-services:4.2.0' -// classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion" -// classpath 'com.google.firebase:firebase-plugins:1.1.5' - -// // NOTE: Do not place your application dependencies here; they belong -// // in the individual module build.gradle files -// } -// } - -// allprojects { -// repositories { -// google() -// jcenter() -// mavenLocal() -// mavenCentral() -// maven { -// // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm -// url "$rootDir/../node_modules/react-native/android" -// } -// maven { -// // Local Maven repo containing AARs with JSC library built for Android -// url "$rootDir/../node_modules/jsc-android/dist" -// } -// maven { -// url 'https://maven.google.com' -// } -// maven { -// url 'https://jitpack.io' -// } -// } -// } - -// subprojects { -// task listAllDependencies(type: DependencyReportTask) {} - -// ext { -// minSdk = 21 -// targetSdk = 27 -// compileSdk = 27 -// buildTools = "28.0.3" -// } - -// afterEvaluate { project -> -// if (!project.name.equalsIgnoreCase("app") && project.hasProperty("android")) { -// android { -// compileSdkVersion compileSdk -// buildToolsVersion buildTools -// defaultConfig { -// minSdkVersion minSdk -// targetSdkVersion targetSdk -// } -// variantFilter { variant -> -// def names = variant.flavors*.name -// if (names.contains("minReactNative44")) { -// setIgnore(true) -// } - -// if (names.contains("reactNative51") || names.contains("reactNative55") || names.contains("reactNative57")) { -// setIgnore(true) -// } -// } -// } -// } -// } -// } diff --git a/index.js b/index.js index 35aaefb..62afb72 100644 --- a/index.js +++ b/index.js @@ -1 +1 @@ -// require('./src/index.ts'); +require('./src/index.ts');