I am new to Android Studio, and thanks to my dog knocking water on my Mac, I am using my PC with Windows 10 for the foreseeable future. Since I'm trying to learn Android Studio while also trying to pinpoint all the bs Windows is doing in the background, I have been beating my head against the wall for several days. To start, the PC I'm using has a 128GB SSD and a 1TB HDD, and since Windows is busy filling up my C: drive (the SSD), I am trying to keep everything else on the HDD. I originally installed Android Studio and went with the defaults, which put it on the C: drive, but when I realized what happened I uninstalled it and re-installed it on the D: drive. I also installed all the SDK tools and API versions on the D: drive.
The problem I am running into is every time I try to import a project from a tutorial, it says the project isn't synced with Gradle (these tutorials are all using older APIs and Gradle versions) and won't even give me the option to build. Originally, I set the GRADLE_HOME environment variable for the Gradle version installed on my D: drive to D:\Program Files\Gradle\gradle-4.8-bin\gradle-4.8\bin and then I could at least run the gradle command without getting "command not recognized...". At that point, the new projects I had created were running fine, but any project that used an older version would not sync. I guessed that I might need to install the older Gradle versions in order to be compatible with older projects, so I installed all of them and put them in the same D:\Program Files\Gradle directory, then set that to my environment variable. That broke everything since the variable was no longer pointing to a bin folder I assume. Now when I try to import a project using Gradle external model, it doesn't matter if I select the specific Gradle path to the /bin folder on the D: drive, or if I set it to C:\Users\brand.gradle, it says 'Gradle location is incorrect'. The only way I can make the gradle command work is if I go to the /bin folder for any one of the versions I have installed, and run it from inside the directory.
I know that when Android Studio installed it put the gradle configuration in C:Users\brand.gradle, part of the reason why I thought changing the GRADLE_HOME variable might fix it. Currently, the gradle command will not work if I am in the C:\Users\brand.gradle directory. I have researched a lot but can't seem to find clear answers, especially in regards to the newest versions of everything, so here are my primary questions:
Where does AS store and look for the gradle configuration on Windows by default (not for an individual project, but for Android Studio itself), and how can I get it to store and look for things on the correct drive?
Do I need every gradle version installed to be able to run projects that use older versions, and if so, is there a way that Android Studio can automatically find the appropriate version if they are in the right location?
In short, I want AS to do everything on my HDD, where all of the SDKs and gradle versions are installed, but I think it is looking in the wrong places by default, and perhaps even changing things back to default values after I change them. I want this to stop, but can't figure out what it's doing.
If you are running android Studio version 4.1.2 then go to Files -> Setting -> to
Build, Execution, Deployment, click on Gradle and it will show you the Gradle user home, it is here that you can change the directory. But make sure you copy over the Gradle files first to the external drive.
Related
I am having a lot of trouble for what should be an easy task. I'm trying to build a simple Java project (just Hello World) with Gradle for one of my courses before classes begin. I cloned the repository, downloaded all the relevant software, and tried gradle build on the command line. I get the error Supplied javaHome must be a valid directory. You supplied: C:\Program Files\AdoptOpenJDK\jre-8.0.282.8-hotspot. This file that shows up was a previous version that I had removed.
I tried reinstalling everything, and I also checked the JAVA_HOME environment variable, which is set to C:\Program Files\AdoptOpenJDK\jdk-15.0.2.7-hotspot\. I've also relaunched the terminal and rebooted my computer. I'm using Git Bash as my shell, if that's anything relevant. Any advice on how to change the supplied javaHome?
Here are some relevant screenshots:
Result of gradle build
Result of java -version
JAVA_HOME environment variable
My (very sketchy) solution is to make a copy of the existing jre15 folder I have and rename it to jre-8.0.282.8-hotspot. I can build and run my program now, but it just seems very sketch.
One year update: I asked my prof when classes started when he said this solution was actually pretty ok and would suffice for the semester.
I had a similar problem building a Java app on GitHub Actions. Once I upgraded from Java 11 to Java 16 I started to get the same error as you.
In my case it turned out to be a caching problem. I was caching two directories:
~/.gradle (on windows this should be something like C:\Users\username\.gradle)
project/.gradle (this one is the gradle directory that is local to my app project).
Invalidating the caches fixed the issue for me.
I had a similar problem after uninstalling a Java version with Gradle deamon running. Stopping the deamon fixed the issue for me:
gradle --stop
(Probably, a cross-platform equivalent of Miguel's solution)
Update gradle(gradle-wrapper.properties) version from Android Studio to the lates version
For me i just deleted the .gradle in my folder C:\Users\username\.gradle.
With Android Studio, dependencies are automatically reinstalled
I have a problem showed on this screenshot:
Android Resolver
JAVA_HOME environment references a directory (C:\Program
Files\Java\jdk1.8.0_212) that does not contain java which is required
to process Android libraries.
The problem has appeared when I imported GoogleMobileAds package to insert AdMob ads to my project. I tried to create 2 local variables "JAVA_HOME" and "PATH" in environment variables using this guide https://null-code.ru/solution/157-reshenie-exception-jar-not-found-windows.html , but it doesn't help me.
It is a Unity bug. To fix:
Edit->Preferences->External Tools
Uncheck Android SDK Tools Installed with Unity (recommended)
Press Browse -> It might update the filepath
Recheck Android SDK Tools Installed with Unity (recommended)
Then:
Assets->Play Services Resolver->Android Resolver->Resolve
This has been tested and works with Unity 2019, Unity 2020, and Unity 2021.
try
Assets-> Play Services Resolver-> Android Resolver-> Delete Resolved Libraries
check is your Java set true or not:
go to cmd and type JAVA -version
if this appeared means your JDK is set if not check this link: https://confluence.atlassian.com/doc/setting-the-java_home-variable-in-windows-8895.html
after these, if you have the problem again update your JDK
from https://www.oracle.com/technetwork/java/javase/downloads/index.html
i was using admob plugin in my project and this is how i resolved the issue after trying all given solutions.
reimport the admob plugin / plugins you are using in your project. (i just reimport the latest version of admob plugin and issue resolved)
For me it was similar to this answer https://stackoverflow.com/a/57361245/2149955 but just a bit different so sharing a separate answer for when you haven't installed the tools through unity hub.
In Unity:
Edit->Preferences->External Tools
See error messages "You are missing the recommended <TOOL>. Install the recommended version using Unity Hub"
In Unity Hub:
Installs -> My Unity Version -> ... -> Add Modules, Twirl open Android Build Support -> Check Android SDK & NDK Tools (I also checked OpenJDK)
Press Next -> Accept Terms
Wait for install to finish
After that finishes, back in Unity:
If you look in external tools again, the error messages will be gone
Assets->Play Services Resolver->Android Resolver->Resolve
Update to Unity 2019.4.10f
fixed it
When I wanted to make an app for Android, I got this and many more as errors. Nothing worked, including the solutions here. I tried both Unity versions 2020.3.5f1 and 2019.4.22f1, it didn't work.
I figured out that the problem was due to "Android Built Support" not being fully installed. I did the following and the problem was gone:
Unity Hub (my version 2.4.3) -> from the left menu, go Installs
Click the 3 dots in the upper right corner of the Unity version you want (I used 2019.4.22f1) -> Add Modules
From Platforms, find "Android Built Support"
Its check box was checked because I installed it before, but if you don't have it, first install it
Display its submodules with the arrow to its left; "Android SDK & NDK Tools" and "OpenJDK"
Check their check boxes, next and install
Restart Unity
When you open the project, it resolves
It gave me another warning after the resolve, so I made sure that the problem was gone by doing "Assets->External Dependency Maneger->Android Resolver->Force Resolve" in the project again.
I faced this error when I wanted to build for Android. The reason I have faced this is that I had 2 Unity versions (2019.4.9f1 and 2020.3.3f1), and my JAVA_HOME was configured to use the java folder inside 2019.4.9f1. I then uninstalled and removed 2019.4.9f1, and after that, I got this error when trying to build in 2020.3.3f1.
I changed my JAVA_HOME variable permanently, following the link below:
How to set JAVA_HOME in Mac permanently?
Restarted my Macbook.
Went to Unity -> Preferences -> External tools, unchecked NDK, JDK, etc., clicked the Browse button that appeared, and selected the folder under 2020.3.3f1 manually for JDK.
(In the end, no folder should change when you uncheck and check again)
Simple fix. I got this message about Missing the JDK. If you have one that is similar or pointing to the wrong JDK you can try this fix.
Here is the Error I was getting:
I solved this by:
In Unity goto "Edit->Preferences->External Tools"
Unchecked the box "JDK Installed with Unity (recommended)", and noticed that the Path was pointing to an Old version of Unity I had uninstalled.
Changed the Path to the current version of Unity I am usings, OpenJDK directory.
Re-checked the box "JDK Installed with Unity (recommended)"
Then was able to build my game, and build to my android phone just fine.
Note: If your having problems with the SDK or NDK you could try this solution, by unchecking, and re-checking their respective boxes.
This Worked For me:
If u had rectified
JAVA_HOME,
JDK SDK files &
every possible way and solution does not show up try
preference -> in android untick the JDK installed..,
if you see a change in directory then just re tick,
copy path of JDK and uncheck,
finally paste the path close(x) preference TRY BUILD & RUN
Next time you open Unity Editor then try to check & uncheck JDK we have to see the same directory both ways
there is no sdk if you install unity editor without hub.
it seems unity want to use the versions they want. so it's very poor support for previous historty version.
there is a workaround. you can install a version offically recommanded.
and then copy the sdk, ndk, openjdk folder from the offical version folder to the folder you are using. for windows, these folder is like this:
from:
C:\Program Files\Unity\Hub\Editor\2021.3.21f1c1\Editor\Data\PlaybackEngines\AndroidPlayer\OpenJDK
to:
C:\Program Files\Unity\Hub\Editor[your_version]\Editor\Data\PlaybackEngines\AndroidPlayer\OpenJDK
After I recently installed the latest Eclipse ADT bundle I get some errors in an old project I was working on:
No known package when getting value for resource number 0x7f080028
android.content.res.Resources$NotFoundException: String resource ID #0x7f080028
at android.content.res.Resources.getText(Resources.java:222)
at android.content.res.Resources.getString(Resources.java:275)
at android.content.Context.getString(Context.java:183)
...
In my R-file there is the correct connection between the string I'm looking for and the resource ID.
I tried several things to solve my issue:
clean all projects
rename all resource-names to lower case names
restart computer
I used "adt-bundle-windows-x86_64-20130522" (it compiled without runtime errors) before and downloaded "adt-bundle-windows-x86_64-20140702" because of an error occurred during an update.
Any suggestions?
EDIT: Looks like a new build-tools version (21.0.2) has been released that addresses this issue! The best fix is now to update to this version, rather than revert to an older version or swap out aapt.exe files.
My short answer: use an older version of the Android SDK Build-tools, for now. There's likely a bug with including certain types of files in the assets directory in versions 21 and 21.0.1 of the build-tools--or at least that's why I was receiving the error messages after updating.
My long answer:
I just spent the better half of this morning with the same issue. Frustratingly enough, only two out of three of the projects I work on presented it, but it at least gave me a starting point. I found that the failing projects included a zip file in their assets folders while the working project did not. Removing this zip file allowed all apps to run, but that's obviously not a good enough solution.
I'm going to go out on a limb here and assume that there's a bug in the newest Android SDK Build-tools release (revisions 21 and 21.0.1) that fails to properly build the APK if there's a zip file in the assets folder with certain properties (I didn't research enough to figure out the exact triggers). Just zipping an empty text file wasn't enough to trigger this, but I managed with a small 13KB zip file. I don't know whether any other types of files cause this.
For an immediate fix I just went back to using an older version of the build tools. As seen here, that involves modifying the project.properties file to include sdk.buildtools=20 (for Eclipse users) or the build.gradle file to include buildToolsVersion "20" to the android section (for Android Studio users). Version 20 worked to get me back up to speed, while version 21 breaks my apps. Your current list of installed Android SDK Build-tools versions can be seen in the Android SDK Manager, under Tools.
I was facing the same issue for the past 3 hours, after tiring search of Google and other websites
came to a conclusion that this error (Cannot resolve symbol :R )
occurs specially with gradel tools version 21.0, 21.0.1, 21.0.2 and 21.1
BUT it is resolved in build-tools 21.1.1.
For Android IDE users , following steps can work.
go to your project's Gradel Scripts folder.
select the folder build.gradel(app) { not the other build.gradel("your mainActivity classname").
open the build.gradel(app) file,
CHANGE the buildToolsVersion to "21.1.1" from your old buildToolsVersion..
4.Sync your project one more time.
5.That's it.
It worked for me.
I have eclipse and the ADT bundle correctly installed on my home PC, and tried to install it on my laptop so I can work on my projects on the go. However, I either didn't set the java paths correctly, or installed them in the wrong place, because I can't get a default project to load without errors.
I have correctly:
-Installed the ADT bundle and launched eclipse without errors
-Created a workspace
-Correctly Installed both the jre8 and jdk1.8.0_05 in the location C:\Program Files\Java
I am very new to Android development, and I feel like I was lucky to set up the Java dependencies correctly on my home PC, no such luck this time from what the error look like...
However, when I try to make a basic "Hello world" project, I immediately get the following error:
The container 'Android Dependencies' references non existing library 'C:\Users\userName\workspace\appcompat_v7_3\bin\appcompat_v7_3.jar'
I have tried adding the library, by checking build configurations, but I don't understand fully whats going on to correctly solve the problem. Here is my workspace:
And lastly, I tried checking the build configurations to see that the libraries are, in fact, missing. Or something like that. I am not sure if I should just try to reinstall java and the jdk.
Build configuration:
Anyway, I'm not sure what I deleted, misplaced, uninstalled, or didn't install, but if anyone could point me to a solution I would be very grateful. If anyone has any other questions on my setup I will try and be as thorough as possible. Thank you!
In my experience I have had issues like this if not running eclipse as Administrator. Make sure that you aren't being blocked here.
EDIT: Please note Chris Stratton's concers regarding running an IDE as Administrator, as seen in the comments below.
EDIT 2: In my more recent experience, I have noticed that if I installed the SDK by copying and pasting the contents of the downloaded, compressed, folder to a destination rather than extracting it first, I would be required to run as Administrator. If this is the case, delete the SDK that you copied out of the compressed folder and simply extract the contents of the downloaded compressed folder. I am running Windows 7 so it is likely that this applies to all Windows 7 and 8 OS's.
In another case, I have also seen issues like this if the JRE is installed second rather than first. In this case, a reinstall of the SDK is probably all that is required.
After installing tomcat 6 on machine , my existing eclipse stops working and on ubuntu software center it showing the option to install eclipse. When I tried to install eclipse I am getting the following error
The following packages have unmet dependencies:
eclipse-platform: Depends: eclipse-platform-data (>=
3.8.0~rc4-1ubuntu1) but 3.8.0~rc4-1ubuntu1 is to be installed
Depends: eclipse-rcp (= 3.8.0~rc4-1ubuntu1) but 3.8.0~rc4-1ubuntu1 is to be installed
Depends: liblucene2-java (< 2.9.5) but 2.9.4+ds1-4 is to be installed
Depends: sat4j (< 2.4.0) but 2.3.1-1ubuntu1 is to be installed
Any ideas to fix this ,
I got stuck in the middle of my work.
Simple: Don't install Eclipse using a package manager. Just download the tar.gz archive from eclipse.org and unpack it anywhere. 3.8.2 is here.
Some background: Eclipse comes with its own package manager (p2). P2 doesn't like when someone else messes with its world. Linux package manager try to modify the p2 config files in such a way that p2 doesn't notice but eventually, this fails.
Word of advice: You can now install plugins using the help menu. Every time you install a new plugin, make a backup of the Eclipse folder and your workspace. P2 has some very ugly bugs and when it gets into a "I don't wanna work anymore" state, it's next to impossible to heal it.
Keep those backups in a safe place. You will eventually need them. And yes, I imply that you will need the 5th last backup eventually.
Note: To work, Eclipse just needs the files inside of its installation folder and in the workspace/.metadata folder. If they get damaged, it won't work anymore. That also means that installing packages using your package manager can't break Eclipse anymore.