To import the SDK take the following steps:
Go to Android Studio | New Project | Minimum SDK
Select "API 15: Android 4.0.3" or higher and create your new project.
In your project, open your_app | Gradle Scripts | build.gradle
Add the Maven Central Repository to build.gradle before dependencies:
repositories {
mavenCentral()
}
Add compile 'com.facebook.android:facebook-android-sdk:[4,5)' to your
build.gradle dependencies.
Build your project.
Or, if you like, you can find the SDK download here(link to facebook
developer site ).
****Looking at above way, I think downloading SDK into your project is same as putting an image in your drawable(permanent and more app size) and providing dependency is to using the SDK components whenever needed by loading the component from the site (temporary when needed and less app size)**** Am I right? If not then please correct.
When you add the dependencies to build.gradle. gradle will download the SDK for you.
What the documentation suggests is that you can manually download the files and put them yourself.
So the difference is do you want the build tool to download for you or to download it yourself.
There are many advantages in making this automated so this is the recommended way.
See this very famous question.
Related
I am trying to do a tutorial for making an Android application using osmdroid with android Studio, but I didn't succeed to use the library I download on https://github.com/osmdroid/osmdroid
My questions are following :
Where do I have to put the folder download at: github.com/osmdroid/osmdroid ? I don't find any libs folder in home/android/sdk.
Which version I have to put in this command:
dependencies {
compile 'org.osmdroid:osmdroid-android:(INSERT_VERSION_HERE):release#aar'
}
instead of INSERT_VERSION_HERE. I don't know how to find it.
Follow the steps at https://github.com/osmdroid/osmdroid/blob/master/README.md
You don't have to download anything manually. Open your build.gradle and add the following lines (or amend your already existing sections):
repositories {
mavenCentral()
}
dependencies {
compile 'org.osmdroid:osmdroid-android:5.6.5'
}
For a list of released osmdroid versions see https://github.com/osmdroid/osmdroid/releases. Currently the newest release is 5.6.5 (as of Feb 4th, 2017).
I've been trying to add the volley library to my android project by downloading this repository https://android.googlesource.com/platform/frameworks/volley and then importing the module to my project by following this guide:
First get latest volley with git (git clone >https://android.googlesource.com/platform/frameworks/volley).
In your current project (android studio) click [File] --> [New] -->[Import >Module].
Now select the directory where you downloaded Volley to.
Now Android studio might guide you to do the rest but continue guide to verify >that everything works correct
Open settings.gradle (find in root) and add (or verify this is included):
include ':app', ':volley'
Now go to your build.gradle in your project and add the dependency:
compile project(":volley").
When gradle tries to sync the project after I've imported the module i get the following error message : Error:Could not download layoutlib-api.jar (com.android.tools.layoutlib:layoutlib-api:24.3.1): No cached version available for offline mode.
I believe you want to use Volley and not contribute to the volley library. if that is the case there are better ways to get volley in your project. let Gradle handle it. Gradle is Build Management tool just like Maven but better, As it gives you more freedom and flexibility.
How to add libraries to gradle in android studio. this link shows a how to add libraries to your android project.
As Android Studio uses Gradle things are pretty neat as it uses the middle ground of ANT and Maven for Build and Management tool.
for volley you can add
compile 'com.mcxiaoke.volley:library:1.0.19'
to the app module of your project. this library can be looked up on Github
or you can do that using android studio's GUI, click on File -> Project Structure
example
I'm following a tutorial to integrate facebook sdk in my android project, I'm using eclipse currently , tutorial is asking me to define repositories { mavenCentral() } in build.gradle file , but I don't know in which file I've to add this in eclipse... ant.properties, project.properties or any other file?
I've read some related threads , but I could not find in which file I've to change.
Defining Repository in Maven
maven repository eclipse project
You are working in Eclipse and the tutorial asks you to add the Maven central to your Gradle configuration which you (properly) don't have in Eclipse.
You basically have two options:
Get a Gradle plugin for Eclipse (like this: http://marketplace.eclipse.org/content/gradle-integration-eclipse-44)
Get Android Studio (http://developer.android.com/tools/studio/index.html), where Gradle is already an integrated part of the IDE.
Both options means that you have to get your head around what Gradle does, and how it works, but it'll properly be worth the effort.
I'm trying to implement a Facebook Like Button in an app and I just found a good library: Facebook Like Button by shamanland.
Now the problem is that I'm using Eclipse and I can't figure out how to import this project correctly in order to use it in the app.
Can anyone help?
Thanks!
That project uses the gradle build system, but eclipse uses the ant system.
Google is leaving ant and migrating to the new gradle system which is used with their new Android Studio IDE. Most of the new libraries also are migrating to gradle due to easy dependency management.
This is a good time to migrate your project to Android Studio.
Download it and when you import your project, it will automatically convert it to gradle.
Then you can easily add gradle libraries to your project's build.gradle, and it will take care of downloading and maintaining them.
For this particular library, you have to add the following to your build.gradle:
repositories {
mavenCentral()
}
dependencies {
compile 'com.shamanland:facebook-like-button:0.1.6'
}
You can also download the Gradle plugin for Eclipse, but it may not be fully compatible with ADT. It's better to use the Android Studio and avoid the headache.
More Info Here
You may download compiled aar file from the Maven Cental.
Just import this aar into your Eclipse project as standalone library.
I'm using Android Studio with an external Android SDK. I have installed the support library and the support repository. The support repository is in:
~/Development/Tools/android/sdk/extras/android/m2repository
When I add a dependency to the support library in the build.gradle file, like:
...
repositories {
mavenCentral()
}
...
dependencies {
compile "com.android.support:support-v4:18.0.+"
}
Android Studio cannot find the support libraries (cannot resolve symbol etc) and Gradle also cannot find the libraries:
Gradle: A problem occurred configuring project ':TestAndroidStudio'.
> Failed to notify project evaluation listener.
> Could not resolve all dependencies for configuration ':TestAndroidStudio:_DebugCompile'.
> Could not find any version that matches com.android.support:support-v4:18.0.+.
Required by:
TestAndroidStudio:TestAndroidStudio:unspecified
How do I specify in Android Studio and/or the build.gradle file the location of the Android support repository?
You are probably hit by this bug which prevents the Android Gradle Plugin from automatically adding the "Android Support Repository" to the list of Gradle repositories. The work-around, as mentioned in the bug report, is to explicitly add the m2repository directory as a local Maven directory in the top-level build.gradle file as follows:
allprojects {
repositories {
// Work around https://code.google.com/p/android/issues/detail?id=69270.
def androidHome = System.getenv("ANDROID_HOME")
maven {
url "$androidHome/extras/android/m2repository/"
}
}
}
Gradle can work with the 18.0.+ notation, it however now depends on the new support repository which is now bundled with the SDK.
Open the SDK manager and immediately under Extras the first option is "Android Support Repository" and install it
Found a solution.
1) Go to where your SDK is located that android studio/eclipse is using.
If you are using Android studio, go to extras\android\m2repository\com\android\support\.
If you are using eclipse, go to \extras\android\support\
2) See what folders you have, for me I had gridlayout-v7, support-v4 and support-v13.
3) click into support-v4 and see what number the following folder is, mine was named 13.0
Since you are using "com.android.support:support-v4:18.0.+", change this to reflect what version you have, for example I have support-v4 so first part v4 stays the same. Since the next path is 13.0, change your 18.0 to:
"com.android.support:support-v4:13.0.+"
This worked for me, hope it helps!
Update:
I noticed I had android studio set up with the wrong SDK which is why originally had difficulty updating! The path should be C:\Users\Username\AppData\Local\Android\android-sdk\extras\
Also note, if your SDK is up to date, the code will be:
"com.android.support:support-v4:19.0.+"
Android Studio 3
Make sure you have the latest version of Android Studio. The support library is included by default when you create new projects. If you are adding the Support Library to a project that doesn't have it, then you just need to add a single line to your app module's build.gradle file, and then sync gradle.
build.gradle
dependencies {
...
implementation 'com.android.support:appcompat-v7:27.1.1'
}
It should just be that easy, though there may be some things to note:
Android Studio should give you a warning nowadays if the support library needs to be updated. Just update the 27.1.1 numbers that I have here to whatever it tells you to. You can also manually check what the latest revision is if you want to.
The implementation keyword replaces compile that was used in Android Studio 2.x. (What's the difference?)
There are other support library packages that you may need to include depending on what your app uses (like constraint-layout or recyclerview).
Make sure that you have the latest updates for everything in the SDK Manager. Go to Tools > SDK Manager.
Documentation
Support Library
Support Library Setup
Support Library Features
I used to get similar issues. Even after installing the support repository, the build used to fail.
Basically the issues is due to the way the version number of the jar files are specified in the gradle files are specified properly.
For example, in my case i had set it as "compile 'com.android.support:support-v4:21.0.3+'"
On removing "+" the build was sucessful!!
Instead of doing this:
compile "com.android.support:support-v4:18.0.+"
Do this:
compile 'com.android.support:support-v4:18.0.+'
Worked for me