-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
https://github.com/oblador/react-native-vector-icons/issues/1265 #1271
Conversation
oblador#1265,Android Platform, Fonts not being copied if using Android gradle plugin 4.1.0 => FIXED
This is fantastic @gulshan183 ! I was away on vacation so I am only now seeing this. I will put this on my list of things to test (a bit long, since I was away...) and hope to confirm it is working locally for me as well, to lend confidence for a merge. 🏆 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Edit after testing]: This works for me in my project in dev but not release
@oblador at least in my testing, this looks good, modulo whitespace perhaps (since it removes a code scope, should perhaps lose the related indent...)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wait! This "works" on dev builds but did not work for me on a release build, with a build flavor (i.e. release, dev flavor, so assembleDevRelease as a target example), the icons were not included in the APK
Can you please specify on which Android Gradle Plugin version you were able to reproduce this? |
In AGP 4.0.2 it works when I do a release build of my dev flavor, but when I use AGP4.1.0 with the patch it does not work. I will report back |
I'm sorry for the delay - I got very busy unexpectedly. It still works with 4.0.x so I don't think I'm doing anything wrong, it just does not work for me
// Top-level build file where you can add configuration options common to all sub-projects/modules.
import groovy.json.JsonSlurper
// This is for logging directly when needed, during development
//import groovy.util.logging.Slf4j
buildscript {
ext {
buildToolsVersion = "30.0.2"
minSdkVersion = 16
compileSdkVersion = 30
targetSdkVersion = 29 // can't change until READ_PHONE_NUMBERS is handled?
kotlinVersion = "1.4.20" // https://kotlinlang.org/releases.html
supportLibVersion = "1.3.2" // this maps to androidx.core https://developer.android.com/jetpack/androidx/releases/core
appCompatVersion = "1.2.0" // this maps to androidx.appcompat https://developer.android.com/jetpack/androidx/releases/appcompat
supportVersion = ext.supportLibVersion
googlePlayServicesLocationVersion = "17.1.0" // Play Services: https://developers.google.com/android/guides/releases
googlePlayServicesVersion = "17.5.0"
googlePlayServicesIidVersion = "17.0.0"
googlePlayServicesAuthVersion = "19.0.0"
googlePlayServicesVisionVersion = "20.1.2"
mediaCompatVersion = "1.2.0" // this maps to androidx.media
supportV4Version = "1.0.0" // this maps to androidx.legacy:legacy-support-v4
swiperefreshlayoutVersion = "1.1.0" // https://developer.android.com/jetpack/androidx/releases/swiperefreshlayout
facebookSdkVersion = "8.1.0" // https://github.com/facebook/facebook-android-sdk/releases
reactNativeVersion = "+"
firebaseBomVersion = "26.1.0"
set('react-native',[versions:[firebase:[bom:"${firebaseBomVersion}"],],])
}
repositories {
mavenLocal()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url("$rootDir/../node_modules/react-native/android")
}
google()
jcenter()
maven { url 'https://jitpack.io' }
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.1'
classpath 'com.google.gms:google-services:4.3.4'
classpath 'com.google.firebase:perf-plugin:1.3.4'
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.4.1'
//classpath 'com.getkeepsafe.dexcount:dexcount-gradle-plugin:0.8.6'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
mavenLocal()
maven {
// 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")
}
maven {
// Required for react-native-background-geolocation
url("${project(':react-native-background-geolocation-android').projectDir}/libs")
}
maven {
// Required for react-native-background-fetch
url("${project(':react-native-background-fetch').projectDir}/libs")
}
google()
// For react-native-camera
maven { url("https://jitpack.io") }
jcenter()
}
}
// Custom versioning solution to do version / build code from package.json
subprojects {
ext {
def npmVersion = getNpmVersionArray()
processedVersionName = npmVersion[0]
processedVersionCode = npmVersion[1]
}
}
static def getNpmVersion() {
def inputFile = new File("../package.json")
def packageJson = new JsonSlurper().parseText(inputFile.text)
return packageJson["version"]
}
static def getNpmVersionArray() { // versionName [0], versionCode [1]
def (mainVersion, buildStamp) = getNpmVersion().tokenize('-')
//staticLogger.info("We appear to have mainVersion / buildStamp info: " + mainVersion + " / " + buildStamp)
if (buildStamp.contains('pre')) {
//staticLogger.info("contains pre")
if (buildStamp == "pre") {
throw new GradleException("Pre-release version but no build stamp. Did you run versioning script?")
}
(buildStamp) = buildStamp.tokenize('pre')
//staticLogger.info("trimmed pre from buildStamp: " + buildStamp)
mainVersion = mainVersion + "-pre" + buildStamp
}
//staticLogger.info("Final versionName / versionCode: " + mainVersion + " / " + buildStamp)
return [mainVersion, Integer.parseInt(buildStamp)]
}
// If you need logging in gradle in a static context, you need this:
//@Slf4j
//class staticLogger {
// static def info(string) {
// log.warn string
// }
//}
apply plugin: "com.android.application"
// For react-native-firebase
apply plugin: 'com.google.gms.google-services'
apply plugin: "com.google.firebase.firebase-perf"
apply plugin: 'com.google.firebase.crashlytics'
//apply plugin: 'com.getkeepsafe.dexcount'
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",
*
* // https://reactnative.dev/docs/performance#enable-the-ram-format
* bundleCommand: "ram-bundle",
*
* // 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. * // https://facebook.github.io/react-native/docs/performance#enable-the-ram-format
* bundleCommand: "ram-bundle",
* 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 = [
//entryFile: "index.js",
bundleAssetName: "index.bundle",
bundleInDevDebug: project.hasProperty("bundleInDevDebug"),
bundleInQaDebug: project.hasProperty("bundleInQaDebug"),
bundleInStagingDebug: project.hasProperty("bundleInStagingDebug"),
bundleInProdDebug: project.hasProperty("bundleInProdDebug")
]
apply from: "../../node_modules/react-native/react.gradle"
// react-native-background-geolocation-android
Project background_geolocation = project(':react-native-background-geolocation-android')
apply from: "${background_geolocation.projectDir}/app.gradle"
/**
* Set this to true to create two separate APKs instead of one:
* - An APK that only works on ARM devices
* - An APK that only works on x86 devices
* The advantage is the size of the APK is reduced by about 4MB.
* Upload all the APKs to the Play Store and people will download
* the correct one based on the CPU architecture of their device.
*/
def enableSeparateBuildPerCPUArchitecture = true
/**
* The preferred build flavor of JavaScriptCore.
*
* For example, to use the international variant, you can use:
* `def jscFlavor = 'org.webkit:android-jsc-intl:+'`
*
* The international variant includes ICU i18n library and necessary data
* allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that
* give correct results when using with locales other than en-US. Note that
* this variant is about 6MiB larger per architecture than default.
*/
def jscFlavor = 'org.webkit:android-jsc:+'
/**
* Whether to enable the Hermes VM.
*
* This should be set on project.ext.react and mirrored here. If it is not set
* on project.ext.react, JavaScript will not be compiled to Hermes Bytecode
* and the benefits of using Hermes will therefore be sharply reduced.
*/
def enableHermes = project.ext.react.get("enableHermes", false)
/**
* Run Proguard to shrink the Java bytecode in release builds.
*/
def enableProguardInReleaseBuilds = true
def enableProguardInDebugBuilds = false
def kullkiKeyPass = System.getenv('KULLKI_ANDROID_KEY_PWD')
def kullkiStorePass = System.getenv('KULLKI_ANDROID_KEYSTORE_PWD')
def kullkiKeyAlias = 'kullki-android-key-alias'
android {
// because of firestore:
dexOptions {
javaMaxHeapSize "4g"
}
compileSdkVersion rootProject.ext.compileSdkVersion
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
defaultConfig {
applicationId "com.kullki.kscore"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode processedVersionCode + 10000 // shift above top of previous scheme
versionName "${processedVersionName}"
// because of firestore:
multiDexEnabled true
// react-native-camera:
missingDimensionStrategy 'react-native-camera', 'general'
resConfigs "en", "es" // Update this if we translate more https://developer.android.com/studio/build/shrink-code#unused-alt-resources
}
splits {
abi {
reset()
enable enableSeparateBuildPerCPUArchitecture
universalApk true // If true, also generate a universal APK
include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
}
}
signingConfigs {
devSigning {
storeFile rootProject.file("keystores/dev.keystore")
keyAlias 'debugkullkikey'; keyPassword 'NOPE'; storePassword 'NOPE'
}
qaSigning {
storeFile rootProject.file("keystores/qa.keystore")
keyAlias 'debugkullkikey'; keyPassword 'NOPE'; storePassword 'NOPE'
}
stagingSigning {
storeFile rootProject.file("keystores/staging.keystore")
keyAlias 'debugkullkikey'; keyPassword 'NOPE'; storePassword 'NOPE'
}
prodSigning {
storeFile rootProject.file("keystores/prod.keystore")
keyPassword kullkiKeyPass; storePassword kullkiStorePass; keyAlias kullkiKeyAlias
}
}
flavorDimensions "release_streams"
productFlavors {
dev {
applicationIdSuffix ".dev"
versionNameSuffix applicationIdSuffix
}
qa {
applicationIdSuffix ".test"
versionNameSuffix applicationIdSuffix
}
staging {
applicationIdSuffix ".staging"
versionNameSuffix applicationIdSuffix
}
prod {
}
}
buildTypes {
debug {
shrinkResources enableProguardInDebugBuilds
minifyEnabled enableProguardInDebugBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
proguardFiles "${background_geolocation.projectDir}/proguard-rules.pro"
signingConfig null // clear out built-in debug signing + force use signingConfig block
// Firebase requires all signatures to be globally unique, so each package has unique config
productFlavors.dev.signingConfig signingConfigs.devSigning
productFlavors.qa.signingConfig signingConfigs.qaSigning
productFlavors.staging.signingConfig signingConfigs.stagingSigning
productFlavors.prod.signingConfig signingConfigs.prodSigning
}
release {
shrinkResources enableProguardInReleaseBuilds
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
proguardFiles "${background_geolocation.projectDir}/proguard-rules.pro"
signingConfig null // clear out built-in debug signing + force use signingConfig block
// Firebase requires all signatures to be globally unique, so each package has unique config
productFlavors.dev.signingConfig signingConfigs.devSigning
productFlavors.qa.signingConfig signingConfigs.qaSigning
productFlavors.staging.signingConfig signingConfigs.stagingSigning
productFlavors.prod.signingConfig signingConfigs.prodSigning
}
}
// applicationVariants are e.g. debug, release
applicationVariants.all { variant ->
// purge debug sounds from react-native-background-geolocation-android
if (variant.buildType.name == 'release') {
// We want the same version stream for all ABIs in debug but for release we can split them
variant.outputs.each { output ->
// For each separate APK per architecture, set a unique version code as described here:
// https://developer.android.com/studio/build/configure-apk-splits.html
def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4]
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
}
}
}
}
ndkVersion "21.3.6528147"
}
dependencies {
implementation project(':react-native-calendar-events')
implementation project(':react-native-gesture-handler')
//noinspection GradleDependency https://github.com/facebook/react-native/pull/30061
implementation 'com.facebook.fresco:animated-gif:2.2.0'
implementation("androidx.appcompat:appcompat:${rootProject.ext.appCompatVersion}")
implementation("androidx.core:core:${rootProject.ext.supportLibVersion}")
implementation('androidx.fragment:fragment:1.2.5') // https://developer.android.com/jetpack/androidx/releases/fragment
implementation('androidx.vectordrawable:vectordrawable-animated:1.1.0') // https://developer.android.com/jetpack/androidx/releases/vectordrawable
implementation("androidx.swiperefreshlayout:swiperefreshlayout:${rootProject.ext.swiperefreshlayoutVersion}")
implementation("androidx.legacy:legacy-support-core-ui:${rootProject.ext.supportV4Version}")
implementation("androidx.legacy:legacy-support-core-utils:${rootProject.ext.supportV4Version}")
implementation('androidx.vectordrawable:vectordrawable:1.1.0') // https://developer.android.com/jetpack/androidx/releases/vectordrawable
implementation 'androidx.annotation:annotation:1.1.0' // https://developer.android.com/jetpack/androidx/releases/annotation
implementation 'androidx.multidex:multidex:2.0.1' // https://developer.android.com/jetpack/androidx/releases/multidex
implementation 'com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava'
implementation platform("com.google.firebase:firebase-bom:${rootProject.ext.firebaseBomVersion}")
implementation 'com.google.firebase:firebase-firestore'
implementation 'com.google.firebase:firebase-iid'
implementation "com.google.android.gms:play-services-auth:${rootProject.ext.googlePlayServicesAuthVersion}"
//noinspection GradleDynamicVersion
implementation "com.facebook.react:react-native:${rootProject.ext.reactNativeVersion}"
debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") {
exclude group:'com.facebook.fbjni'
}
debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
exclude group:'com.facebook.flipper'
exclude group:'com.squareup.okhttp3', module:'okhttp'
}
debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") {
exclude group:'com.facebook.flipper'
}
if (enableHermes) {
def hermesPath = "../../node_modules/hermes-engine/android/"
debugImplementation files(hermesPath + "hermes-debug.aar")
releaseImplementation files(hermesPath + "hermes-release.aar")
} else {
implementation jscFlavor
}
implementation fileTree(dir: "libs", include: ["*.jar"])
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xlint:deprecation"
}
}
// 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'
}
// Needed to shrink APK with react-native-vector-icons - don't include all the font files
project.ext.vectoricons = [
iconFontNames: [ 'Entypo.ttf', 'FontAwesome.ttf' ] // Name of the react-native-vector-icons fonts to copy
]
apply from: "../../node_modules/react-native-vector-icons/fonts.gradle"
// End of react-native-vector-icons stuff
// react-native 0.60+ auto-linking
apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
|
Sorry for the delayed response. I could not identify the issue you are facing. |
Superseded by #1307 |
#1265,Android Platform, Fonts not being copied if using Android gradle plugin 4.1.0 => FIXED
Tested on following versions of Android Gradle Plugin:
As of now, the creation and addition of tasks to the Task Graph were depended upon to project being evaluated while Gradle build lifecycle i.e
gradle.projectsEvaluated
. That is while the Gradle build is in the execution phase due to which the task to copy fonts was not being added to the TaskGraph(of tasks to be executed).Therefore, the listener to the project being evaluated is now removed. Now, the tasks are added to the TaskGraph while in the configuration phase, thus our
copy{}IconFonts
task can be run in the execution phase of Gradle Build.