I keep getting this error
Error:Execution failed for task ':app:compileDebugJavaWithJavac'.
Unexpected lock protocol found in lock file. Expected 3, found 0.
Thinkgs I've tried doing:
Deleting .gradle file and restarting android studio
Project structure > JDK path: C:\Program Files\Java\jdk1.8.0_91
Downloaded every item in the SDK manager and installation was successful
Project Structure > app > Build Tools Version tried whats on the list
Note: This error only appears when I try to run the program. If I never touch the run button all my code and builds are clean and successful, until I try running for the first time and it never goes if I try running again
Other posts about this problem is very confusing since there is no right answer on how to do this and all the answers aren't supported with feedback
Thanks in advance!
Try deleting this file:
c: \ users \ [myusername] \ .gradle \ caches \ 2.14.1
and restart the Android Studio
Related
I'm here to write about an issue that I've tried to fix for 3 weeks.
I think I updated a tool in the SDK within Android Studio (not sure which one).After this, I saw a lot of different issues that caused all my projects to stop working. I uninstalled it and deleted all my data of installations SDK NDK and reinstalled it, but I see the same error.
When I create a new Android Studio project I get these issues:
Access Deniel: I followed all instructions which results in the second issue.
you should use version Kotlin 1.2.51 or higher: I
don't use Kotlin in my project and the version of Gradle is 3.1.0, which was working correctly before.
Following the instructions, I updated the version of Kotlin in my project to 1.2.51, I received a lot of issues:
Android resource compilation failed
Output: C:\Users\safin\Desktop\Project\myproject 02-05-
2018\myproject\myproject\myproject\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:977: error: unescaped apostrophe in
string
"Safin click,
it is a oneself.\n\n
All have made
and click.\n\n
After days.\n
Thank you safineas.".
C:\Users\safin\Desktop\Project\myproject
02-05-2018\myprojectr\myproject\myproject\app\build\intermediates
\incremental\mergeDebugResources\merged.dir\values\values.xml:963:
error: not a valid string.
Command: C:\Users\safin\.gradle\caches\transforms-1\files-1.1\aapt2-3.2.0-
4818971-windows.jar\016347ebf5a2e9c410c8e5c96l7d7b16\aapt2-3.2.0-4818971-windows\aapt2.exe compile --legacy \
-o \
C:\Users\safin\Desktop\Project\myproject 02-05-2018\myproject\myproject\myproject\app\build\intermediates\res\merged\debug \
C:\Users\safin\Desktop\Project\myproject 02-05-2018\myproject\myproject\myproject\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml
Daemon: AAPT2 aapt2-3.2.0-4818971-windows Daemon #0
See attached screenshots below:
I don't get your whole problem but in that case - error: unescaped apostrophe in string, the string you provided SHOULD BE MODIFIED. You must add backslash before the apostrophe like this-
\"Safin click, it is a oneself.\n\n All have made and click.\n\n After days.\n Thank you safineas.\"
While developing an app I came into following error. I tried downgrading the java version from 11 to 8, but that wasn't helpful.
FAILURE: Build failed with an exception.
* What went wrong:
Could not create service of type ScriptPluginFactory using BuildScopeServices.createScriptPluginFactory().
> Could not create service of type PluginResolutionStrategyInternal using BuildScopeServices.createPluginResolutionStrategy().
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 15s
Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/getting-started.html
Command failed: gradlew.bat installDebug
Error: Command failed: gradlew.bat installDebug
at checkExecSyncError (child_process.js:616:11)
at Object.execFileSync (child_process.js:634:13)
at runOnAllDevices (C:\Users\samie\Documents\React Native\auth\node_modules\react-native\local-cli\runAndroid\runAndroid.js:299:19)
at buildAndRun (C:\Users\samie\Documents\React Native\auth\node_modules\react-native\local-cli\runAndroid\runAndroid.js:135:12)
at isPackagerRunning.then.result (C:\Users\samie\Documents\React Native\auth\node_modules\react-native\local-cli\runAndroid\runAndroid.js:65:12)
at process._tickCallback (internal/process/next_tick.js:68:7)
How I solved this problem:
First, make sure that I have %java_home% variable set and also %path% has the java sdk included.
How to setup Java environment variables
Second, Go to your android folder and run this command:
C:\Projects\myproject\android>gradlew.bat app:installDebug.
Unzipping
C:\Users\codeb.gradle\wrapper\dists\gradle-4.10.2-all\9fahxiiecdb76a5g3aw9oi8rv\gradle-4.10.2-all.zip
to
C:\Users\codeb.gradle\wrapper\dists\gradle-4.10.2-all\9fahxiiecdb76a5g3aw9oi8rv
Exception 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.(ZipFile.java:225)
at java.util.zip.ZipFile.(ZipFile.java:155)
at java.util.zip.ZipFile.(ZipFile.java:169)
at org.gradle.wrapper.Install.unzip(Install.java:215)
at org.gradle.wrapper.Install.access$600(Install.java:27)
at org.gradle.wrapper.Install$1.call(Install.java:75)
at org.gradle.wrapper.Install$1.call(Install.java:48)
at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAccessManager.java:69)
at org.gradle.wrapper.Install.createDist(Install.java:48)
at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:107)
at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:61)
As you can see that my gradle download is corrupt. All you have to do is delete this folder and rerun the command.
C:\Projects\myproject\android>gradlew.bat app:installDebug
Downloading
https://services.gradle.org/distributions/gradle-4.10.2-all.zip
...............................................................................................................
Unzipping
C:\Users\codeb.gradle\wrapper\dists\gradle-4.10.2-all\9fahxiiecdb76a5g3aw9oi8rv\gradle-4.10.2-all.zip
to
C:\Users\codeb.gradle\wrapper\dists\gradle-4.10.2-all\9fahxiiecdb76a5g3aw9oi8rv
Welcome to Gradle 4.10.2!
Here are the highlights of this release:
- Incremental Java compilation by default
- Periodic Gradle caches cleanup
- Gradle Kotlin DSL 1.0-RC6
- Nested included builds
- SNAPSHOT plugin versions in the plugins {} block
For more details see https://docs.gradle.org/4.10.2/release-notes.html
Now, you can go back to your react native project and run
react-native run-android
info JS server already running. info Building and installing the app
on the device (cd android && gradlew.bat app:installDebug)...
Task :app:installDebug 01:03:18 V/ddms: execute: running am get-config 01:03:18 V/ddms: execute 'am get-config' on 'emulator-5554'
: EOF hit. Read: -1 01:03:18 V/ddms: execute: returning Installing APK
'app-debug.apk' on 'Pixel_2_API_28(AVD) - 9' for app:debug 01:03:18
D/app-debug.apk: Uploading app-debug.apk onto device 'emulator-5554'
01:03:18 D/Device: Uploading file onto device 'emulator-5554' 01:03:18
D/ddms: Reading file permision of
C:\Projects\xx\android\app\build\outputs\apk\debug\app-debug.apk
as: rwx------ 01:03:18 V/ddms: execute: running pm install -r -t
"/data/local/tmp/app-debug.apk" 01:03:19 V/ddms: execute 'pm install
-r -t "/data/local/tmp/app-debug.apk"' on 'emulator-5554' : EOF hit. Read: -1 01:03:19 V/ddms: execute: returning 01:03:19 V/ddms: execute:
running rm "/data/local/tmp/app-debug.apk" 01:03:19 V/ddms: execute
'rm "/data/local/tmp/app-debug.apk"' on 'emulator-5554' : EOF hit.
Read: -1 01:03:19 V/ddms: execute: returning Installed on 1 device.
BUILD SUCCESSFUL in 9s 27 actionable tasks: 1 executed, 26 up-to-date
info Running
C:\Users\codeb\AppData\Local\Android\Sdk/platform-tools/adb -s
emulator-5554 reverse tcp:8081 tcp:8081 info Starting the app on
emulator-5554
(C:\Users\codeb\AppData\Local\Android\Sdk/platform-tools/adb -s
emulator-5554 shell am start -n
com.myproject/com.myproject.MainActivity)... Starting:
Intent { cmp=com.myproject/.MainActivity }
Try running this command inside your project file
react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res
after that
cd (path to project/android folder) && gradlew clean && cd .. && react-native run-android
always gradlew clean before run react-native-run-android
the above command basically cleans up the gradle and previous builds.
for ENOENT Error
Check if $ yarn start works. The metro bundler wasn't able to run on port 8081 for me and I needed to run $ killall node
EDIT:
Also update the gradle-wrapper.properties
add
distributionUrl=https\://services.gradle.org/distributions/gradle-5.2.1-all.zip
remove following code from build.gradle:
task wrapper(type: Wrapper) {
gradleVersion = '5.2.1'
distributionUrl = distributionUrl.replace("bin", "all")
}
after that
cd (path to project/android folder) && gradlew clean && cd .. && react-native run-android
always gradlew clean before run react-native-run-android the above command basically cleans up the gradle and previous builds.
You're good to go!
Just run sudo react-native run-android and it will build and install ./gradlew app:installDebug inside android directory for you.
I had this issue too and I was able to fix it by creating a new project in react-native 0.57.3 using the command:
react-native init --version="0.57.3" MyNewApp
You have to update the gradle-wrapper.properties file to use the newest version of gradle:
distributionUrl=https\://services.gradle.org/distributions/gradle-5.2.1-all.zip
And remove this block from build.gradle file:
task wrapper(type: Wrapper) {
gradleVersion = '5.2.1'
distributionUrl = distributionUrl.replace("bin", "all")
}
Then run a gradlew clean on the android folder and everything should work.
I had this issue too and I was able to fix it by run ./gradlew app:installDebug in android folder .
In my case, I uninstalled my java jdk17 and installed java jdk11. It worked for me few seconds ago. Really happy :)))
I had this issue myself, it eventually went away after I uninstalled and re-installed android studio and gradle, but a few other things you could try first
1: Setting GRADLE_USER_HOME in environment variables (if on windows)
2: Downgrade to react-native 0.57.0
3: Make sure you have the correct permissions to run the command and access files
4: Make sure your gradle files are synced correctly, and that location of gradle and the android skd are correct within project structure offline mode
5: Check gradle for updates
(Assuming you are using android studio)
Good luck
The problem is on file:
nameyourapp/android/local.properties
you have to substitute with the correct path: /Users/nameUser/AppData/Local/Android/sdk
I have the same error I just uninstall the JDK old version and install the latest version from https://www.oracle.com/java/technologies/javase-downloads.html and now it's working.
Open your settings.grandler file in the android folder
Change the \ to /
Save the file
Run the command react-native run-android
Android resource compilation failed
Output: values_values.arsc.flat: error: failed to open.
Command: C:\Users\KAMAL.gradle\caches\transforms-1\files-1.1\aapt2-3.2.1-4818971-windows.jar\1004f9e02d2cf44b39e5208f3f298ce2\aapt2-3.2.1-4818971-windows\aapt2.exe compile --legacy \
-o \
D:\AndroidRoomDbTutorial\app\build\intermediates\res\merged\debug \
D:\AndroidRoomDbTutorial\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml
Daemon: AAPT2 aapt2-3.2.1-4818971-windows Daemon #2
It is room database application .
I had this, turned out aapt was being blocked by antivirus.
Found answer here:
https://forum.ionicframework.com/t/unable-to-build-error-values-values-arsc-flat-error-failed-to-open/128575
Now Android Studio will be giving you error for explicit values and if those values are coming from some library you are using then you can't make a change in the intermediate file so instead change here and while merging your code Android studio takes care of it.
<resources>
<item name="faqID" type="id">faq</item>
Changed it to:
<resources>
<item name="faqID" type="id"/>
Please refer this link
https://developer.android.com/guide/topics/resources/more-resources#Id
You can also try as follows
If problem still exists please try as follows
File | Invalidate Caches / Restart
Deleting .idea folder
Running gradlew clean
Re-import the project
When trying to build my phone gap app for android using
sudo phonegap build android
it fails with this error:
:compileDebugJava
/Users/youssefsami/Library/Mobile Documents/com~apple~CloudDocs/Developer/Mobile Apps/UzuConvert/platforms/android/src/org/apache/cordova/inappbrowser/InAppBrowser.java:120: error: cannot find symbol
|| Config.isUrlWhiteListed(url)) {
^
symbol: method isUrlWhiteListed(String)
location: class Config
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
1 error
FAILED
FAILURE:
Build failed with an exception.
* What went wrong:
Execution failed for task ':compileDebugJava'.
>
Compilation failed; see the compiler error output for details.
* Try:
Run with
--stacktrace option to get the stack trace. Run with
--info or
--debug
option to get more log output.
BUILD FAILED
Total time: 5.607 secs
/Users/youssefsami/Library/Mobile Documents/com~apple~CloudDocs/Developer/Mobile Apps/UzuConvert/platforms/android/cordova/node_modules/q/q.js:126
throw e;
^
Error code 1 for command: /Users/youssefsami/Library/Mobile Documents/com~apple~CloudDocs/Developer/Mobile Apps/UzuConvert/platforms/android/gradlew with args: cdvBuildDebug,-b,/Users/youssefsami/Library/Mobile Documents/com~apple~CloudDocs/Developer/Mobile Apps/UzuConvert/platforms/android/build.gradle,-Dorg.gradle.daemon=true
ERROR building one of the platforms: Error: /Users/youssefsami/Library/Mobile Documents/com~apple~CloudDocs/Developer/Mobile Apps/UzuConvert/platforms/android/cordova/build: Command failed with exit code 1
You may not have the required environment or OS to build this project
Error: /Users/youssefsami/Library/Mobile Documents/com~apple~CloudDocs/Developer/Mobile Apps/UzuConvert/platforms/android/cordova/build: Command failed with exit code 1
at ChildProcess.whenDone (/usr/local/lib/node_modules/phonegap/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:131:23)
at ChildProcess.emit (events.js:110:17)
at maybeClose (child_process.js:1015:16)
at Process.ChildProcess._handle.onexit (child_process.js:1087:5)
I tried setting the java_home to the java alias in lib exec but still nothing. Any ideas on what maybe causing the problem?
It's because your InAppBrowser plugin is out date and probably out of sync with a newer version of the Cordova Android platform than when you first installed the plugin. I was getting the same issue with cordova-android#4.0.0 and 0.5.3 of InAppBrowser.
Fix is to first remove plugin
cordova plugin rm org.apache.cordova.inappbrowser
Then add it again (it should reinstall with the latest version the cordova CLI has in my case it grabbed 0.6). You can check the version in the RELEASENOTES.md in the plugins/org.apache.cordova.inappbrowser/ folder.
cordova plugin add org.apache.cordova.inappbrowser
You will need to remove the android platform and re-add it before building again so it doesn't keep the old version of the plugin.
cordova platform rm android
and
cordova platform add android
Now build again and the error should have gone.
EDIT: I just noticed at the top of your question you are using phonegap. Since you tagged with cordova (and thats what I use) I answered with cordova commands, but I'm guessing almost the same process applies with Phonegap.
Same problem with cordova-android#4.0.0
Thank's JDawgg your solution's better than mine, but if someone still have the bug you can use cordova-android#3.6.4 like this :
cordova platform remove android
then
cordova platform add android#3.6.4
you must have android 4.2.2 sdk installed
Finally
sudo phonegap build android
In case someone is using Meteor and came across the same problem, martijnwalraven suggests removing the older version of cordova-plugin-inappbrowser and add the most recent one:
$ meteor remove cordova:cordova-plugin-inappbrowser
$ meteor add cordova:cordova-plugin-inappbrowser#1.0.1
This did the trick for me!
I know this question has been asked prior to this in here and here
but I can't seem to find a solution to this issue.
I checked every single thing from
Checking all the resource files, manually running through the strings.xml to even updating IntelliJ Idea (I am using IntelliJ 13) not the Android studio, but unfortunately nothing seems to work.
I am using app-compact in my project to show the ActionBar in Android Versions prior to Honeycomb.'
> Error:android-apt-compiler: Command
> "D:\AndroidSDK\build-tools\19.0.2\aapt.exe package -m
> --auto-add-overlay --extra-packages android.support.v7.appcompat --output-text-symbols C:\Users\Mushtaq\.IntelliJIdea13\system\compile-server\hac_89cbbfa5\android\intermediate_artifacts\HAC\r_txt
> -J C:\Users\Mushtaq\.IntelliJIdea13\system\compile-server\_temp_\android_apt_output5484624330942511062tmp
> -M C:\Users\Mushtaq\Desktop\HAC\AndroidManifest.xml -S C:\Users\Mushtaq\Desktop\HAC\res -S
> C:\Users\Mushtaq\Desktop\HAC\library\appcompat_v7\res -I
> D:\AndroidSDK\platforms\android-19\android.jar" execution failed with
> exit code -1073741819
Finally found the issue, I was had a messed up drawable xml which had a truncated xml namespace, which in turn did not let the R class to generate.
The weird part is it was not showing up in any of the IDE's, it was failing silently and had to go through each and every file to come up with Issue. Not cool Android Lint/IDE, wasted almost a day.
If your Rclass does not generate it is ALWAYS and I mean ALWAYS the issue is with a resource file, do not look/think for one second that the issue is at some place else.Lesson learnt the hard way.
Edit :
I don't understand why the error message thrown by the IDE has to be so cryptic.