Office Hours — Today, January 28

Yesterday, January 27

Mark M.
has entered the room
Mark M.
turned on guest access
Jan 28
7:30 PM
Ken
has entered the room
Mark M.
hello, Ken!
how can I help you today?
Ken
View paste (1 more line)
Hi Mark!

I sometimes see Android build.gradle files that include this:

    buildscript {
        repositories { 
            jcenter()
        }


        dependencies {
            classpath 'com.android.tools.build:gradle:1.3.1'
        }
    }

...
Mark M.
what you're seeing is two different forms of creating a project
a typical Android Studio project puts the application code in an app/ module
in that case, there are two build.gradle files: one in the project root, and one in app/
the stuff that you cite appears in the build.gradle that is in the project root
now, it is entirely possible to not bother with an app/ module, particularly if your project is fairly simple
in that case, there would just be one build.gradle file, containing the stuff you cite, plus the stuff that ordinarily would appear in the app/ module's build.gradle file
Ken
Oh, I see -- so the app file doesn't need to specify that, because it is getting that information from the parent (in some sense)? That's cool.
Mark M.
yes
the top-level build.gradle file contains stuff that applies for all of the modules in the project
7:35 PM
Mark M.
whereas app/build.gradle contains stuff specific to the app/ module
7:35 PM
Ken
Oh, that's great -- I rarely look at the Gradle file in the parent folder so I missed some of this...
Mind if I ask another question or two since it's just us at the moment?
Mark M.
go right ahead
Ken
View paste
Ok, looking at the SDK Manger, I see there appear to be three sets of tools, each with their own version number:

Android SDK Tools (24.4.1)
Android SDK Platform-tools (23.1)
Android SDK Build-tools (23.0.2. ...) but can have multiple versions of this one
What's the difference between these and for Build-tools, should we always use the most current version available?
Mark M.
these correspond to the tools/, platform-tools/, and build-tools/ directories of your Android SDK installation
platform-tools/ generally contains binaries that are platform-specific, such as adb
tools/ generally contains stuff that is cross-platform, because it's implemented in Java, like monkeyrunner, draw9patch, etc.
build-tools/ contains the command-line tools used for actually building the app: aapt, dx, etc.
the biggest filesystem difference is that, as you note, you can have multiple build-tools/ installed
7:40 PM
Mark M.
those correspond to the buildToolsVersion value in app/build.gradle
the reason for having N of those is for historical builds, such as checking out a tag from two years ago and trying to build it agani
er, again
the vision is that all the tools are versioned: Gradle, Android Plugin for Gradle, and buildToolsVersion
so that when you check out that tagged set of code, it has in it all the information about how to build the project, including the right versions of all the tools
as it is possible that the stuff you did two years ago would require tweaking if built with today's tools
Ken
I thought it might be something like that -- just seemed strange that we version built-tools but no so much platform-tools and tools...
Mark M.
well, you shouldn't need monkeyrunner from two years ago
or adb
or draw9patch
etc.
Ken
Ah, I see -- so we version what we need to -- smart.
Mark M.
basically, the difference is in tools for building the project versus general development tools
but, yes, it's confusing to look at
I remember the good old days, when we just had tools/ and were happy for it... :-)
Ken
Ha!
7:45 PM
Ken
My last version related question is about dependencies and version numbers like: compile 'com.android.support:support-v13:23.1.1' -- that seems to have two separate version numbers baked into it -- the "v13" and the "23.1.1" -- what's the difference between these two parts and how would we know what the latest version of an available library is? (I could go on using 23.1.1 in my script forever if I didn't update it, right?)
Mark M.
-v13 refers to the minSdkVersion of relevance for the library
so, appcompat-v7 works back to API Level 7
support-v13 contains classes that are relevant for API Level 13+, though it has a transitive dependency on support-v4, which contains classes that are relevant for API Level 4+
the 23.1.1 is the actual version of the library itself, following standard semantic versioning format
they are dumping the -v7 nomenclature for newer libraries, as you don't see that on design, customtabs, percent, etc.
7:50 PM
Ken
Is there a place that lists the latest versions of these (appcompat, support, etc.) libraries?
Mark M.
your hard drive :-)
$ANDROID_SDK/extras/android/m2repository
where $ANDROID_SDK is wherever you installed the Android SDK
7:55 PM
Mark M.
you'll see all of the artifacts and their versions inside of there
that's a local Maven-style artifact repository, what you get from the Android Repository entry in the SDK Manager
Ken
Ah, I see -- and if there's a newer version available, the SDK Manager will offer to update to it...
Mark M.
right
which downloads new files into that directory tree
Ken
It's a bit confusing as the SDK manager just says "Android Support Library" but I'm thinking that may include several of the dependencies I see in a build.gradle file...
Mark M.
there is "Android Support Library" and "Android Repository"
the former is for Eclipse/Ant
or other environments that cannot use AAR files in a Maven-style repository
8:00 PM
Ken
Oh, that's interesting -- confusing too though as I see the Android Support Repository has Rev 25, yet there's all kinds of libraries underneath the m2repository folder with different versions. Must be an overall version number?
Mark M.
yeah, something like that
I don't tend to pay attention to the specific Rev number for that in the SDK Manager
I just update it when a new version is available, and call it good
8:05 PM
Ken
Ok, sounds good -- thanks for all your help, Mark -- more people should take advantage of the fantastic resource you provide!
Mark M.
feel free to tell them that :-)
Ken
Will do. Have a great evening and thanks again.
Ken
has left the room
8:25 PM
Mark M.
turned off guest access

Yesterday, January 27

 

Office Hours

People in this transcript

  • Ken
  • Mark Murphy