React Native Bug when Assembling Release on Windows - android

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

Related

Flutter: Not able to run the app on simulator - gradle error

I am trying to run the default app which comes when creating a flutter file using "flutter run" but it gives me the following error:The error I am facing.
I did try installing gradle, creating a settings.gradle file in my root directory of project and run "gradle wrapper" it was successful but I still face the same error.
UPDATE: One of my parent directories had spaces in the directory name. After removing the spaces it solved the issue.
Your gradle-wrapper is missing. Make sure that you've a gradle distribution added in your PATH variable and restore the wrapper by running this command:
gradle wrapper

debug directory does not exist error running React-native's AwsomeProject

I'm trying to create a react-native android app following react-native "Getting started" here but when I try to run it both through CLI and with Android studio it gives me this error:
A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> Android resource compilation failed
AAPT: C:\Windows\System32\AwsomeProject\android\app\build\intermediates\res\merged\debug: error: directory does not exist.
I tried deleting the build folder, cleaning the project and re-running it but it doesn't work.
How can I solve this?
If I understand your situation right:
There is absolutely no issue in your Java and XML.
Your project built just fine before this.
You tried to remove the build cache.
In addition to above you should remove the .gradle directory as well.
Unfortunately, some react-native modules have their own build directory inside the node_modules/ directory, so it is possible that you didn't clear the build cache for them.
Of course, it's really hard to go into each module and remove the build cache manually each time, but fortunately, you can change this behavior by adding to build.gradle file something like below:
allprojects {
// ...
buildDir = "${rootProject.rootDir}/.build/${project.name}"
}
Note: This tells gradle to use the same build directory for all projects.
I prefer ".build" as build directory but you may want to change that to "build" in above.

react-native run-android Exception in thread "main" java.util.zip.ZipException: error in opening zip file

I try to
react-native run-android
and meet
this problem
JS server already running.
Running C:\Users\丶丶困困兽兽犹犹斗斗\AppData\Local\Android\sdk/platform-tools/adb -s 192.168.76.101:5555 reverse tcp:8081 tcp:8081
Building and installing the app on the device (cd android && gradlew.bat installDebug...
Unzipping C:\Users\丶丶困困兽兽犹犹斗斗\.gradle\wrapper\dists\gradle-2.4-all\6r4uqcc6ovnq6ac6s0txzcpc0\gradle-2.4-all.zip to C:\Users\丶丶困困兽兽犹犹斗斗\.gradle\wrapper\dists\gradle-2.4-all\6r4uqcc6ovnq6ac6s0txzcpc0Exception in thread "main" java.util.zip.ZipException: error in opening zip file
at java.util.zip.ZipFile.open(Native Method)
at java.util.zip.ZipFile.<init>(ZipFile.java:114)
at java.util.zip.ZipFile.<init>(ZipFile.java:131)
at org.gradle.wrapper.Install.unzip(Install.java:159)
at org.gradle.wrapper.Install.access$500(Install.java:26)
at org.gradle.wrapper.Install$1.call(Install.java:69)
at org.gradle.wrapper.Install$1.call(Install.java:46)
at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAccessManager.java:65)
at org.gradle.wrapper.Install.createDist(Install.java:46)
at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:126)
at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:61)
SDK works well and can find device in adb devices
The problem is Unable to Unzip your gradle-2.4-all.zip,
So please Delete the existing file
gradle-2.4-all.zip
from your folder :
C:\Users\丶丶困困兽兽犹犹斗斗.gradle\wrapper\dists\gradle-2.4-all\6r4uqcc6ovnq6ac6s0txzcpc0\
Download a fresh gradle-2.4-all.zip file and place it on the same folder as we deleted and try again to run your code : react-native run-android
It may work.You can download gradle zip file from the below Link: https://services.gradle.org/distributions
I have the same problem as yours!
Because when I first run "react-native run-android", my INTERNET is SLOW and LAG, CORRUPTED. This bad internet connection lets to download a TEMPORARY DAMAGE file gradle....zip.
Solution: Just go in that path contains that file zip, delete it then run again! It worked for me!
Well, I meet the same problem.
I use this method solve it.
I input: sudo react-native run-android
then the Terminal show :
java.lang.RuntimeException: SDK location not found. Define location
with sdk.dir in the local.properties file or with an ANDROID_HOME
environment variable.
So I copy a "local.properties" from an existing Android project and put it in this project.
And then,I input sudo react-native run-android again.
Content in file gradle-2.4-all error.
Please delete content in gradle-2.4-all (~/.gradle\wrapper\dists\gradle-2.4-all...) then re-compile .. it will auto download file.
I just experienced the same problem as yours. When I run react-native run-android, I got the error message:
Exception in thread "main" java.util.zip.ZipException: error in opening zip file
I use Mac and apparently the problem was caused by the react-native CLI that is failed to write the Gradle zip file to certain folder due to lack of permission. In my case, I tried to ran the command again this time using sudo: sudo react-native run-android, and the problem was solved.
The gradle-2.4-all.zip was damaged,so it should be replaced with a new gradle-2.4-all.zip
One of the causes of this problem (since late 2019) is the decommissioning of HTTP services by Gradle. This means that if your [PROJECT_PATH]/gradle/wrapper/gradle-wrapper.properties file has an entry like:
distributionUrl=http\://services.gradle.org/distributions/gradle-{version}.zip
... then this entry will try to retrieve a ZIP file from a service no longer servicing it (http based one) and it will silently return an empty ZIP file; which consequentially will be the source of an error from any process trying to unzip that empty ZIP file.
To fix this, just change your [PROJECT_PATH]/gradle/wrapper/gradle-wrapper.properties file to have its distributionUrl entry to use https:
distributionUrl=https\://services.gradle.org/distributions/gradle-{version}.zip
Hope this helps.
update the line in ../android/gradle/wrapper/gradle-wrapper.properties
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-all.zip
I think you could download the gradle-2.4-all.zip from here,unzip it to your .gradle.
For me I just deleted .gradle folder and then tried again. It re-downloaded libraries and it worked.
P.S.
I think in new configuration there is no .zip file.
The problem is the same as you.
Exception in thread "main" java.util.zip.ZipException: error in opening zip file.
just use sudo react-native run-android insted of react-native run-android

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/

Phonegap error android sdk build.xml:950 : null returned: 1

I'm trying to launch phonegap android app in android sdk, but I am receiving an error:
[phonegap] detecting Android SDK environment...
[phonegap] using the local environment
[phonegap] compiling Android...
[error] An error occurred while building the android project.Error executing "ant debug -f "/Users/me/Projects/one/platforms/android/build.xml"":
BUILD FAILED
/Applications/Android/adt-bundle-mac-x86_64-20131030/sdk/tools/ant/build.xml:932: The following error occurred while executing this line:
/Applications/Android/adt-bundle-mac-x86_64-20131030/sdk/tools/ant/build.xml:950: null returned: 1
I followed this guide http://docs.phonegap.com/en/2.2.0/guide_getting-started_android_index.md.html but it is not working.
What could have caused this?
You are most likely also getting the line
invalid resource directory name:
/YOUR/PROJECT/ROOT/PATH/bin/res/crunch
right before the error codes, so open up terminal and enter the following:
cd YOUR/PROJECT/ROOT/PATH
rm -fR $(find . -type d -name crunch|xargs)
I just had to cd into the platforms/android dir and run ant clean and it fixed this issue for me.
had the same issue. something that can help is to read ant log as recommend here
to do so run ant -logfile //antLogFile.txt release -f ./AppMain/build.xml
or in the folder itself. i.e : platforms\android run ant -logfile ./antLogFile.txt release
My issue was a file with Hebrew characters on its name..
Hi Sorry for the late answer
An alternative to other solutions possibly OS-X Specific but i was having the same issue and none of the solutions for me worked however the mention of assets made me go back and scour over my build logs and i noted this:
[aapt] /Users/rowdoggnz/Development/cordova/surveyapp/platforms/android/assets/www/lib/fa/Icon
[aapt] : error: Invalid filename. Unable to add.
This was the cause of my error which shared the same error code and line references as the original poster.
OS-X seems to generate ghost icon files for some reason which are not visible in finder due to being hidden, i used an app called "Invisiblix" to view my project folder and removed all of the 'Icon' files and my app would build fine.
I'm guessing the iOS build naturally ignores these Icon files however Ant doesn't.
Hope this helps someone.
If you have more than one project and you are using the same assets eg: images, ant will fail to build. You can use ant clean to remove the cache from other projects and avoid this issue as suggested in this post crunch/resource packaging with aapt in ant build uses cache from other projects
Nevertheless, In my case I just have one project with many images, some of them were called with the same name, but with different letter case. Ant's build process is case-insensitive, so those images were duplicated, being error cause.
My particular fix was to rename or eliminate one of the images to allow cordova build my project.
I was having this issue in OSX using Ionic framework. This was my fix:
I ran this on the command line in the project root folder:
find . -name Icon -exec rm {} \;
What the above does descend through the whole project to search for files name Icon. Upon finding them they are deleted.
After this I ran my build process and all was good again.
Make sure you have installed the prerequisites correctly.

Categories

Resources