-
Notifications
You must be signed in to change notification settings - Fork 2.2k
/
build.gradle
199 lines (177 loc) · 7.53 KB
/
build.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
buildscript {
repositories {
google()
jcenter()
maven {
url 'https://maven.fabric.io/public'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.0'
}
}
apply plugin: 'com.android.library'
def DEFAULT_COMPILE_SDK_VERSION = 27
def DEFAULT_BUILD_TOOLS_VERSION = "28.0.2"
def DEFAULT_TARGET_SDK_VERSION = 27
def DEFAULT_SUPPORT_LIB_VERSION = "27.1.1"
android {
compileSdkVersion rootProject.hasProperty('compileSdkVersion') ? rootProject.compileSdkVersion : DEFAULT_COMPILE_SDK_VERSION
buildToolsVersion rootProject.hasProperty('buildToolsVersion') ? rootProject.buildToolsVersion : DEFAULT_BUILD_TOOLS_VERSION
defaultConfig {
minSdkVersion 16
targetSdkVersion rootProject.hasProperty('targetSdkVersion') ? rootProject.targetSdkVersion : DEFAULT_TARGET_SDK_VERSION
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
}
}
productFlavors {
}
lintOptions {
disable 'GradleCompatible'
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
rootProject.gradle.buildFinished { buildResult ->
if (buildResult.getFailure() != null) {
//noinspection GroovyUnusedCatchParameter
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) {
}
}
}
repositories {
google()
jcenter()
def found = false
def parentDir = rootProject.projectDir
def androidSourcesName = 'React Native sources'
def androidPrebuiltBinaryName = 'React Native prebuilt binary'
1.upto(4, {
if (found) return true
parentDir = parentDir.parentFile
// Running React Native from sources locally or for ExpoKit
def androidSourcesDir = new File(
parentDir,
'node_modules/react-native'
)
// Official releases of React Native come with a prebuilt version of Android sources
// in ./android, e.g. react-native/android/**/react-native-0.57.1.aar
def androidPrebuiltBinaryDir = new File(
parentDir,
'node_modules/react-native/android'
)
if (androidPrebuiltBinaryDir.exists()) {
maven {
url androidPrebuiltBinaryDir.toString()
name androidPrebuiltBinaryName
}
println "${project.name}: using ${androidPrebuiltBinaryName} from ${androidPrebuiltBinaryDir.toString()}"
found = true
} else if (androidSourcesDir.exists()) {
maven {
url androidSourcesDir.toString()
name androidSourcesName
}
println "${project.name}: using ${androidSourcesName} from ${androidSourcesDir.toString()}"
found = true
}
})
if (!found) {
throw new GradleException(
"${project.name}: unable to locate React Native android sources or prebuilt binary. " +
"Ensure you have you installed React Native as a dependency in your project and try again."
)
}
}
def supportVersion = rootProject.hasProperty('supportLibVersion') ? rootProject.supportLibVersion : DEFAULT_SUPPORT_LIB_VERSION
dependencies {
//noinspection GradleDynamicVersion
api "com.facebook.react:react-native:+"
/* ----------------------------
* REACT NATIVE FIREBASE
* ---------------------------- */
// Required dependencies
//noinspection GradleCompatible
compileOnly "com.google.firebase:firebase-core:16.0.4"
compileOnly "com.google.android.gms:play-services-base:16.0.1"
/* -------------------------
* OPTIONAL FIREBASE SDKS
* ------------------------- */
// Ads
compileOnly('com.google.firebase:firebase-ads:15.0.1') {
// exclude `customtabs` as the support lib version is out of date
// we manually add it as a dependency below with a custom version
exclude group: 'com.android.support', module: 'customtabs'
}
// Authentication
compileOnly "com.google.firebase:firebase-auth:16.0.5"
// Analytics
compileOnly "com.google.firebase:firebase-analytics:16.0.4"
// Performance Monitoring
compileOnly "com.google.firebase:firebase-perf:16.2.0"
// Remote Config
compileOnly "com.google.firebase:firebase-config:16.1.0"
// Cloud Storage
compileOnly "com.google.firebase:firebase-storage:16.0.4"
// Invites
compileOnly "com.google.firebase:firebase-invites:16.0.4"
// Dynamic Links
compileOnly "com.google.firebase:firebase-dynamic-links:16.1.2"
// Real-time Database
compileOnly "com.google.firebase:firebase-database:16.0.4"
// Cloud Functions
compileOnly "com.google.firebase:firebase-functions:16.1.2"
// Cloud Firestore
compileOnly "com.google.firebase:firebase-firestore:17.1.2"
// Cloud Messaging / FCM
compileOnly "com.google.firebase:firebase-messaging:17.3.4"
// Crashlytics
compileOnly('com.crashlytics.sdk.android:crashlytics:2.9.5@aar') {
transitive = true
}
/* --------------------------------
* OPTIONAL SUPPORT LIBS
* -------------------------------- */
// For Firebase Ads
compileOnly "com.android.support:customtabs:$supportVersion"
// For React Native Firebase Notifications
api "com.android.support:support-v4:$supportVersion"
// For React Native Firebase Notifications
compileOnly 'me.leolin:ShortcutBadger:1.1.21@aar'
}