Following error occurred in Android Studio(ver. 4.2.1): "An error occurred while preparing SDK package Android SDK Platform 30: C:\Users\KIIT\AppData\Local\Android\Sdk.temp\PackageOperation01\unzip\android-11\data\res\drawable-xhdpi\btn_star_big_off_disable_focused.png: The process cannot access the file because it is being used by another process." Also another error that cam up was: Project':app': Cannot query the value of this provider because it has no value available.
CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900
Whenever trying to run a flutter app I am greeted with this error. * What went wrong: Execution failed for task ':app:transformResourcesWithMergeJavaResForDebug'. java.nio.file.FileSystemException: D:\Projects\buisnesscard\build\app\intermediates\transforms\mergeJavaRes\debug\0.jar: The process cannot access the file because it is being used by another process. I tried adding: packagingOptions { exclude 'META-INF/DEPENDENCIES.txt' exclude 'META-INF/NOTICE' exclude 'META-INF/NOTICE.txt' exclude 'META-INF/LICENSE' exclude 'META-INF/LICENSE.txt' } to my build gradle file and restarting android studio however the error still occurs. My /app/build.gradle looks like this: ` def localProperties = new Properties() def localPropertiesFile = rootProject.file('local.properties') if (localPropertiesFile.exists()) { localPropertiesFile.withReader('UTF-8') { reader -> localProperties.load(reader) } } def flutterRoot = localProperties.getProperty('flutter.sdk') if (flutterRoot == null) { throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") } def flutterVersionCode = localProperties.getProperty('flutter.versionCode') if (flutterVersionCode == null) { flutterVersionCode = '1' } def flutterVersionName = localProperties.getProperty('flutter.versionName') if (flutterVersionName == null) { flutterVersionName = '1.0' } apply plugin: 'com.android.application' apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" android { compileSdkVersion 28 lintOptions { disable 'InvalidPackage' } packagingOptions { exclude 'META-INF/DEPENDENCIES.txt' exclude 'META-INF/NOTICE' exclude 'META-INF/NOTICE.txt' exclude 'META-INF/LICENSE' exclude 'META-INF/LICENSE.txt' } defaultConfig { // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). applicationId "com.seandiacono.buisnesscard" minSdkVersion 21 targetSdkVersion 27 versionCode flutterVersionCode.toInteger() versionName flutterVersionName testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } buildTypes { release { // TODO: Add your own signing config for the release build. // Signing with the debug keys for now, so `flutter run --release` works. signingConfig signingConfigs.debug } } } flutter { source '../..' } dependencies { testImplementation 'junit:junit:4.12' androidTestImplementation 'com.android.support.test:runner:1.0.2' androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' implementation 'com.google.firebase:firebase-core:17.0.0' } apply plugin: 'com.google.gms.google-services' `
If the error is recurring, you can try a file leak detector to determine what part of the gradle process is holding your files. As suggested here,
In my case, I found out that a file was held by AspectJ compiler/weaver (ajc): #115 C:\Users\me\StudioProjects\myapp\app\build\intermediates\compile_and_runtime_not_namespaced_r_class_jar\debug\R.jar by thread:Execution worker for ':' Thread 3 on Mon Oct 19 18:41:06 BST 2020 at java.util.zip.ZipFile.<init>(ZipFile.java:156) ... at org.aspectj.tools.ajc.Main$run.call(Unknown Source)I was running it directly from Gradle: new Main().run(args, handler)I don't know if it's possible to make ajc release the files. So I resolved my issue by running it in a separate process. I added a new configuration to get aspectjtools onto classpath: val weaving: Configuration by configurations.creating dependencies { weaving("org.aspectj:aspectjtools:1.9.6") }And instead of the above code, I did: javaexec { classpath = weaving main = "org.aspectj.tools.ajc.Main" args = arguments } |