• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Help with transitioning from Eclipse/Ant to Android Studio/Gradle, Dependencies

I am transitioning to AS/Gradle from Eclipse/Ant. I am new developer. Well technically since I haven't have any decent app on google store yet. I can code and develop things but not something at par with coporate-ish/enterprise development. I have no idea what exactly is Ant or Gradle except I knew they are build systems. Ant works in Eclipse but I haven't touch this since I believe the IDE do all the nasty low-level stuff for me.

Since Eclipse is no longer officially supported in future developments by Google, I decided to get off the Eclipse IDE and start my development adventures anew with Android Studio. At first it is a pain, I can't even barely understand the documentations provided here and the internal links provided there. I read the Gradle Script basics tutorial but it teaches about how to create task. Somehow I believe I no longer need to know to write build script for now, I just need a documentation on Android Gradle Build scripts.

I successfully migrated my code from Eclipse to Android Studio, everything works well, but I can't get myself ahead building the app with my fingers touching the gradle build script. For me, this is an Egyptian Heiroglyph. It made me feel like I need to get doctoral degree in computer science. For example, I am using Android support v13. I only support API 15 and above. I need to tuck this in the build.gradle file of my project since it will not build without the dependencies here is what my gradle code looks like:

Code:
apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.1"

    defaultConfig {
        applicationId "com.neonwarge.android.note"
        minSdkVersion 15
        targetSdkVersion 23
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }

    dependencies
    {
        compile "com.android.support:v13:android-support-v13"
    }
}

What I don't understand as of the moment is the dependencies' compile section. I build the file and its saying it cannot resolve the dependencies.

I swear to god the "com.android.support:v13:android-support-v13" is a syntax of some sort. Semantics I don't truly understand. I need to access the jar file from SDK folder but I don't know to do it here. I can't seem to find any documentation on what values possible in compile method.

First, what is com.android.support? Is this the folder relating to my SDK folder? I typed v13 believing it would translate as '<SDK FOLDER>/<SUPPORT>/v13/android-support-v13.jar' but I think I am wrong.

Second, I am worried because someday I will use external libraries like, Joda time or Caldroid, who will provide me the correct values for compile? Am I the one to define it? Or the developer will provide me the 'compile <THE VALUES GOES HERE IS LIKE A KEY ON WHERE TO FIND YOUR EXTERNAL LIBRARY>"?

I don't understand this nor could not find any documentation on compile. I don't know what correct values to put there. What do I need to place if I wanted to turn on Material design which requires v4 or v7 support files? How about my own library? How do I address this in compile?

I would appreciate your help. I never knew transitioning from new technical tools can be this hard.

Thank you!
 
If it helps, here's what's in my build.gradle:

Code:
   compile 'com.android.support:support-v4:22.1.1'
    compile 'com.android.support:appcompat-v7:22.1.1'
 
Hey @Jose Jerson Naval Jr ,

The format of gradle's compile statement is actually simple and similar to maven (if you're familiar with it). It's:

compile '<groupId>:<artifactId>:version'

Gradle will find and use the dependency package from a repository (central or local depending on how you set it up). In Android Studio, gradle is by default setup to use "jcenter()" as the main respository. You can go to the jCenter website at https://bintray.com/bintray/jcenter to find more details about the package you want to use (e.g. you can search for "Joda time" or "Caldroid", and you'll find the info about the groupId, artifactId, and latest version of the package).

However, if you're using open sources projects that you find at GitHub, sometimes they also provide the instructions on how to use it with Gradle.

For introduction about gradle in android, you can go here: https://gradle.org/getting-started-android/
 
Thank you guys (AppVisionaire & LV426)! It seems the value of compile is supplied as a sort of id by the developer of the library. I also saw the configuration for this hiding under the module properties > dependencies tab which list dependencies available along with the id on how you will reference them in a gradle.build file. Everything I need will be pulled out from the a central repo like maven or the like, for which I believe gradle will download the file as needed. At least I understand it a bit now.
 
Back
Top Bottom