0

Still feeling my way around Android Studio. Looking at a bunch of tutorials and examples out on the web – and I'm finding out that studio must have evolved quiet a bit since it's 1st beta release and that many (perhaps most) of the information scattered out on the web references earlier versions of studio then what I'm currently running and some of the information may no longer apply and even be complexly wrong for my current version of Android Studio. I'm currently running

  • Android Studio 1.1,0
  • Build AI-135.1740770 built on February 18, 2015
  • JRE 1.7.0_71614 amd64x

and my SDK is up to date as of 4/4/15

This has left me with a bunch of questions. My current question is about
import android.support.v4.app.Fragment;

Some tutorials say that when using studio, you need to find the .jar file and manually copy it into your projects .lib folder. Other examples just use the import statement and never talk about needing to manually copy it into your projects .lib folder. Or adding it to the manifest file.

Which method is correct?

Joe Cullity
  • 518
  • 2
  • 8
  • 24

1 Answers1

0

In your app gradle file, you will see a bunch of stuff like android, dependency etc.

Dependency is the place you add your libraries. For eg.

dependencies {
    compile 'com.android.support:support-v4:21.0.3'
}

We use compile to make sure that the project is ready to use in your project and you also see the support-v4:21.0.3, you can always get the correct version no from the dev website or some external souce.

Same way you add dependency for v7 and its gonna be like :

dependencies {
        compile 'com.android.support:support-v7.SOME VERSION NAME'
    }

You probably dont have to use the v4 lib since you are already adding the dependency for app compat. After adding the dependency, trying to clean the project.

To add your own built library project, you will point your app project to the library project you have created and add that to your dependency as the same process as above.

If you want to know more about adding dependency to you android projects, also refer to this link How do I add a library project to Android Studio?.

Hope this solves your problem.

Community
  • 1
  • 1
mike20132013
  • 5,357
  • 3
  • 31
  • 41