diff --git a/android/build.gradle b/android/build.gradle index cdbdbf3..c2382c9 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -1,70 +1,68 @@ -buildscript { - repositories { - jcenter() - google() - } - dependencies { - classpath "com.android.tools.build:gradle:3.4.0" - } -} - -apply plugin: "com.android.library" - def safeExtGet(prop, fallback) { rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback } -def _excludeAppGlideModule = safeExtGet("excludeAppGlideModule", false) -def _buildToolsVersion = safeExtGet("buildToolsVersion", "28.0.3") -def _compileSdkVersion = safeExtGet("compileSdkVersion", 28) -def _glideVersion = safeExtGet("glideVersion", "4.11.0") -def _minSdkVersion = safeExtGet("minSdkVersion", 16) -def _reactNativeVersion = safeExtGet("reactNative", "+") -def _targetSdkVersion = safeExtGet("targetSdkVersion", 28) +buildscript { + // The Android Gradle plugin is only required when opening the android folder stand-alone. + // This avoids unnecessary downloads and potential conflicts when the library is included as a + // module dependency in an application project. + if (project == rootProject) { + repositories { + google() + jcenter() + } + dependencies { + classpath 'com.android.tools.build:gradle:3.5.3' + } + } +} + +apply plugin: 'com.android.library' android { - compileSdkVersion _compileSdkVersion - buildToolsVersion _buildToolsVersion - + compileSdkVersion safeExtGet('compileSdkVersion', 28) + buildToolsVersion safeExtGet('buildToolsVersion', '28.0.3') + defaultConfig { + minSdkVersion safeExtGet('minSdkVersion', 16) + targetSdkVersion safeExtGet('targetSdkVersion', 28) + versionCode 1 + versionName "1.0" + } sourceSets { main { java { - if (_excludeAppGlideModule) { + if (safeExtGet('excludeAppGlideModule', false)) { srcDir "src" exclude "**/FastImageGlideModule.java" } } } } - - defaultConfig { - minSdkVersion _minSdkVersion - targetSdkVersion _targetSdkVersion - versionCode 1 - versionName "1.0" - } lintOptions { abortOnError false } } repositories { - mavenCentral() - google() + mavenLocal() maven { - url "https://maven.google.com" + // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm + url "$rootDir/../node_modules/react-native/android" } + maven { + // Android JSC is installed from npm + url "$rootDir/../node_modules/jsc-android/dist" + } + google() + jcenter() } +def glideVersion = safeExtGet('glideVersion', '4.11.0') + dependencies { //noinspection GradleDynamicVersion - implementation "com.facebook.react:react-native:${_reactNativeVersion}" - implementation "androidx.core:core:1.0.0" - implementation "androidx.appcompat:appcompat:1.0.0" - implementation "androidx.annotation:annotation:1.0.0" - implementation("com.github.bumptech.glide:glide:${_glideVersion}") - implementation("com.github.bumptech.glide:annotations:${_glideVersion}") - annotationProcessor 'com.android.support:support-annotations:28.0.0-alpha3' - annotationProcessor "com.github.bumptech.glide:compiler:${_glideVersion}" - implementation("com.github.bumptech.glide:okhttp3-integration:${_glideVersion}") + implementation 'com.facebook.react:react-native:+' // From node_modules + implementation "com.github.bumptech.glide:glide:${glideVersion}" + implementation "com.github.bumptech.glide:okhttp3-integration:${glideVersion}" + annotationProcessor "com.github.bumptech.glide:compiler:${glideVersion}" } diff --git a/android/src/main/java/com/dylanvann/fastimage/FastImageViewWithUrl.java b/android/src/main/java/com/dylanvann/fastimage/FastImageViewWithUrl.java index 0b74d92..d0af705 100644 --- a/android/src/main/java/com/dylanvann/fastimage/FastImageViewWithUrl.java +++ b/android/src/main/java/com/dylanvann/fastimage/FastImageViewWithUrl.java @@ -1,11 +1,12 @@ package com.dylanvann.fastimage; import android.content.Context; -import android.widget.ImageView; + +import androidx.appcompat.widget.AppCompatImageView; import com.bumptech.glide.load.model.GlideUrl; -class FastImageViewWithUrl extends ImageView { +class FastImageViewWithUrl extends AppCompatImageView { public GlideUrl glideUrl; public FastImageViewWithUrl(Context context) {