Following the guides here on stack overflow I was able to create a pure Java program using Android studio.
Here’s what I did:
I created a new project with no activity
I added a java library module and created a main method inside the
added java library class
Through “edit configuration” I configured Android Studio to start
the class inside the Java library
Since I wanted to create a pure Java program I removed the app module from the project structure and deleted the app folder as well.
The problem is that, after removing the app module, every time I start the project I need to sync project with gradle files to show the java library folder.
If I do not sync project with gradle files the java library folder is hidden and all other folders and files in the project are highlighted with a yellow color.
Can you tell me if it it is possible to avoid manual syncing project with gradle files at every project startup?
As far as I can tell, this problem is the same as this defect I raised with Google: Task graph, syncing is incomplete for Java modules when running unit tests from UI gesture if there is no Android module
This problem doesn't just cause this syncing issue. It also messes with the task graph such that Java unit tests will not be rebuilt prior to running them, leading to strange errors about missing classes or old test classes being run for days or weeks.
I have found no workaround, other than committing a dummy Android library module parallel to the pure Java modules. The problem with having to force a manual sync should be fixed in Android Studio 3.3.
Also, with 3.3 the task graph seems to be fixed, but invoking Run 'All Tests' on a clean build will still fail the first time. It is making the classes, though, so if you invoke that gesture immediately it seems to work. This may be a different defect.
what is the actual root cause of this issue? I already sync with gradle files but eventually failed.
Just sync your project with gradles. File --> Sync Project with Gradle Files
Build -> Clean Project
Build -> Rebuild Project
File -> Sync project with gradle files . If not worked then try
File -> Invalidate Caches / Restart .
It's work for me !!!
That could be fixed in one or two steps, depending on how nice is Android Studio today:
Try to sync your project with gradle files:
If that doesn't work, invalidate Android Studio caches and restart. That should fix the problem:
The reason behind the first solution not working could be related on gradle cached dependencies problems, but who knows 🤷
This error mostly occurs when you're trying to open Android App from existing application and probably developed using different computer.
Almost all the troubleshoot methods like File->Sync Project, Build->Clean, etc. Might not work.
This is applied only if you are trying to open the Adroid Application from existing application.
The proper way to evoid errors is only to open sub folder from the path not the root folder. Below is the example of how to properly open the Android application from existing application.
For example in your Message_App/messages/msg path, you must open msg folder not your Message_App folder.
Message_App/messages/msg
>msg
>manifests
>java
>res
Just you have to do >> open File --> Sync Project with Gradle Files
and then after >> open File --> invalidate Android Studio caches / restart so done this problem.:)
sometimes Sync project with gradle File dosent work; you should check the compileSdkVersion in the "build.gradle" file , make them is the same number within all library/modlue
This issue is because the gradle file is not found when starting the project. To fix this ensure your connection to the internet is stable during project startup, the gradle file is downloaded automatically, after a successful download, You should be good!
Issue happened to me when I changed the res>values>styles.xml
What I change was
"Theme.AppCompat.Light.DarkActionBar" --->>> "Base.Theme.AppCompat.Light.DarkActionBar"
Solutions I tried.
Build -> Rebuild Project (Not worked)
Close all files and Open again. Then
Build -> Clean Project (Not worked)
File -> Sync project with gradle files (Not worked)
Close the Android Studio while project still opened. Opened it again. - It Worked.
If nothing of the above steps work, Then simply undo the changes that you have recently made, and then build gradle.
In my case, I have added one dependencies and this problem raised, so I removed that dependencies build the gradle and then again add it.
Problem Solved..!!
I had this problem and it was because I didn't have the right API level installed (and I was also getting an error to that effect). I went into Tools --> SDK Manager and installed the API the system was telling me I needed (in my case, 30). I did that and restarted Android Studio and was able to get into XML files.
So far I have updated to Android 1.0 and some of my issues where fixed but the Gradle issue is driving me nuts. I have searched everywhere and none of the solutions work for me I use Windows 8.1
When ever I try to run my program:
Pops up
Failed to complete Gradle execution. Cause:
However the virtual Android still runs and the project is not there and this pops up:
19:32:30 Gradle build finished with 1 error(s) in 9 sec
19:37:15 Unexpected Error
Local path doesn't exist.
Local path doesn't exist.
The project may need to be synced with Gradle files.
Sync Project with Gradle files
19:37:15 Session 'app': error
19:38:29 Gradle build finished in 4 sec
19:44:14 Gradle build finished with 1 error(s) in 3 sec
19:45:16 Unexpected Error
Local path doesn't exist.
Local path doesn't exist.
The project may need to be synced with Gradle files.
Sync Project with Gradle files
19:45:16 Session 'app': error
I try to open Android SDK it wont open I tried to solve that as well by editing android.bat running as admin updating java reinstall everything. Nothing works.
I have updated to the latest Android SDK and set JAVA_HOME in .bash_profile using
export JAVA_HOME=$(/usr/libexec/java_home), and I'm getting the following error:
Error Gradle:
FAILURE: Could not determine which tasks to execute.
* What went wrong:
Task 'assembleDebug' not found in project ':CrystalBall'.
* Try:
Run gradle tasks to get a list of available tasks.
Error: Could not execute build using Gradle distribution
http://services.gradle.org/distributions/gradle-1.6-bin.zip
I've attached a screenshot:
What should I do?
The second error in your screenshot seems more important to me. You have to make sure, that the Android Studio is able to download and execute the gradle binary. If you are using a proxy you have to configure it in the Android Studio.
To check the gradle tasks, go to your project folder on the command line and type "gradlew tasks"
You can also configure a proxy for gradle. Just create a gradle.properties file in (your project folder) with these properties:
systemProp.http.proxyHost=www.example.org
systemProp.http.proxyPort=8080
systemProp.http.proxyUser=userid
systemProp.http.proxyPassword=password
systemProp.http.nonProxyHosts=*.nonproxy.com|localhost
I don't believe this is the issue the poster had, but for the benefit of others I'll add what I found as I was helping someone on Windows XP who was getting the same error.
It appears the issue in his case was that the path to the Android Studio project had spaces in it (since Windows XP uses the Documents and Settings directory). I had him generate a new project into a directory without spaces in it and it built and ran without problems. Might have actually been something else, but as usual it is best to avoid spaces in paths.
I've just been working away normally on my Java project (not Android) in IntelliJ, not doing anything out of the ordinary. It's actually a Niagara 4 project.
For some strange reason, I've just attempted another build and got this:
Unable to find method 'org.bouncycastle.crypto.CryptoServicesRegistrar.isInApprovedOnlyMode()Z'.
Possible causes for this unexpected error include:
Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.)
Re-download dependencies and sync project (requires network)
The state of a Gradle build process (daemon) may be corrupt. Stopping all Gradle daemons may solve this problem.
Stop Gradle build processes (requires restart)
Your project may be using a third-party plugin which is not compatible with the other plugins in the project or the version of Gradle requested by the project.
In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes.
You'll notice the stray 'Z' at the end of the method name. That's not my code: I'm guessing it is what my Gradle build is using to set up the signing of the JAR file I'm building: I have absolutely no idea where the corrupted method call is coming from (nor why it got corrupted in the first place !).
I've tried all the suggestions given by IntelliJ. I've cleaned the project. I've deleted the project's .gradle folder and gone back into IntelliJ to get it rebuilt. I've rebooted.
I'm out of ideas, other than thinking that the corruption is to a binary file as opposed to a readable gradle build or properties file.
Any thoughts what I can try ? It's been suggested I re-install Java (J8) ?
Use bc-fips*.jar
Ref: https://mvnrepository.com/artifact/org.bouncycastle/bc-fips
Conflicts with bcprovjdk15-on*.jar
Which BC provider are you using and of course which release? It could be that the method is deprecated. For example, in the bcprovjdk15-on 1.65 the method is no longer there.