I'm migrating an Android build system from ADT to mostly-out-of-the-box Ant and would like to make it as painless as possible for devs. A fresh checkout doesn't contain local.properties (as advised, and which makes perfect sense), and the build yells at you:
sdk.dir is missing. Make sure to generate local.properties using
'android update project' or to inject it through the ANDROID_HOME
environment variable.
Either of these steps is tedious enough that doing it after every fresh checkout is unsavory under Windows. Given that the ADT knows the SDK location (and that's all we really need), is there any way to spit the file out without having to drop into cmd drill into Windows env vars?
I tried Project > Android Tools > Fix Project Properties, but that doesn't seem to take care of local.properties.
There's no way to do it. Eclipse with ADT uses a different mechanisms for some parts of the build project.
I'm not sure why setting ANDROID_HOME is tedious to do after every checkout. You only need to set it once.
Related
I have set an environment variable ANDROID_HOME, which points to my android SDK location. However, every time I open my project in Android Studio it places local.properties file to the root of my project and copies my SDK location from ANDROID_HOME to this file. I want Android Studio use ANDROID_HOME directly, without generating local.properties.
Why? I'm on Windows 10 and I use Bash for Windows. I want to run command line using Bash while running Android Studio from Windows. For this I need two ANDROID_HOME environment variables, one for Windows, one for Bash. This is because although they point to the same (windows) android SDK the format is different, for Windows it is C:\Users\me\Android SDK while for Bash it's /mnt/c/Users/me/Android SDK. When Android Studio creates local.properties with windows path Bash becomes broken since apparently local.properties takes advantage over ANDROID_HOME, so I have to delete it manually.
You might find this article useful:
Posix path conversion (mingw.org)
The gradle android plugin "Application" extension
(your regular gradle-android interface) has a property
sdkDirectory. Perhaps this can override it? I can't check.
I think there is a configuration switch for bash on Windows to parse path separators Windows-like, can't seem to find it, it is buried deep inside MinGW or MSYS docs I think.
Last resort - git Hooks. Read the ProGit book chapter on Hooks.
The Android will generate this file always when gradle sync it. But if you delete it and define ANDROID_HOME and ANDROID_NDK_HOME environment variables, every time that generates it will read ANDROID_HOME and ANDROID_NDK_HOME.
If you want to build your project in many computers with different home folders, just keep the local.properties outside the source version control.
I'm preparing an Android build pipeline in Jenkins, on a Windows build server. Jenkins uses a number of workspaces and will often re-use them. I've noticed that when Jenkins re-uses a workspace, there are no problems and a build goes perfectly. But when it first checks out a new workspace, the gradle wrapper complains that it cannot install Android build-tools. The build tools (the exact version) are already installed.
I can open another older workspace and run the gradle build in there and it works perfectly and then, with the same login and in the exact same cmd session, go to the new workspace and run the same command and it complains that it cannot install Android build-tools.
A note about the Android configuration: I'm storing the Android SDK in C:\android-sdk\ and have given every user access to that directory. ANDROID_HOME and ANDROID_SDK are set as system-wide variables. This is the most convenient solution- this way every user that logs in, domain account or otherwise, is (in theory) able to immediately build the solution without having to set up their own SDK, and we don't end up with a lot of duplicated SDK data.
I can fix the issue manually by opening the workspace folder in Android Studio. Just doing this alone seems to fix the issue. My hypothesis is that somewhere there's a cached value in the project metadata telling gradle where to find the Android build-tools, and when I open Android Studio it updates this value.
Obviously the work-around isn't adequate because the build needs to work consistently every time without human intervention. Is there some command I can use to refresh this cache? Or perhaps some configuration files that are checked into git that shouldn't be?
Figured it out. Gradle looks in two places, in order of priority, for your SDK: Firstly, it checks whether a local.properties file specifies the SDK. Then, it tries the ANDROID_HOME (not ANDROID_SDK) system variable. Opening a folder in Android Studio generates the local.properties file, which is why that work-around worked.
I had no local.properties file, but my ANDROID_HOME was set to the Android Studio install folder rather than the Android SDK. When I moved it to the SDK and re-started the Jenkins agent service it worked.
We decided to use GitHub as our version control. I know the Gradle build scripts use certain paths, such as the Android SDK path in the local.properties file.
Since this path will differ between the five of us, I think the projects will fail to build on my teammates' machines when they pull changes from GitHub. Is this correct?
If so, can we all make an environment variable called something like ANDROID_SDK and use that for the sdk.dir in the local.properties? Would the project properly build on all of our machines if we used the environment variable? Are there any other places where we may need to set
a similar environment variable? Will this work? If so, how do we do this?
I am not sure if this is the best way to go about setting up a team project for Android. I'm looking for suggestions on a best practice for this.
Is this correct?
No, because IMHO local.properties should not be in your Git repo. The standard Android Studio .gitignore file (created when you create the project) has local.properties, meaning that local.properties would not be committed to your repo.
As Doug Stevenson points out in a comment, local.properties is generated when you import a project. It will be driven by Android Studio settings.
can we all make an environment variable called something like ANDROID_SDK and use that for the sdk.dir in the local.properties?
Not for use with Android Studio, at least the last I tried it. For command-line Gradle builds, that works fine, but Android Studio does not pass the environment to its forked Gradle process.
So, I've been trying to build a project in LibGDX for about 10 hours now. In case you'r unfamiliar, LibGDX is one of those platforms where you specify a project directory at the start, along with any required SDKs and then when you're ready to start coding it will generate a project for you.
Anyway, I've been having a problem where every time I try to build it fails with the single error message:
Execution failed for task :core:compileJava.
Could not find tools.jar
I'm guessing "tools.jar" is a package within the Android SDK, as this is the only repository needed to build, it doesn't ask for a JRE or even the Java SDK. just the Android SDK.
I have been looking in the SDK manager, I have installed all of the packages labelled "Android-SDK Tools", "Android-SDK Platform Tools" and "Android SDK Build Tools" but there is nothing else that includes "tools.jar", I am looking for some light shed on this topic as it is a very grey area. I would like to know where this .jar file comes from and what exactly it includes. Can it be installed from the Android SDK?
There have been similar questions like this before which only fit narrow situations, If someone could provide a holistic description of the tools.jar package it would benefit a great deal for me and everyone else that needs it in their 3rd-party android IDEs.
For the record, it's building with Gradle and my current SDK is well-equipped enough to build full-fledged apps in Android Studio.
Please don't answer this question with a question unless I have left out some information that is dire to finding an adequate solution
Try copying tools.jar from %JAVA_HOME\lib to Android Studio\lib
For me, copying tools.jar to Android lib folder alone didn't solve my problem.
But I also had to create a System Variable 'JAVA_HOME' in Windows Environment Variables with path to the latest JDK folder.
Restarted Android Studio, and this solved by problem.
My Android Studio Version: 4.2.1
The "tools.jar" is provided by Oracle JDK which is required by android studio for compilation - I have faced this issue after updating android studio to latest version in my PC.
To Resolve the issue follow below steps:
In Android studio File -> Project Structure -> SDKs (Under Platform Settings)
A) Add JDK path by pressing '+' symbol in middle pane if suppose JDK/JDK home path is not present in the middle pane already (Middle pane also contains the Downloaded Android SDK's)
B) Java sdk will be usually present/installed in the path
64 bit => "C:\Program Files\Java\jdk1.X.Y_ABC" (In my PC it is 1.8.0_202) or
32 bit => "C:\Program Files (x86)\Java\jdk1.X.Y_ABC"
If suppose you don't have JDK installed in your PC, please download and install from Oracle Java website
https://www.oracle.com/java/technologies/javase/javase-jdk8-downloads.html
Set JDK and JRE Path(Download both from webpage mentioned in step 2) in system environment variable
A) Press windows key type "Edit the system environment variables" and open the application
B) Go to Advanced -> Environment Variables
Under system variables add JAVA_HOME and JRE_HOME as below
Set Windows system environment variable
Add jdk lib path on the Path environment variable under user variables (this step is required only if the error not resolves with the previous steps)
C:\Program Files\Java\jdk1.X.Y_ABC\lib
In my case, I have five jdk and some have tools.jar and other not, my solution is copy paste this tools.jar in all lib of jdk.
Nothing worked for me. So I Copied tools.jar and pasted it in C:\Users\UMAR_\AppData\Local\Android\Sdk\platforms\android-30 which is the path to the library for the Android API 30 Platform. I pasted tools.jar in every folder and it start working.
I didn't have tools.jar initially but followed this link and downloaded https://www.oracle.com/java/technologies/javase/javase-jdk8-downloads.html
Also added to a environment variable.. but what worked was in the first para, I still don't know if adding to variable was necessary or not.
I am having some problems with getting started with my first Cordova app in Visual Studio.
When I create a new Cordova Project, I am presented with a page that says:
We've detected issues with your system's environment configuration
And it lists 3 things that need to be installed:
Android SDK The software is missing from your system. You may also have to configure it after installation. Instructions
Apache Ant The software is missing from your system. You may also have to configure it after installation. Instructions
Git CLI The software is missing from your system. You may also have to configure it after installation. Instructions
I already have the Android SDK installed. So how can I let Visual Studio know where it is? A search for this on Google did not yield any results that were related.
Searching for Git CLI did not yield any results. How do I install this?
I haven't even tried installing Apache Ant yet because I can't get past the other two.
How can I install Git CLI and how do I let VS know where my Android SDK is located?
P.S. I am aware that each of those list items has an 'instructions' link, however, I am unable to access those pages, they say "Webpage is not accessible" in Chrome, Firefox and IE (and Spartan).
I guess you have already installed Tools for Apache Cordova.
Once you did that and you can't install them with the tool, download them manually in their official websites. You can then add the path for these items in :
Tools > Options > Tools for Apache Cordova > Environment Variables
Here is a screen of mine :
I hope it helps
Not sure these are solutions, but something to check for:
If you're using VS2013, ensure you have update 4. Visual Studio Tools for Cordova only relies runs on VS 2013 and 2015.
Of course, ensure you have the latest Tools for Cordova CTP 3.1 (http://www.microsoft.com/en-us/download/details.aspx?id=42675)
In my system path, I have C:\Program Files (x86)\Android\android-sdk\platform-tools. I have ANT_HOME as a system/environment variable set to C:\apache-ant-1.9.3. I have ADT_HOME as a system/environment variable set to C:\Program Files (x86)\Android\android-sdk. I have GIT_HOME set to C:\Program Files (x86)\Git.
Setup your PATH environment variable on Windows
From the Desktop, right-click My Computer and click Properties.
Click Advanced System Settings link in the left column.
In the System Properties window click the Environment Variables button.
Select the PATH variable from the System variables section.
Select the Edit button.
You need to add the path to your Android SDK platform-tools and tools directory. In my example I will use "C:\Development\android-sdk-windows" as the directory the SDK is installed in. Append the following text into the text box:
;C:\Development\android-sdk-windows\platform-tools;C:\Development\android-sdk-windows\tools
Save your edit. Close the Environment Variables dialog.
Additionally, you may need to include %JAVA_HOME%\bin to your PATH as well. To check to see if this is required, run a command prompt and type java. If the program can not be found add %JAVA_HOME%\bin to the PATH. You may need to specify the full path instead of using the %JAVA_HOME% environment variable.
Finally, you may need to include %ANT_HOME%\bin to your PATH as well. To check to see if this is required, run a command prompt and type ant. If the program can not be found add %ANT_HOME%\bin to the PATH. You may need to specify the full path instead of using the %ANT_HOME% environment variable.