Android gradlew assembleRelease --sourcemap output fail because bundle doesn't exist yet - android

When bundling react-native code via gradlew assembleRelease and having the generate source maps tag added to the app build.gradle, bundling error occurs.
"error ENOENT: no such file or directory,
app\build\intermediates\assets\release\index.android.js.map"
In './android/app/build.gradle', I have the extraPackagerArgs property to generate source maps.
project.ext.react = [
entryFile: "index.js",
extraPackagerArgs: ["--sourcemap-output", "$buildDir/intermediates/assets/release/index.android.js.map"]
]
Doesn't work
When calling cd android && gradlew assembleRelease in the root of the project folder.
This however fails because it seems as though its trying to generate the source map before the bundle file index.android.bundle is even created.
example:
first I clean my project via android studio.
\android\app\build\intermediates\assets\release will be empty.
next, run cd android && gradlew assembleRelease.
The error is displayed stating that there is no bundle file as its trying to make a sourcemap.
Works
example:
clean the project via android studio
run cd android && gradlew assembleRelease without having extraPackagerArgs in the build.gradle file.
The bundle is created in ..\intermediates\assets\release.
Next, add back the extraPackagerArgs for generate the sourcemap.
Run again cd android && gradlew assembleRelease, and the sourcemap is created.
This tells me that whatever arguments are added to extraPackagerArgs seem to be running before the bundle is actually created.
Does anyone know a way to ensure that the sourcemaps only get generated after the bundle file is made?

Related

Why config object is empty (react-native-config)?

I have followed this blog to set multiple flavors to my project and I can successfully run it. However, I am not able to get the environment variables as the config object is empty. When I run i.e. the command : npx react-native run-android --variant=developmentdebug and I try to console log the variable object, it is always empty.
I have added 3 .env files to my RN project root:
.env.development
.env.production
.env.staging
What am I missing here?

How to sync gradle in React Native (android)?

I tried ./gradlew build but that didn't work, because it doessnt see the changes made in gradle file. The only thing that works for me is restarting and invalidating cache, but there must be a better way to do it.
Thank you
You should try running ./gradlew clean before building.
change directory to /{your project}/android then run below commands
./gradlew clean
./gradlew build
Note :-
you will get error : ./gradlew: No such file or directory
if you are trying gradlew commands outside android folder.
also check this : Why run 'gradle clean build' instead of 'gradle build'?

Jenkins- How to invoke gradle script tasks in different directory than the project root

Project Structure.
Root/
-------Android Project/
----------------------------ProjectRoot
-------Other Folders
My git repo contains Root. Inside root i have my android project.
Now when integrating Jenkins freestyle pipeline,
for wrapper location i simply pass ${workspace}/Android Project where my wrapper actually lies.
But the problem is when i add my tasks: i.e clean | build | assembleDebug its actually running on the Root folder and not inside "Android Project".
i tried "cd Android Project" before running the script but it does not seems to work
i have resolved the issue by simply removing invoke gradle script and adding a shell command window.
Within shell command i cd navigated to the directory i wanted to run the gradle task.
cd to the root directory, then call:
./gradlw :moduleName:gradleTaskName
replace moduleName and gradleTaskName with your project's real names.

React Native Bug when Assembling Release on Windows

When trying to assemble the release of my application in Windows, I get the following error:
Failed to capture snapshot of input files for task ':app:bundleReleaseJsAndAssets' property '$1' during up-to-date check.
> Failed to create MD5 hash for file content.
Both:
react-native run-android --variant=release
And:
gradlew assembleRelease
Won't work, however, it does work when I build the debug version with just:
react-native run-android
I've done some research and this seems to be a bug that only exists on Windows. I've also seen suggestions like:
Ensure NODE_ENV is not set to 'development'
.gradle is in the same directory as the outputDir and is causing locking issues with Windows
Try bundling the project manually with --dev false option (this doesn't give me an error but I don't know what to do after it's bundled)
The problem is only when assembling the release version and it seems to break when reading the google-services.json file each time but can't seem to find anything online that links the error to that file.
Does anyone have any idea what's going on here and how I could fix it?
Try remove the /node_modules folder and run npm install
Do the following
Delete the .gradle folder from the C:/Users/_username_/
Delete the node_modules and reinstall and run

React-native run-android fail on :app:processDebugResources

I recently added push notification to my app using react-native
and since at seemingly random times I get messages such as in the added photo
Execution failed for task
':app:processDebugResources'.
java.io.IOException: Could not delete folder ..\android\app\build\generated\source\r\debug\com\facebook\drawee
Did anyone experienced something like that or has a solution?
Run this command to clean project:
cd android && gradlew clean
After, run the following command to run project again:
cd .. && react-native run-android
I had the same problem. I changed the permissions of the project folder and all subfolders to full access from all users, and now it seems to work!
So apparently the packager can cause two types of file-access errors to occur during gradle syncing and building:
1) "EPERM: operation not permitted, lstat"
2) "java.io.IOException: Could not delete path"
These are actually two separate problems -- one of them caused by the watchman npm module, and the other caused by the packager itself.
Instructions to solve them can be found here: https://stackoverflow.com/a/47420765/2441655
If you are running the application in android device then go to the android director in your react native project then Delete the build folder/(Directory) then again run the project.Its work for me
The path of the build folder
YourProject/android/

Categories

Resources