I manage an offline, air gapped, dev environment that supports many different types of coding projects. My most frustrating project to maintain is our Android Studio projects.
Our dev environment is isolated with no access to the internet. When I have to bring a new machine up for a user or bring in updates to the Android SDK it usually involves heartburn with getting the building in sync across multiple systems.
Is there well documented processes for building Android apps manually, somehow forcing the Gradle/maven libraries to point to an easily copied and setup place? I'm thinking C make file like build process. When we ran Eclipse it was easy to spin up a new system, just scp someone else's environment. Is there some alternative to mirroring the Google maven environment internally?
Am I over thinking the Android studio build process?
The Gradle build system needs to download your dependencies and store them. after downloading them, as long as there is no change to the dependency gradle will use it's cached version of it on its own.
Now, as long as your dependency tasks remain UP-TO-DATE (the dependency has not changed) you should be fine without a connection.
You could also manually put the jars and aars of your dependencies and use gradle to use them instead -
Just modify the dependencies to compile your libs dir and not get them online (all those compile 'com.google.android.gms:play-services-location:8.3.0' are just url's of sorts pointing to the location of the files) and place the necessary files in libs
Another way of obtaining the files easily would be to run the project once in a connected environment and getting the necessary jars from .gradle/caches/
I have been working in similar conditions. To make development much easier you should setup repository management system. Two popular options are Artifactory and Nexus. In your build tools repository configuration, you should refer to your repository management tool address. With this setup, every computer in the network has to get the source code from version control and good to go.(no extra configuration is required)
In an enviroment with internet connection you can prepare the repository your projects depending and after transfering these files to internal network upload these to your repository management tool.
Related
If an Android app depends on a library that is developed simultaneously in a separate git repository, it would be convenient to develop them in the same project, but keep the proper remote location of this library as dependency.
So during development I would want to use a local checkout of the dependency, which I can constantly develop alongside the app and push updates to its own repo. Yet the app project's configuration should properly refer to the dependency's remote URL.
In Xcode I can do this easily by creating a Workspace, into which I drag the app project, and the local checkout of the package I want to develop in concert. The app project will then use my local checkout instead of pulling the remote dependency.
Is something like this possible with Android Studio, or what is the best way to have a library from a separate git repository (that is used in other projects as well for example) be developed in sync with an app. I want to avoid changing the API in the library, then pushing, only to then find out that the app project doesn't compile anymore with the latest version for example. If the app project already tries with the local checkout of the library, this is a much better development experience.
Is it possible for example to specify the dependency as local with a fallback to the remote? Then I could check out app and library alongside, but on CI or any other developer's build machine, which doesn't have the library checked out, it would pull the dependency and it would work as well.
I have a utility library, that I'd like to use in several app projects.
I'd like to be able to work on it without having to deploy to a server every time I change something. I need a way to test it in my app before publishing the changes anywhere.
The way I would normally do this is to install the lib to my local maven repository (by local I mean on my dev machine's hard drive), in order to make it visible to the app projects.
Unfortunately, it seems that gradle install doesn't work on Android projects (see this SO question).
So my question is, what's the recommended way to do this and how do most people do? This seems to me as a fairly common use case!
I describe my current workflow. Maybe it helps you, too.
If I develop a library, which targets a special app, I upload a Snapshot build to my local maven repo (upload works). In my app project I reference the Snapshot build. Each time you build the app project Gradle checks for a new Snapshot release. So you definitely use the most current version of your library.
If the library is finished, I upload a finished (no Snapshot) build with a fixed version to my local repository. Later, if I want to extend the library, I increase the version of the library and add the snapshot suffix again.
I'm pretty happy with this workflow. You may want to take a look at one of my build files. In order to upload a Snapshot build, you only need to add the suffix '-SNAPSHOT' to the version string.
If you are already deploying to the maven local, then you can just add that as a repo source for gradle. At least that's what we did:
repositories {
mavenLocal()
}
I want to have the SDK available on both machines and sync the projects via Dropbox. However, since the SDKs for Linux and Mac are different, I have to chose a different SDK folder each time when launching Eclipse. Any workarounds?
I actually did something similar to this a while ago. I found that managing the ADT plugins (and SDKs) separately on each machine was a better solution, since they had path dependencies. I used Google Drive (Dropbox in your case) to hold all of the projects, which was ok at syncing the projects, but tends to run into issues with all the binary files created when building projects. As my projects grew larger, this became a bad solution for keeping things in sync as there were constantly syncing issues due to the amount of files that needed to stay in sync.
The best way to really do this is to use source control to keep your projects in sync, and I strongly recommend Git over CVS or SVN. GitHub offers free public repos and paid private repos while Bitbucket offers free public and private repos. I moved all of my projects to Bitbucket and now have them synced between machines, backed up, have stored histories, and can be shared publicly/privately (if I want).
In my opinion you should move away from using a file syncing service and use source control, it takes a little effort up front but is well worth it in the end.
Try syncing only the actual code files you create, not the project itself (i/e file1.java if you're writing in java, file2.cpp if in C++, etc). You might have to monkey around with adding new files, but that should be as simple as importing/exporting. You're going to have all kinds of trouble syncing paths for 2 different machines...
Otherwise try a free source control like assembla
I have been developing an Android app on a Windows machine. Now I would like to continue development on another Ubuntu 10.04 LTS machine. I would like to move between computers maintaining a recent copy of the project files on each computer. I am using SpiderOak to create a synchronization of the workspace directories of Eclipse which I am using for development. When the files were copied from the Windows machine onto the Ubuntu machine and I ran Eclipse, an error was presented that the path to the java sdk could not be validated and the path shown was the path relevant to the Windows machine.
Is there a simple solution to this? I can imagine that some files regarding the workspace specifics should not be transferred. Can I simply omit transferring the .metadata folder contained in each workspace created by Eclipse? I am not interested in synchronizing preferences/plugins/parts not essential to the operation of the app. Will excluding the .metadata from the sync create another problem in not transferring valuable information regarding the Android app being developed?
The correct, simplest, and most robust way to do what you want is to use a version control system like CVS, svn, git, etc. Even when working alone on a project, its a wise idea, not just for having the code on different computers but also because it gives you all the benefits of version management like being able to rollback changes, etc.
There are many free or inexpensive cvs, svn, and git hosting options; I strongly suggest you get an account and check your code in/out on the two machines you work on. If you have a web hosting provider, chances are they provide one of these services with your account.
If you're going to insist on manually moving/syncing code, you need to know that Eclipse workspaces are NOT designed or intended to be shared. Trying to do so always leads to headaches and other pain. Instead, you can export/import the project(s), not the workspace. Keep in mind that in Eclipse, a Project does not have to be located in the workspace directory; when you create a project there's an option to store it in any arbitrary location on your filesystem. Also note that all files under the project (including .project and .classpath) should be shared, except generated stuff like bin/ and gen/. This applies to using cvs, svn, etc or some other manual syncing mechanism.
As long as I have my project source code on hand, I will never consider synchronizing Eclipse workspace directory for cross-platform development. The correct way is maintain your source separately (by separately, I means do not bind your source to any IDE on any OS, use version control system is always recommended if the condition allows), wherever your want to start development by Eclipse or IntelliJ, on Windows, Linux or Mac, get a copy of you source and import it into your IDE.
Generally, the only files that makes your project a Android Project are:
src/
res/
assets/
lib/ (if you import external jar libraries)
AndroidManifest.xml
project.properties (or default.properties, renamed since r14)
proguard.cfg (if you use Proguard)
If you work within a team and use source control like SVN, these are the only required folders/files that need checked in to SVN, all others (.project, .classpath, .settings/, bin/, target/ and etc.) are not necessary. thoese are iteratively generated by IDE when import and build your project.
This applies to all three Android project type (Android Project, Libaray Project and Test Project), If you are familiar with other build tools like Ant or Maven, it may also helps you a lot to maintain cross-platform development.
I've started work on an Android App that will work with Google Docs.
UPDATE 12/9: From the information I've come across, it seems Google Docs is not supported by this library. The question is probably still relevant in general, but seem not specifically for this project as I can't use the library anyway.
I was doing some research and come across the Google APIs Client Library for Java
I decided to start with the tasks-android-sample to begin learning how to utilize this library.
I followed these instructions
I successfully installed Mercurial and Maven and already had Java 7 installed.
I was able to execute these commands
cd [someDirectory]
hg clone https://code.google.com/p/google-api-java-client.samples/ google-api-java-client-samples
cd google-api-java-client-samples/shared/shared-sample-android
[editor] src/main/java/com/google/api/services/samples/shared/android/ClientCredentials.java
mvn source:jar install
I was also successful in setting up the Mercurial plugin (not sure what this did for me -- I believe the hg command above is the only time Mercurial was involved) and Maven plugin
Finally, I was able to imported the tasks-android-sample, compile it, run it on the emulator and I was able to see the tasks I created on my google account.
I then repeated the process, except this time I simply imported sample's source code and the required JARs into a new Android project and added the ClientCredentials.java manually to the project (So I could specify my Google API Key).
I was also able to compile and run this project and it operated as expected.
My questions in all this is which method is preferred? Or is it a personal choice? Are there benefits to using Maven that I'm not realizing at this time?
Maven helps you download proper dependency libraries for the project, and can reduce the burden of find and download proper libraries.
It's fine to just put dependency libs in your code base. It's a personal choice.