[android][build] added groovy code to detect duplicate dex build failures and log out a help section

[android][firebase-sdk] upgraded to 11.2.0
This commit is contained in:
Salakar 2017-08-18 21:03:44 +01:00
parent ae3e64db87
commit b088d6e683
4 changed files with 68 additions and 110 deletions

View File

@ -1,29 +1,24 @@
// START - required to allow working on this project inside Android Studio
// YES, jcenter is required twice - it somehow tricks studio into compiling deps below
// doesn't break anything anywhere else and projects using this lib work as normal
buildscript {
ext.firebaseVersion = '11.0.0'
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.2'
}
ext.firebaseVersion = '11.2.0'
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
}
}
// END
apply plugin: 'com.android.library'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
compileSdkVersion 26
buildToolsVersion "25.0.3"
defaultConfig {
minSdkVersion 16
targetSdkVersion 26
versionCode 1
versionName "1.0"
multiDexEnabled true
// multiDexEnabled true
}
buildTypes {
release {
@ -34,20 +29,51 @@ android {
}
}
// START - required to allow working on this project inside Android Studio
// YES, jcenter is required twice - it somehow tricks studio into compiling deps below
// doesn't break anything anywhere else and projects using this lib work as normal
// you'll now have code completion/validation and all the other AS goodies.
allprojects {
repositories {
jcenter()
}
repositories {
jcenter()
}
}
// END
rootProject.gradle.buildFinished { buildResult ->
if (buildResult.getFailure() != null) {
try {
String message = buildResult.getFailure().properties.get("reportableCauses").toString()
if (message.contains("com.android.dex.DexException: Multiple dex files define Lcom/google/") ||
message.contains("java.util.zip.ZipException: duplicate entry: com/google/android/gms/")) {
logger.log(LogLevel.ERROR, "")
logger.log(LogLevel.ERROR, " -----------------------------------------------------------")
logger.log(LogLevel.ERROR, "| REACT NATIVE FIREBASE |")
logger.log(LogLevel.ERROR, " ----------------------------------------------------------- ")
logger.log(LogLevel.ERROR, "| |")
logger.log(LogLevel.ERROR, "| This is a common build error when using libraries that |")
logger.log(LogLevel.ERROR, "| require google play services. |")
logger.log(LogLevel.ERROR, "| |")
logger.log(LogLevel.ERROR, "| This error occurs because different versions of google |")
logger.log(LogLevel.ERROR, "| play services or google play services modules are being |")
logger.log(LogLevel.ERROR, "| required by different libraries. |")
logger.log(LogLevel.ERROR, "| |")
logger.log(LogLevel.ERROR, "| A temporary fix would be to set: |")
logger.log(LogLevel.ERROR, "| |")
logger.log(LogLevel.ERROR, "| android { multiDexEnabled true } |")
logger.log(LogLevel.ERROR, "| |")
logger.log(LogLevel.ERROR, "| inside your build gradle, however it is recommended for |")
logger.log(LogLevel.ERROR, "| your prod build that you de-duplicate these to minimize |")
logger.log(LogLevel.ERROR, "| bundle size. |")
logger.log(LogLevel.ERROR, "| |")
logger.log(LogLevel.ERROR, "| See http://invertase.link/dupe-dex for how to do this. |")
logger.log(LogLevel.ERROR, "| |")
logger.log(LogLevel.ERROR, " ----------------------------------------------------------- ")
}
} catch (Exception exception) {}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.facebook.react:react-native:+'
compile "com.facebook.react:react-native:+" // From node_modules
compile 'me.leolin:ShortcutBadger:1.1.10@aar'
compile "com.google.android.gms:play-services-base:$firebaseVersion"
compile "com.google.firebase:firebase-core:$firebaseVersion"

View File

@ -3,74 +3,12 @@ apply plugin: "com.google.firebase.firebase-perf"
import com.android.build.OutputFile
/**
* The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets
* and bundleReleaseJsAndAssets).
* These basically call `react-native bundle` with the correct arguments during the Android build
* cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the
* bundle directly from the development server. Below you can see all the possible configurations
* and their defaults. If you decide to add a configuration block, make sure to add it before the
* `apply from: "../../node_modules/react-native/react.gradle"` line.
*
* project.ext.react = [
* // the name of the generated asset file containing your JS bundle
* bundleAssetName: "index.android.bundle",
*
* // the entry file for bundle generation
* entryFile: "index.android.js",
*
* // whether to bundle JS and assets in debug mode
* bundleInDebug: false,
*
* // whether to bundle JS and assets in release mode
* bundleInRelease: true,
*
* // whether to bundle JS and assets in another build variant (if configured).
* // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants
* // The configuration property can be in the following formats
* // 'bundleIn${productFlavor}${buildType}'
* // 'bundleIn${buildType}'
* // bundleInFreeDebug: true,
* // bundleInPaidRelease: true,
* // bundleInBeta: true,
*
* // the root of your project, i.e. where "package.json" lives
* root: "../../",
*
* // where to put the JS bundle asset in debug mode
* jsBundleDirDebug: "$buildDir/intermediates/assets/debug",
*
* // where to put the JS bundle asset in release mode
* jsBundleDirRelease: "$buildDir/intermediates/assets/release",
*
* // where to put drawable resources / React Native assets, e.g. the ones you use via
* // require('./image.png')), in debug mode
* resourcesDirDebug: "$buildDir/intermediates/res/merged/debug",
*
* // where to put drawable resources / React Native assets, e.g. the ones you use via
* // require('./image.png')), in release mode
* resourcesDirRelease: "$buildDir/intermediates/res/merged/release",
*
* // by default the gradle tasks are skipped if none of the JS files or assets change; this means
* // that we don't look at files in android/ or ios/ to determine whether the tasks are up to
* // date; if you have any other folders that you want to ignore for performance reasons (gradle
* // indexes the entire tree), add them here. Alternatively, if you have JS files in android/
* // for example, you might want to remove it from here.
* inputExcludes: ["android/**", "ios/**"],
*
* // override which node gets called and with what additional arguments
* nodeExecutableAndArgs: ["node"]
*
* // supply additional arguments to the packager
* extraPackagerArgs: []
* ]
*/
project.ext.react = [
// whether to bundle JS and assets in staging mode
bundleInDebug: true,
jsBundleDirDebug: "$buildDir/intermediates/assets/debug"
]
project.ext.react = [
// whether to bundle JS and assets in staging mode
bundleInDebug : true,
jsBundleDirDebug: "$buildDir/intermediates/assets/debug",
nodeExecutableAndArgs : ["/usr/local/bin/node"]
]
apply from: "../../node_modules/react-native/react.gradle"
apply from: "../../node_modules/react-native-vector-icons/fonts.gradle"
@ -91,13 +29,13 @@ def enableSeparateBuildPerCPUArchitecture = false
def enableProguardInReleaseBuilds = false
android {
compileSdkVersion 25
compileSdkVersion 26
buildToolsVersion '25.0.3'
defaultConfig {
applicationId "com.reactnativefirebasedemo"
minSdkVersion 16
targetSdkVersion 25
targetSdkVersion 26
versionCode 1
versionName "1.0"
ndk {
@ -133,16 +71,18 @@ android {
}
}
project.ext.firebaseVersion = '11.0.4'
project.ext.firebaseVersion = '11.2.0'
dependencies {
compile(project(':react-native-firebase')) {
transitive = false
}
// compile(project(':react-native-firebase')) {
// transitive = false
// }
compile project(':react-native-vector-icons')
compile project(':react-native-firebase')
compile fileTree(dir: "libs", include: ["*.jar"])
compile "com.google.android.gms:play-services-base:$firebaseVersion"
compile "com.google.firebase:firebase-ads:$firebaseVersion"
compile "com.google.firebase:firebase-ads:$firebaseVersion"
compile "com.google.firebase:firebase-analytics:$firebaseVersion"
compile "com.google.firebase:firebase-auth:$firebaseVersion"
compile "com.google.firebase:firebase-config:$firebaseVersion"
@ -152,7 +92,7 @@ dependencies {
compile "com.google.firebase:firebase-messaging:$firebaseVersion"
compile "com.google.firebase:firebase-perf:$firebaseVersion"
compile "com.google.firebase:firebase-storage:$firebaseVersion"
compile "com.android.support:appcompat-v7:24.0.0"
compile "com.android.support:appcompat-v7:26.0.1"
compile "com.facebook.react:react-native:+" // From node_modules
}

View File

@ -1,18 +1,13 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.reactnativefirebasedemo"
android:versionCode="1"
android:versionName="1.0">
package="com.reactnativefirebasedemo">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
<uses-permission android:name="android.permission.SYSTEM_OVERLAY_WINDOW" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-sdk
android:minSdkVersion="16"
android:targetSdkVersion="22" />
<application
android:name=".MainApplication"
android:allowBackup="true"

View File

@ -8,20 +8,17 @@ buildscript {
classpath 'com.android.tools.build:gradle:2.3.2'
classpath 'com.google.gms:google-services:3.1.0'
classpath 'com.google.firebase:firebase-plugins:1.1.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
mavenLocal()
jcenter()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
google()
}
}