weird gradle warnings during react-native variant-release build - android

(using android,
openjdk-11.0.13_8
node v16.13.2
react-native 0.67.0)
i created a barebone react-native project with
npx react-native init testapp
then signed it according to official react-native documentation
then tried to create the release-variant with npx react-native run-android --variant=release
now i get BUILD SUCCESSFUL message and got apk, and it installs and works in my physical device...
BUT, i got a lot of gradle problem-warning ...here is one sample..
Task :app:processReleaseManifestForPackage Execution optimizations have been disabled for task ':app:processReleaseManifestForPackage' to
ensure correctness due to the following reasons:
Gradle detected a problem with the following location: 'D:\testapp\android\app\build\intermediates\merged_manifests\release'.
Reason: Task ':app:processReleaseManifestForPackage' uses this output
of task ':app:copyReleaseBundledJs' without declaring an explicit or
implicit dependency. This can lead to incorrect results being
produced, depending on what order the tasks are executed. Please refer
to
https://docs.gradle.org/7.2/userguide/validation_problems.html#implicit_dependency
for more details about this problem.
this same problem-warning is repeated for many other tasks!!...
NB i havent added any packages or changed any source code.. its the barebone app coming with react-native!... so how do i solve this issue?.. how to fix my settings so that this warning can be removed...
(i copied one of these tasks-names and did a text-search inside all files in my project directory to find out where its mentioned...but shockingly, its not mentioned anywhere!!!...so where are all these problem-warnings coming from? and how can we get a neat gradle build?)
this same warning is repeated in lots of lines in gradle output for other tasks too, such as:
Task :app:compressReleaseAssets
Task :app:processReleaseManifestForPackage
etc.. etc..

Related

Error on converting flutter project to APK, error files coming from AppData

So I tried every possible way and ask from different people, and I also tried updating dependencies on my project but to only possible latest version since there's a version constraint. Here's the full error
https://pastebin.com/r6ZEPURC
Script 'C:\Users\Rodrigo\flutter\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 1151
* What went wrong:
Execution failed for task ':app:compileFlutterBuildRelease'.
> Process 'command 'C:\Users\Rodrigo\flutter\flutter\bin\flutter.bat'' finished with non-zero exit value 1
How can I fix this issue? thanks.
I tried updating my dependencies and changing some parts of my code, but it still doesn't work. I was trying to build it into an APK for a few days now, but I still get the same error.
There is a known issue with the modal_bottom_sheet package conflicting with material bottom sheet. You need to follow the recommendations there to get your app to build. See: https://github.com/jamesblasco/modal_bottom_sheet/issues/328
As a general rule, it is always a good idea to check the package's GitHub repo issues section when you see errors like this.

Gradle build failing - "A problem was found with the configuration of task ':app:generateSafeArgsDebug' (type 'ArgumentsGenerationTask')."

I'm trying to open and run the android architecture components sample project here: https://github.com/android/architecture-components-samples/tree/main/GithubBrowserSample in Android Studio. One one machine I'm able to get the project built and run just fine, but on my primary machine I'm seeing a build task error:
A problem was found with the configuration of task ':app:generateSafeArgsDebug' (type 'ArgumentsGenerationTask').
> No value has been specified for property 'enableGradleWorkers'.
I've tried the version of gradle and the gradle plugin that the project seems to have been built with, as well as the latest of each. I do have "android.enableGradleWorkers=true" specified in gradle.properties.
I haven't found this message when searching around, but I often see similar-looking errors when opening projects from different sources. I'd love to be able to fix this one, and ideally understand more about what to check when encountering build errors with projects from different sources in the future.

Ignite CLI (React Native) + Facebook SDK = Android Multidex?

Alright, so really just posting as a sanity check, and making sure I'm not doing my android all wrong. Essentially, it seems needing to use multiDexEnabled true is not best practice, as it means the app is getting "big", aka bloated. But it takes very little to get there with the tools I'm using, which I'll outline below.
TL;DR: Using multidex seems to be bad practice, is there a different solution?
Starting with a vanilla Ignite CLI Bowser project, a template engine for React Native, and adding the React Native Facebook SDK according to the official guide, results in a build error for the android application.
ignite new TestApp
cd TestApp && yarn add react-native-fbsdk && npx react-native link react-native-fbsdk
Following Android Guide, make relevant changes to
TestApp/android/app/src/main/java/com/testapp/MainApplication.java and TestApp/android/settings.gradle
Then, following the linked Facebook SDK guide (auth wall), made the relevant changes to TestApp/android/app/build.gradle, TestApp/android/app/src/main/res/values/strings.xml and TestApp/android/app/src/main/AndroidManifest.xml
Then, running npx react-native run-android, results in the following build error:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:mergeDexDebug'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives:
The number of method references in a .dex file cannot exceed 64K.
Learn how to resolve this issue at https://developer.android.com/tools/building/multidex.html
More searches point to a fix of adding multiDexEnabled true to defaultConfig within the module build.gradle, which does fix the error. The issue, is most of those solutions also lead to others pointing out poor library management, importing too much, etc.
So, am I doing something wrong, or is this just the result of using Facebook SDK and Ignite CLI and there's nothing I can do about it? I just worry, as I was hoping to add more than one provider's OAuth to the application, but don't want a bloated application that never loads.
It's not related to libraries used in your project but to the number of methods used.
When your app and the libraries it references exceed 65,536 methods, you encounter a build error that indicates your app has reached the limit of the Android build architecture and you have to turn on multidex to be able to support more methods.
https://developer.android.com/studio/build/multidex

Contribute a Ionic 3 App to F-Droid

I'd like to contribute to the F-Droid GitLab Repo.
I followed this guide: https://gitlab.com/fdroid/fdroiddata/blob/master/CONTRIBUTING.md
I have done this already, many times with a normal native app. That worked great. But with an Ionic app it seems to be different. I see, for example, no gradle data in my Ionic app. Do I need gradle? Because the build failed because he can not run gradle clean ..
Heres my stack:
==== detail begin ==== FAILURE: Build failed with an exception.
What went wrong: Task 'clean' not found in root project.
This is how my metadata file looks like:
Categories:System
License:GPL-3.0
[...]
Repo Type:git
Repo:<Repo Link>
Build:1.0,1
commit=<commit>
gradle=yes
Auto Update Mode:None
Update Check Mode:None
Everything in <> is filled out correctly.
You are forging new ground here! We (F-Droid) don't have solid support for Cordoba/Ionic/etc. but the only thing preventing it is someone doing the work! We're working on adding a new build field sudo= which will let you download and install whatever you need to run your build. I've never used Ionic, Cordoba, or any of these Javascript app things, so I don't know the details.
You can follow the progress of sudo= here:
https://gitlab.com/fdroid/fdroidserver/merge_requests/297
It'll still be a while yet before this is deployed on our infrastructure, but your testing it will speed up that process!

Failed to capture snapshot of output files for task

Error:Failed to capture snapshot of output files for task 'transformClassesWithDexForDebug' property 'streamOutputFolder' during up-to-date check.
Failed to create MD5 hash for file 'C:\Users\GauravZone\AndroidStudioProjects\ZopporoStore\app\build\intermediates\transforms\dex\debug\folders\1000\10000\instant-run_83dbc65f4e3a4cd278807c089695c6b352698791\classes.dex'.
I am getting these errors don't know why, all application working fine earlier but suddenly getting this error in my all applications when try to run projects
Disable your antivirus, and it will work.
This is a Gradle issue and you can find it here.
So as of now just disable Instant Run.
It worked for me.
In android studio,
Open the Settings or Preferences dialog: On Windows or Linux, select File >
Settings from the menu bar. On Mac OSX, select Android Studio > Preferences from the menu bar.
Navigate to Build, Execution, Deployment > Instant Run.
Uncheck The box next to Restart activity on code changes.
I Solved this issue in my react-native project by removing all npm cache
1.npm cache clean --force
2.react-native run-android
Set multiDexEnabled true in your buildType release class in your build.gradle file
Error:Failed to capture snapshot of output files for task 'transformClassesWithDexForDebug' property 'streamOutputFolder' during up-to-date check ::
Solution: Just rebuild the project and then sync the project with Gradle files, as mention below.
1. Click on Build -> Rebuild Project
2. Click on Tools -> Android -> Sync Project with Gradle Files
I was also getting the same error.
But when i disabled Instant Run, Gradle started building.
But i agree with those who think this is a Gradle issue.
And until it gets resolve, disable Instant Run.
follows steps: instant run(file->setting->build,execution,deployment->uncheck instant run) then compile it work properly.
I've run into this issue after updating Android Plugin for Gradle to version 2.3.1. Rollback to version 2.3.0 helped for me, try setting
classpath 'com.android.tools.build:gradle:2.3.0' in your top level gradle.build file.
For me i had this error when i use my device as emulator . I did like that and it works :
1.adb reverse tcp:8081 tcp:8081
2.react-native start --reset-cache
3.react-native run-android
I faced the same issue and by disabling the QuickHeal Antivirus's virus protection, it worked for me fine.
Problem is gradle version. Update the gradle version to latest to resolve this kind of issues.
I have tried 'com.android.tools.build:gradle:3.3.2' is working for me. previously it was '3.1.0'
This issue comes when there are more than one process which is doing something with a file in your disk (whether it's your Jenkins job's workspace or Gradle's cache path or Gradle build folder that it creates) where these processes are trying to do something with a file and holds a lock.
If you have anti-virus, you may see this. Un-installing may resolve the issue but then you don't have anti-virus (it's better if you can set something in anti-virus to scan files periodically).
In my case, this issue only comes when I have a Jenkinsfile pipeline, where I'm running Gradle task for 3-5 projects in parallel (let's say Gradle is running an rpm task or build task) and when I'm running concurrent runs of this pipeline.
As you can see my pipeline code (Jenkinsfile Pipeline DSL: How to Show Multi-Columns in Jobs dashboard GUI - For all Dynamically created stages - When within PIPELINE section) is creating dynamic stage(s) and when I call it within pipeline section, I use parallel to run N no. of projects (that I can define in a hash/array) gradle tasks in parallel.
What I noticed is, all these runs (running in parallel) is running using my user-id (or some service account) and they are all using same Gradle version (4.3.1 in my case) and thus, they are using the same cache.
Running them in parallel alone --OR-- more realistic case would be running multiple pipeline runs of this pipeline job (running 5 project's gradle task in parallel) would probably land into this LOCK file condition.
You can probably solve this by setting a unique GRADLE_USER_HOME="~${WORKSPACE}/.cache"
(i.e. use Jenkins job's workspace which is dynamically created and is unique) or even better by setting Gradle user home as:
dt_stamp=`date +%s`; ## set and pass this dt_stamp variable for Gradle user home before calling Gradle.
GRADLE_USER_HOME="~${WORKSPACE}/${dt}/.cache"`
This way, at least in Gradle's cache, you won't see any issues due to lock files (NOTE: You'll not be able to efficiently use Gradle's cache concept of being lazy (or not fetching artifacts/library dependencies from a binary repository like Artifactory each time) while using Gradle among many projects if you set GRADLE_USER_HOME to a dynamic folder value as it'd be like running gradle after clearing it's cache each time (for some it's OK if your build doesn't take much time and it's more cleaner way to build as well)).
When I tried to run just one pipeline run (which runs all 5 project's gradle task in paralle), the pipeline succeeds all the time.
Running multiple instances of the pipeline job (running 5 parallel builds in each run) lands into this file LOCK issue.
Error mesg when I ran many concurrent pipeline runs (each pipeline run - runs Gradle tasks in parallel on 5 different projects).
FAILURE: Build failed with an exception.
* What went wrong:
Failed to capture snapshot of output files for task ':rpm' property 'archivePath' during up-to-date check.
> Timeout waiting to lock file hash cache (/view/user123456_Team_Tools/vobs/space/test/folder1/Project1of5/.gradle/4.3.1/fileHashes). It is currently in use by another Gradle instance.
Owner PID: 29003
Our PID: 903
Owner Operation:
Our operation:
Lock file: /view/user123456_Team_Tools/vobs/space/test/folder1/Project1of5/.gradle/4.3.1/fileHashes/fileHashes.lock
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
-- OR --
You may also get this kind of error where a process is not able to delete a directory (while Gradle is in progress as the target folder/file may be in use by some other process)
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':clean'.
> Unable to delete directory: /view/user123456_Team_Tools/vobs/space/test/folder1/project2of5/build/classes/java/main/org/syntax/jedit
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
* Get more help at https://help.gradle.org
If you are really lucky (like me), then you'll probably hit this error as well:
Jenkins - java.lang.IllegalArgumentException: Last unit does not have enough valid bits &
Gradle error: Task 'null' not found in root project
See here for more details: Jenkins - java.lang.IllegalArgumentException: Last unit does not have enough valid bits & Gradle error: Task 'null' not found in root project
Clearing the cache does fix it. But only once, if you stop the project and re run it, you ll end up with same error again.
Doing following fixes it for me,
cd android
./gradlew clean
react-native start --reset-cache
npm clean cache --force
Next, open two different terminals,
Run react-native start
in one terminal and in second,
Run react-native run-android
Hope it'll work for you as well.

Categories

Resources