Error:Execution failed for task ':app:incrementalDebugJavaCompilationSafeguard' [duplicate] - android
I am trying to develop a Android application using Android Studio,
so I created an Android app and I want to publish it.
Whenever I click on “build project“ to obtain the apk file,
I get this error:
Error:Execution failed for task ':app:processDebugResources'.
> java.io.IOException: Could not delete folder C:\Users\ehsan\AndroidStudioProjects\MyApplication3\app\build\generated\source\r\debug\com\example\ehsan
Build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.example.ehsan.myapplication"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.2.0'
}
REACT NATIVE
From your react native folder run:
cd android && gradlew clean
THEN
cd .. && react-native run-android
Notes:
For mac you may need to change gradlew to ./gradlew
For the command prompt you may need to change the && to &
For powershell you may need to change the && to ; and gradlew to .\gradlew.bat
Each command can also be run individually like so cd android then gradlew clean then cd .. then react-native run-android
I guess some of the files in the target build directory is open in another tool you use. Just a file handle open in the folder which has to be cleaned. The build task 'clean' wants to delete all the files in the build directory(normally 'target') and when it fails, the build fails.
Just clean your project, it works for me.
Clean task for gradle will work.
Fix This issue by this command
In Windows Platform
cd android && gradlew clean && cd..
In Mac Platform
cd android && ./gradlew clean && cd ..
Fix is very simple: Just follow below instructions
First, save the project
Click on project folder
Click on Syncronize button in the menubar (The third icon from the left which is just below to File menu option)
Clean project and run
as others have said allready you need to clean your project , the steps to clean the project are:
Build -> Clean Project or Build -> Rebuild Project
In my case, that problem is about permissions. if you open android studio as administrator (or using sudo) then if you open the project again as normal user, android studio may not delete some files because when you open the project as administrator, some project files permissions are changed. If you lived those steps, I think you should clone the project from your VCS (git, tfs, svn etc.) again. Otherwise you have to configure project file - folder permissions.
I have same issue. When I clean my project and rebuild it then everything works fine.
Build -> Clean Project
Just clean your project (Android Studio>Build>Clean Project) and build again.
I found another handy solution, which avoids rebuilding all components again and again, in this article:
http://bitstopixels.blogspot.ca/2017/04/react-native-windows-10-eperm-operation.html
Execute react-native run-android
As soon as React Packager window opens, close it
Wait for react-native run-android to complete giving you the BUILD SUCCESSFUL message. (The app will be launched with a red error screen complaining connecting to server failed. Don't panic.)
Then run react-native start to start the React Packager, this is the server indicated in the error message of the previous step
Reload the app in emulator or device (Double tap the R key)
If you encountered these errors due to opening the android studio with sudo command, then the solution is setting permission for the project folder.
Run the command below.
sudo chmod -R 777 your_project_folder
clean and rebuild again your android project.
React Native
These steps solved my problem:
Renaming of ReactNativeApp/android/build directory to old.build
Closing Android Studio
Inside ReactNativeApp/android executed this command.
gradlew clean
Making sure my RAM is 1500mb free
Then finally executing the command
react-native run-android
** It's quite interesting to close Android Studio. But beleive me these steps solved my problem **
Stopping OpenSdk Java process (inner to Android Studio process) worked.
If you have another instance of Android Studio running, then kindly close it and then build the app. This worked in my case
If you are using macOS then => sudo ./gradlew clean will work for you.
I deleted folder app/build and the problem was resolved in my case.
Update your gradle version.
Go to your project level build.gradle file and make sure you are using the latest version of gradle.
React Native
In my case I just refresh ( http://localhost:8081/debugger-ui/ ) , and it works... Any other solutions didn't work for me. Perhaps some files are used by debuger and it can't delete them... Anyway, it works for me. Please try this and give a feedback.
If it says:
The term 'gradlew' is not recognized
Then using following command
npm start -- --reset-cache
worked for me. cheers!
Delete android/app/build folder and run react-native run-android
From my experience in React Native, you can also restart your CLI and this error goes away.
I'm working on windows 10 and i can't find gradlew i cleaned the project using Android Studio :
Build ---> clean project and after that i was able to run :
react-native run-android or to run project using Android Studio
i just delete the error package from package.json and run again gradlew clean and its works for me For React Native
In my case it was that you had the app installed and when you gave it react-native run-android I could not install the app since it was already previously installed
Try closing your text editor (maybe VS Code) and File Explorer and run the command again in terminal with admin permissions.
Just Do onething File->Invalidate caches/ restart.
After loading the project sync the project.
Related
Android Studio Fails with: "File was deleted, but previous version not found in cache"
I had a project on Android Studio which was working. But after I ran git pull and then git reset --hard and tried to run it again, build failed with the message: File 'com.android.builder.files.ZipCentralDirectory#412e039a' was deleted, but previous version not found in cache
Build -> Clean Project fixed my problem.
Go to Task Manager Search for any instances of OpenJDK or java in task manager click and End Task Run flutter clean in IDE The Reason was Flutter Clean cant delete the build while the Application is still running in the Background process, u have to close it and run.
I also faced the same issue. it occurs when you run> flutter clean command that actually did't clean all the files inside build directory of your project, and causes the issue. So the simple solution is, delete your build directory manually. If it alerts "File in Use" dialogue then simple do the following steps open the run command with shortcut Window+R type resmon.exe it will open the resource monitor click on "CPU" tab click on "Associated handles" and type build in search bar right click on java.exe and end process restart your IDEA and run your project the problem is solved
An alternative way to fix this issue is to run flutter clean. You mentioned you are using android studio, go to your terminal inside android studio and then run the above mentioned command. After the above command was executed then run your app again. This simple solution worked for me !
Using Android Studio 3.6.2 for a Flutter project there is no 'Build -> Clean' unless you 'Open Android module in Android studio'. Then there is a 'Build -> Clean Project'. An alternative as mentioned above is to open the terminal in the project where you may Debug your application and run 'flutter clean'. For me the latter is better since I typically only open the Flutter android module when I want to build a release of my app.
Open Android module in Android studio run success execute ‘Build -> Clean’ close Android module in Android studio run flutter project again
react-native-firebase NullPointerException on android release build
I am getting below error in android when I have changed my MacBook. The app is running perfectly in the emulator/ real device. But I am facing this issue in making a release with ./gradlew assembleRelease command. A problem occurred configuring project ‘:react-native-firebase’. > java.lang.NullPointerException (no error message) I also tried the solution given on this link. But didn't work.
After spending two days on this issue, I have found that there was a problem of Java version. I added this two line in gradle.properites org.gradle.java.home=/Applications/Android Studio.app/Contents/jre/jdk/Contents/Home org.gradle.daemon=true And In Project Structure option -> SDK Location -> Enable Use embedded JDK This solution is worked for me.
Try to make release build from android studio. Before doing that go to android folder and run ./gradlew clean Follow below steps: Open you project in android studio and search for build -> generate release apk -> follow steps for keystore and all then select release option at last window.
react-native-webview Could not resolve org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.11
I initialized a react-native app with react-native init xxx and installed the latest(v4.1.0). Android Studio could not complete sync. it says: When I run react-antive run-android from console, it says something similar. I tried to wget the kotlin gradle plugin, it was not there. :'( How to reproduce? Just initialize a react-native(0.58) app Run yarn install react-native-webview . // version 4.1.0 run react-native run-android So this is a deadlink: https://dl.google.com/dl/android/maven2/org/jetbrains/kotlin/kotlin-gradle-plugin/1.3.11/kotlin-gradle-plugin-1.3.11.pom I find it's here. https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-gradle-plugin/1.3.11/kotlin-gradle-plugin-1.3.11.pom Please Note version 1.3.20 is also available. https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-gradle-plugin/1.3.20/kotlin-gradle-plugin-1.3.20.pom Please help :'( Thanks in advance.
Steps: Delete .idea folder and .iml in android directory In Android Studio -> Build -> Clean File -> Invalidate Caches / Restart
Generating APK - gradlew is not recognised
Trying to generate signed APK for android using windows 10, I have generated my keystore but how do I run gradlew assembleRelease? I have unzipped the binary into C:, added gradle to my path. However, gradlew is not recognised, and there is no build.gradle file in android/app/ The react native docs aren't very clear at all. Can anyone help? Using Android Studio I cannot see any build options either. Tried cd android && ./gradlew assembleRelease but get the error '&&' is not a valid statement separator Menu in android studio looks like:
Even though I am using a Mac, it's the same on windows too: you can use the Build->Generate signed APK. That should work by default. If that it's not working I suggest to Invalidate caches and restart your android studio.
Go into your react native project directory and run cd android && ./gradlew assembleRelease
Installation failed with message Invalid File
Installation failed with message Invalid File: K:\project\app\build\intermediates\split-apk\with_ImageProcessor\debug\slices\slice_0.apk. It is possible that this issue is resolved by uninstalling an existing version of the apk if it is present, and then re-installing. WARNING: Uninstalling will remove the application data! Do you want to uninstall the existing application? i am running my project in android studio 2.3 beta 3 .
Click Build tab ---> Clean Project Click Build tab ---> Build APK Run.
I found the solution go to settings>build,execute,deployment>instant run>Enable instant run to hot swap code /resource change on deploy(unchecked this option) `
Just follow two steps Step 1 : Build---> Clean Step 2 : Build--> Build APK Hope it works. Good luck guys
I solved it this way: Click Build tab ---> Clean Project Click Build tab ---> Rebuild Project Click Build tab ---> Build APK Run.
Hopefully, this should solve your problem. Do follow the following steps. 1. Clean your Project 2. Rebuild your project 3. Finally Build and Run your project
First, as already mentioned, try cleaning and rebuilding the project. If that does not work for you, try this: Settings > Build, Execution, Deployment: Un-check Enable Instant Run to hot swap code... This solved the problem right away for me. P.S. I posted this answer since it's 2017 and I don't think this feature existed in 2014, so it wouldn't cause this problem.
Please follow the below steps File > Settings > Build,Execution,Deployment > Instant Run > Un-check (Enable Instant Run to hot swap code) this is working for me thanks
This happened with me when I copied a project code from one laptop to another one and tried running the project. What fixed this for me was: Delete the project's build folder Clean Project Build project Run
In my case, I had the same issue when the name of my project contains a "&" sign.The solution is to rename the project name,from file browser, so it doesn't contain any "&" signs and then from: Build menu-> Clean Project Build menu-> Build APK I've tested it two times and it worked just fine.
For me it's: Click Build tab ---> Clean Project Rebuild Project Build APK
follow some steps: Clean Project Rebuild Project Invalidate Caches / Restart Now run your project. Hope it will work. It's work for me.
Work for me: Delete these folders Run app
Try this in gradle project dependencies { classpath 'com.android.tools.build:gradle:2.2.3' }
Delete the Intermediate folder after then run the project is working fine actually that APK builds to another system. Go to app/build/intermediates.
In my case , there was a single qutation ' in project directory and after removing it resolved
I found its work by restarting my phone :)
Invalidate cache/restart Clean Project Rebuild Project Run your app / Build APK These steps are enough to solve most of the problems related to Gradle build in any way. These steps helped me solve this problem too.
Try cleaning the project and rebuild, if doesn't work try disabling the Instant Run from Settings>Build>Instant Run in case you are running someone else's code.
My issue was with my Android Studio install. I am building out a new CI server and although I installed Android Studio and hooked up the SDK, etc., I did not open the studio with the project -- instead just went to the command line to build. When I subsequently opened the project in the studio, it started prompting for all sorts of updates. Followed the bouncing-ball and then I was able to reach my USB tethered device. Hopefully, this is helpful for Build Master and DevOps as a "got-cha" to avoid.
None of the answers here worked, I had to: Close android studio rm -rf ./android/.idea Build -> Build Bundle/APK(s) -> Build APK(s)
The path may be invalid, if Android Studio is pointing to the wrong version of the file. This can happen if you make gradle automatically rename your built APK, using setProperty(), like: defaultConfig { applicationId "com.company.app" versionName "1.2.0" // Rename the built apk file setProperty("archivesBaseName", "MyApp-$versionName") ... } Sometimes, an updated versionName is not properly "refreshed" to Android Studio, so it can point to an old versionName in the file name. In this case, just do a Gradle sync then Build, to ensure the versionName matches the built file path. Gradle sync is either: Android Studio 4.x ➔ Toolbar at the far right ➔ Press the 'elephant + down arrow' icon, which has the tooltip "Sync Project with Gradle Files" ➔ Build ➔ Make Project Android Studio 4.x ➔ Help ➔ Find Action ➔ search for "sync" ➔ "Sync Project with Gradle Files" ➔ Build ➔ Make Project
If none of those solutions work for you just close the Android Studio and open it. It worked for me on Mac.
Just Invalidate Cache and Restart !!! 🙌🏻