IntelliJ IDEA Please configure the JDK to match the expected one - android

I just switched from Android Studio to intelliJ IDEA and I am trying to build my previous Android project. However, I am getting the following error upon on build.
The newly created daemon process has a different context than expected.
Java home is different.
Expecting: '/Applications/IntelliJ_IDEA_CE.app/Contents/jdk/Contents/Home' but was: '/Library/Java/JavaVirtualMachines/jdk1.8.0_111.jdk/Contents/Home'.
Please configure the JDK to match the expected one.
In my project structure's JDK setting, it is set to the IntelliJ's default JDK location but it seems like to be modified by some other configurations.
I have tried various solutions I could found online but still getting no where.
I have added the following option in my global gradle.properties:
org.gradle.java.home=/Applications/IntelliJ_IDEA_CE.app/Contents/jdk/Contents/Home
I have also tried deleting ./idea in my project and rerun the application but it is still showing the same error message.
I am not sure if anyone has another solution that worked for this problem. Thanks a lot!
PS. I am running IntelliJ on MAC.

Related

Android Studio problem with compiling "The process cannot access the file because it is being used by another process."

I know this question has been asked before, but there wasn't a satisfactory answer, and the last post was three years ago.
I am using android studio 3.6.2 in windows 10. Every time I try to compile my program I get the error
"The process cannot access the file because it is being used by another process."
Now I know what is causing the error. The R.jar file that was previously compiled cannot be deleted because android studio is locking the file.
It is in a folder \app\build\intermediates\compile_and_runtime_not_namespaced_r_class_jar\debug
Now to get around the problem I have been closing down android studio. Then deleting the R.jar, then restarting android studio and then compiling.
This process takes a good few minutes and I have to do it every time. Imagine how long it takes to write a program when you have to do this every time.
When this was asked on stack overflow previously suggestions were to Invalid caches / restart, but that is no quicker than what I did above, and only works once.
Also tried Clean Project, but that has no effect.
I have used many compilers over the years like visual studio, codeblocks etc but this kind of thing never happened before, so why is android studio so bad?
Has anyone found a solution to this problem yet?
[][]
Go to Edit Configurations check that you are not building before each launch. Remove "Build"
I also encountered the same problem in Android Studio 4.x in Windows 10. Simply using "Restart and Invalidate" does not work for me. Sometimes, deleting the build folder will work but I cannot build the project more than once. Here is my solution:
Check Java Runtime Version Used by Gradle and System Default
Having multiple daemons may cause problems as described in documentation from Gradle. To solve this problem,
Open your project in Android Studio
Find the JDK location used in your project (File > Project Structure > SDK Location > JDK Location)
Open a command prompt. Let $ANDROID_JDK be the path you found in Step 2. Type $ANDROID_JDK/bin/java.exe --version to find out the Java version.
Type java.exe --version to find out the default Java version used by the system.
Compare if the version information from Step 3 and Step 4 are the same.
Build with app Configuration
Empty Composable Activity template will create two build configurations.
You should change the build configuration to app as shown in the figure below. This solves my problem.
Proper Launching Procedure
As illustrated in Bilal Aslam's solution, we can edit the build configurations (Run > Edit Configurations). After selecting Compose Preview > Default Preview, you will see Build then Gradle-aware Make in the Before launch panel. Remove Build should be able to solve the problem. The side-effects are unclear.

Showing Error in all projects: ADT Bundle

I am using ADT bundle for my Android Application Development
1) From last two days whenever I open my ADT bundle its showing error in all the projects (But I have no errors in my projects and I am sure about it). I tried to clean all the projects but no use... Sometime a restarting eclipse will solve this problem but after few days I am getting this same errors again.
2) Also In my Android SDK Manager some packages like Google API and system images in extras were broken, I don't know what to do.
I tried to clean my projects and to update the SDK manager but nothing solved my problem. Kindly tell a better solution to solve this problem. And tell me why these kind of errors are happening.
Thanks a lot in advance.
But for this kind of problems need more clarifications. Here is my few tips to resolve it. It may or may not work! But better give a try.
In each class or java file which place exactly it showing the error? For example for few it will sow error in R. file and the error will be R cannot be resolved into type. If you are getting this error try to import you package R. file (Like import com.example.R) will resolve issue. If you couldn't import then try to check the package name in manifest file and other layout files. Try to resolve all errors one by one in res folder then clean will help it.
Next check whether Eclipse issue or ADT issue. You said few things are broken in ADT i don't know what exactly it means but try to uninstall and re-install them again.
Try to update eclipse. You can do it by Help->Check for updates
If nothing helps follow the error which are displayed in Problems tab which present near console tab. Otherwise open it here Windows->Show View -> Problems.
Hope anyone will help you if not please follow the errors and edit your question with error. So you might get better answers!
I had the same trouble.
I completely remove Eclipse and SDK bundle; then, i re-install everything.
This worked for me.
Do check this, Lint Error Checking will slow your ADT also seems to be occur error like what you got in a often situation..
so Disable lint from Windows-> Preferences -> Android-> Lint Error Checking, Under
Uncheck the two option in right hand side.
Be aware of what all your projects have JDK compliance.. set common JDK level.. mostly 1.6 based on need change to 1.7 for all projects..
set JDk compliance level in properties of your project -> java compiler and select in right hand side..
Always Check when importing any projects after import if its came up with a compatibility library or external library to be added like appcompat_v7
Check in properties of project under android tab in library section if there is any missing files..
From all the above suggestions are not fulfilled your problem, then go ahead with a new fresh latest ADT Bundle with a fresh download of platforms of SDK.. it will solve most of the ADT problems..
Finally the problem solved
This problem occurred due to missing target SDK in project properties and because of the broken files in SDK manager.
What I did is:
1) I deleted all the broken images and Google api packages from the SDK manager and I re installed all the packages again,
2) Then I selected android 4.2 as the Android Build Target in the project properties.
Thanks all for the time and help.

Problems after updating to Android SDK 20 in Eclipse

I updated tools in my Eclipse first by going to Help->Check For Updates and installing everything i that it suggested. Then by going to Window->Android SDK Manager and updating multiple things including my SDK version.
After I have finished my update all my Android projects got a nice red box with an x inside it. I explored the projects and noticed that none of them had any errors inside the project just the project itself had the error icon. I searched online and i found that other people had similar problems. So i thought i found the solution. Alas after cleaning and building the project I got additional error icons next to multiple java files in my projects. Eclipse cannot locate the automatically generated R files when it tries to import them and all the imports are selected red.
I tried deleting the whole content of .android directory (starting with specific few files then the whole content) but that did not bring desired results.
So i have deleted the newly generated files and restored all the old ones.
When I clean and build the projects again all the errors disappear but only until I try to run the project again and then same error appears:
Your project contains error(s), please fix it before running it.
I have also found a related question. It claims that there must be a problem with my xml files. I did not modify any of my xml files since updating the tools so I dont know what could cause them to have errors.
Any ideas as to what is going on??
I've found that eclipse is now picking up errors that it didn't pick up before, because they updated lint, you may have to check all your files and see if there is an error because of this, if it doesn't work try removing Android from the build and reattach it, clean the project, build project, make sure the activities are using the right R files and check what lint says, its like a little square with a tick in it I think.
I had exactly the same problem, solved by removing any imports of R in my code and then cleaning the project
Strangest thing just happened. Even though I have done this 2 times before I have again deleted all my files in .android folder exited my Eclipse and opened it back up again. All the errors were gone and most of my projects work correctly. I have spend a lot of time on this problem and i dont know how it got resolved but Im glad its working again.

Eclipse giving error when none are present (Snow Leopard and Android)

I'm trying to build an Android project in Eclipse, there are no syntax errors in the code (there's not much code at this point so I'm sure of this), I clean the project and build it and there are no errors, but as soon as I try to launch the app I get an error message and an error symbol on the project folder. This isn't the first time this has happened, I can't seem to launch any other projects either. I'm using Eclipse 3.7 (Indigo), JDK 6 with the compiler in Eclipse set to use v1.6, and Snow Leopard 10.6.8. I've tried fixing the project properties and still nothing works. Any help please?
Are there any known compatibility issues with Eclipse Indigo, JDK 6 and Snow Leopard 10.6.8?
I was concentrating on the LogCat and completely overlooked the Error/Problems view. It turns out that my Debug Certificate had expired so I just needed to delete ~/.android/debug.keystore and restart Eclipse and everything worked.
Often, misspelled assets or graphics can cause this and not show any error.
I'd make sure there are no misspelled or invalid characters in your filenames.
Hope that helps

Android application giving a weird error in Eclipse

i put this question in this forum because i am not sure whether this is an eclipse error or an Android error.
yesterday i created an Android application using Google Maps and GPS on Eclipse and it build and ran successfully however today i wanted to do some modification to the code so i started eclipse but it gave me an error.
SDK parse failed
if i try to run it. it says the apk cannot find. how can that be happened? the same application ran successfully on the same environment yesterday. i am using Ubuntu 10.04
Thanks !!
There is a problem with your project, as evidenced by the red x icon on your project title bar shown in the image above. Right-click your project, choose Properties and go through all your properties to make sure they are all still valid. It might be a reference to one of the jar files.
I get this problem all the time, hopefully my solution works for you.
To work around, goto your libraries inside the properties page.
Add any library and then rebuild your project.
Go back and remove the library later for clean up.
The project should still build.

Categories

Resources