Skip to content

Commit 1f04c55

Browse files
friederbluemleDylanVann
authored andcommitted
fix: improve/update build.gradle
1 parent df37c4f commit 1f04c55

File tree

2 files changed

+43
-44
lines changed

2 files changed

+43
-44
lines changed

android/build.gradle

+40-42
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,68 @@
1-
buildscript {
2-
repositories {
3-
jcenter()
4-
google()
5-
}
6-
dependencies {
7-
classpath "com.android.tools.build:gradle:3.4.0"
8-
}
9-
}
10-
11-
apply plugin: "com.android.library"
12-
131
def safeExtGet(prop, fallback) {
142
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
153
}
164

17-
def _excludeAppGlideModule = safeExtGet("excludeAppGlideModule", false)
18-
def _buildToolsVersion = safeExtGet("buildToolsVersion", "28.0.3")
19-
def _compileSdkVersion = safeExtGet("compileSdkVersion", 28)
20-
def _glideVersion = safeExtGet("glideVersion", "4.11.0")
21-
def _minSdkVersion = safeExtGet("minSdkVersion", 16)
22-
def _reactNativeVersion = safeExtGet("reactNative", "+")
23-
def _targetSdkVersion = safeExtGet("targetSdkVersion", 28)
5+
buildscript {
6+
// The Android Gradle plugin is only required when opening the android folder stand-alone.
7+
// This avoids unnecessary downloads and potential conflicts when the library is included as a
8+
// module dependency in an application project.
9+
if (project == rootProject) {
10+
repositories {
11+
google()
12+
jcenter()
13+
}
14+
dependencies {
15+
classpath 'com.android.tools.build:gradle:3.5.3'
16+
}
17+
}
18+
}
19+
20+
apply plugin: 'com.android.library'
2421

2522
android {
26-
compileSdkVersion _compileSdkVersion
27-
buildToolsVersion _buildToolsVersion
28-
23+
compileSdkVersion safeExtGet('compileSdkVersion', 28)
24+
buildToolsVersion safeExtGet('buildToolsVersion', '28.0.3')
25+
defaultConfig {
26+
minSdkVersion safeExtGet('minSdkVersion', 16)
27+
targetSdkVersion safeExtGet('targetSdkVersion', 28)
28+
versionCode 1
29+
versionName "1.0"
30+
}
2931
sourceSets {
3032
main {
3133
java {
32-
if (_excludeAppGlideModule) {
34+
if (safeExtGet('excludeAppGlideModule', false)) {
3335
srcDir "src"
3436
exclude "**/FastImageGlideModule.java"
3537
}
3638
}
3739
}
3840
}
39-
40-
defaultConfig {
41-
minSdkVersion _minSdkVersion
42-
targetSdkVersion _targetSdkVersion
43-
versionCode 1
44-
versionName "1.0"
45-
}
4641
lintOptions {
4742
abortOnError false
4843
}
4944
}
5045

5146
repositories {
52-
mavenCentral()
53-
google()
47+
mavenLocal()
48+
maven {
49+
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
50+
url "$rootDir/../node_modules/react-native/android"
51+
}
5452
maven {
55-
url "https://maven.google.com"
53+
// Android JSC is installed from npm
54+
url "$rootDir/../node_modules/jsc-android/dist"
5655
}
56+
google()
57+
jcenter()
5758
}
5859

60+
def glideVersion = safeExtGet('glideVersion', '4.11.0')
61+
5962
dependencies {
6063
//noinspection GradleDynamicVersion
61-
implementation "com.facebook.react:react-native:${_reactNativeVersion}"
62-
implementation "androidx.core:core:1.0.0"
63-
implementation "androidx.appcompat:appcompat:1.0.0"
64-
implementation "androidx.annotation:annotation:1.0.0"
65-
implementation("com.github.bumptech.glide:glide:${_glideVersion}")
66-
implementation("com.github.bumptech.glide:annotations:${_glideVersion}")
67-
annotationProcessor 'com.android.support:support-annotations:28.0.0-alpha3'
68-
annotationProcessor "com.github.bumptech.glide:compiler:${_glideVersion}"
69-
implementation("com.github.bumptech.glide:okhttp3-integration:${_glideVersion}")
64+
implementation 'com.facebook.react:react-native:+' // From node_modules
65+
implementation "com.github.bumptech.glide:glide:${glideVersion}"
66+
implementation "com.github.bumptech.glide:okhttp3-integration:${glideVersion}"
67+
annotationProcessor "com.github.bumptech.glide:compiler:${glideVersion}"
7068
}

android/src/main/java/com/dylanvann/fastimage/FastImageViewWithUrl.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
package com.dylanvann.fastimage;
22

33
import android.content.Context;
4-
import android.widget.ImageView;
4+
5+
import androidx.appcompat.widget.AppCompatImageView;
56

67
import com.bumptech.glide.load.model.GlideUrl;
78

8-
class FastImageViewWithUrl extends ImageView {
9+
class FastImageViewWithUrl extends AppCompatImageView {
910
public GlideUrl glideUrl;
1011

1112
public FastImageViewWithUrl(Context context) {

0 commit comments

Comments
 (0)