react-native-vision-camera icon indicating copy to clipboard operation
react-native-vision-camera copied to clipboard

Why everytime i run `react-native run-android` i need to download an enormous tar in `:downloadGlog` task❓

Open hkar19 opened this issue 1 year ago • 13 comments

Question

this particular task is making my build time so long and uses enormous data to download:

> Task :react-native-vision-camera:downloadGlog
Download https://github.com/google/glog/archive/v0.3.5.tar.gz
<===========--> 90% EXECUTING [1m 29s]
> IDLE
> :react-native-vision-camera:downloadBoost > boost_1_76_0.tar.gz > 7.99 MB/124.24 MB downloaded
> IDLE
> IDLE
> IDLE
> IDLE

is there any way i can mitigate this such as no need to download when i already have it in my machine?

Edit: apparently it will always download after i installed new package, and everything redownloaded again

What I tried

No response

VisionCamera Version

2.13.5

Additional information

hkar19 avatar Jul 17 '22 14:07 hkar19

Hi!

I know, that's annoying. Maybe this could be fixed with RN 0.69 as RN is included as source there? Would be great if someone could take a look that has experience with Gradle...

mrousavy avatar Jul 18 '22 08:07 mrousavy

我也遇到了和你一样的问题,查了相关资料,然后在/android/gradle.properties尾部增加了以下设置,后面构建速度快了不少

开启编译缓存

org.gradle.caching=true

构建缓存

android.enableBuildCache = true

分配更大的内存

org.gradle.jvmargs=-Xmx4g -XX:MaxMetaspaceSize=1g -Dfile.encoding=UTF-8

开启并行

org.gradle.parallel=true

守护进程

Gradle 是基于 JVM 的构建系统,JVM 的启动和初始化需要时间,开启 Gradle Daemon 守护进程可以节省这些时间

org.gradle.daemon = true

按需配置

org.gradle.configureondemand=true

xyylb avatar Jul 23 '22 01:07 xyylb

我也遇到了和你一样的问题,查了相关资料,然后在/android/gradle.properties尾部增加了以下设置,后面构建速度快了不少

开启编译缓存

org.gradle.caching=true

构建缓存

android.enableBuildCache = true

分配更大的内存

org.gradle.jvmargs=-Xmx4g -XX:MaxMetaspaceSize=1g -Dfile.encoding=UTF-8

开启并行

org.gradle.parallel=true

守护进程

Gradle 是基于 JVM 的构建系统,JVM 的启动和初始化需要时间,开启 Gradle Daemon 守护进程可以节省这些时间

org.gradle.daemon = true

按需配置

org.gradle.configureondemand=true

can you please explain in english?

i tried using google translate to understand your reply, and applied it in my gradle.

this is what i got

A problem occurred evaluating project ':app'.
> Failed to apply plugin 'com.android.internal.application'.
   > The option 'android.enableBuildCache' is deprecated.
     The current default is 'false'.
     It was removed in version 7.0 of the Android Gradle plugin.
     The Android-specific build caches were superseded by the Gradle build cache (https://docs.gradle.org/current/userguide/build_cache.html)

hkar19 avatar Jul 25 '22 05:07 hkar19

Gradle 7.0 不支持这项设置 android.enableBuildCache = true 需要删除

xyylb avatar Jul 25 '22 06:07 xyylb

Gradle 7.0 不支持这项设置 android.enableBuildCache = true 需要删除

xyylb avatar Jul 25 '22 06:07 xyylb

Gradle 7.0 不支持这项设置 android.enableBuildCache = true 需要删除

so i applied everything you suggested, but i commented on org.gradle.caching=true and android.enableBuildCache = true as both are deprecated.

my gradle task still do the dowloadBooster everytime i installed new module.

is there a workaround for Gradle 7.0?

hkar19 avatar Jul 25 '22 10:07 hkar19

Temporarily Workaround:

  • Go to node_modules/react-native-vision-camera/android/build/downloads
  • Copy all *.tar.gz to a safe folder like /home/${yourUsername}/gradleThings
  • When you install a new library and you know that gradle will download glog again, just copy them from the safe folder.
  • Gradle should found and extract them as he do always!

SectionTN avatar Aug 15 '22 13:08 SectionTN

This is really too slow to download

Tzng avatar Aug 22 '22 16:08 Tzng

Temporarily Workaround:

  • Go to node_modules/react-native-vision-camera/android/build/downloads
  • Copy all *.tar.gz to a safe folder like /home/${yourUsername}/gradleThings
  • When you install a new library and you know that gradle will download glog again, just copy them from the safe folder.
  • Gradle should found and extract them as he do always!

this workaround working for me

SectionTN avatar Aug 22 '22 16:08 SectionTN

I'm facing the same problem here. Every time I run expo run:android for the first time, the speed is so fast! However, if I need to install a native package and run the same command again, it turns so slow. I believe that they restrict the download according your IP if you run this command for several times. I tried again using other VPN IP and it runs so fast. But it's so boring to do every time you need to build your app :(

agostinhodev avatar Sep 01 '22 14:09 agostinhodev

Temporarily Workaround:

  • Go to node_modules/react-native-vision-camera/android/build/downloads
  • Copy all *.tar.gz to a safe folder like /home/${yourUsername}/gradleThings
  • When you install a new library and you know that gradle will download glog again, just copy them from the safe folder.
  • Gradle should found and extract them as he do always!

this workaround working for me

This worked for me even for react-native-reanimated Thanks @SectionTN for adding here, even it is a hack but saves a lot of time while build

mandeepsingh-byjus avatar Sep 07 '22 14:09 mandeepsingh-byjus

Temporarily Workaround:

  • Go to node_modules/react-native-vision-camera/android/build/downloads
  • Copy all *.tar.gz to a safe folder like /home/${yourUsername}/gradleThings
  • When you install a new library and you know that gradle will download glog again, just copy them from the safe folder.
  • Gradle should found and extract them as he do always!

You may also add it as a script to your package.json

For example: cp /Users/{{your username}}/projs/boost_1_76_0.tar.gz /Users/{{your username}}/projs/{{your project folder}}/node_modules/react-native-vision-camera/android/build/downloads/

Orange9000 avatar Sep 21 '22 09:09 Orange9000

I'm not familiar with scripts, but your workaround is helpful too, thanks for posting it here!

SectionTN avatar Sep 21 '22 09:09 SectionTN

Still an issue.

heydavee avatar Nov 09 '22 14:11 heydavee

@SectionTN Your hack suggestion works here out of box! Tks!

agostinhodev avatar Nov 13 '22 22:11 agostinhodev

React-native-reanimated faced the same issue (ref here). They resolved this with these code changes. Please, let us know if you're planning a new release with a fix soon to skip an additional script/patch on our app. Thanks!

josej14 avatar Dec 05 '22 16:12 josej14

Hello, this is still an issue in 2023, are we expecting an update?, is the matter being investigated?

Jaybee4real avatar Feb 01 '23 11:02 Jaybee4real

Can we look into this issue, or have a workaround. It takes 45-55 mins to run react-native run-android

jimitshah-dp avatar Feb 08 '23 12:02 jimitshah-dp

Is this being looked into?

bhavzie avatar Feb 11 '23 08:02 bhavzie

jusst remove it and it works for me 0_0

docvhcmc avatar Feb 14 '23 08:02 docvhcmc

react-native-reanimated had this problem once, they seems to fixed it in next version https://github.com/software-mansion/react-native-reanimated/issues/3523

maybe we can use their approach to fix this

vanenshi avatar Feb 24 '23 19:02 vanenshi

Temporarily Workaround:

  • Go to node_modules/react-native-vision-camera/android/build/downloads
  • Copy all *.tar.gz to a safe folder like /home/${yourUsername}/gradleThings
  • When you install a new library and you know that gradle will download glog again, just copy them from the safe folder.
  • Gradle should found and extract them as he do always!

thanks, it's working for me, i added a scripts to automate these copy operations:

change package.json scripts :

  1. android "android": "react-native run-android && chmod +x ./scripts/copy-gradle-things.sh && ./scripts/copy-gradle-things.sh run"

  2. posiinstall "postinstall": "chmod +x ./scripts/copy-gradle-things.sh && ./scripts/copy-gradle-things.sh install"

  3. add copy-gradle-things.sh


#!/bin/bash

echo "copy gralde ache files: $1"

if [ "$1" = "run" ]
then
  echo "start copy gradle cache to localfile"
  mkdir -p gradleThings/react-native-vision-camera
  cp -r ./node_modules/react-native-vision-camera/android/build/downloads/ ./gradleThings/react-native-vision-camera/
fi

if [ "$1" = "install" ]
then
  echo "start copy localfile cache to gradle"
  cp -r ./gradleThings/react-native-vision-camera/ ./node_modules/react-native-vision-camera/android/build/downloads/
fi

leiMsnow avatar Apr 21 '23 04:04 leiMsnow

This issue has been fixed by the #1306, and you can define a env: REACT_NATIVE_DOWNLOADS_DIR to change the downlaod dir to a global place so that it will not downlaod every time you run.

By the way, although the v3-rc will not have this kind of problem, but it's still in rc and will only support ios for now, think twice before you upgrade

sheltonsuen avatar Jul 13 '23 02:07 sheltonsuen

Closing as this is a stale issue - this might have been fixed with the full rewrite in VisionCamera V3 (🥳) - if not, please create a new issue.

mrousavy avatar Sep 30 '23 09:09 mrousavy