Using GitHub project in Android Studio - android

I know there are already similar question but I still could not find a way to do this:
I want to import and use the following GitHub project in my own Android Studio project:
https://github.com/shamanland/floating-action-button
The owner say in another topic to just add a dependecy:
dependencies {
compile 'com.shamanland:fab:0.0.5'
}
I already tried:
repositories {
mavenCentral()
}
But it did not help. Could someone please explain how to add such GitHub projects the easiest way?

There are two gradle files..You should add dependancy in inner build.gradle file. In outter build.gradle file you should add repositories...

Related

Adding Github repo to Android Studio Dependencies Using Maven

I'm currently attempting to include this github repository to my android studio project. I tried following the instructions given in this question but to no avail.
I've added the line maven { url "https://jitpack.io" } to my project build.gradle as well as this line compile 'com.github.karussell:snacktory' to my module build.gradle file and I get a failed to resolve error. In the question that I linked earlier, it says to follow this format for adding the library compile 'com.github.User:Repo:Tag' but I'm not sure what the tag part of it is supposed to be.
The github repo has a pom.xml file which lists other dependencies which I've been able to add without an issue. Any suggestions on how to include this particular library?
I used this repo as suggested by #Randyka Yudhistira and it worked perfectly!

Gradle unable to resolve dependency

I am trying to develop an Android app using Pubnub's realtime API facilities. As per the documentation we need to add a gradle dependency line below within the build.gradle file:
compile 'com.pubnub:pubnub:4.1.0'
Strangely enough, Gradle is not able to satisfy this dependency. My repository configuration within the Gradle build script is as follows:
repositories {
jcenter()
}
I tried adding mavenCentral() instead of jcenter() but still no luck. Any help would be greatly appreciated.
Please note: I am adding only the relevant sections of the build.gradle file since I do not have the authority to paste the whole build script.
Also, this is my first time with the Android ecosystem - hence any help in pointing out obvious newbie errors would be great.
Did you right click on app, go to Open module settings, click on the Dependencies tab, click on the +, choose add module dependency and then ok?

How to make it possible to add my Library on GitHub to Android Gradle Files?

I have a project hosted on GitHub at https://github.com/BoardiesITSolutions/NavigationDrawerManager.
I've seen some projects on GitHub state adding it to their gradle file in Android Studio to the dependencies section but this doesn't seem to be working for me.
I have tried compile: 'com.github.boardiesitsolutions.NavigationDrawerManager:+' but it keeps saying it can't find it, I've also tried replacing the + with the version number but no luck, Android Studio keeps saying it can't find it. I've added the repository MavenCentral as well.
Is there something I need to do from GitHub to make it accessible for Gradle?
I don't see it on maven.
You can use this website to use non-mavenized libraries with Gradle.
Just add maven { url "https://jitpack.io" } to repositories section of build.gradle and use compile 'com.github.BoardiesITSolutions:NavigationDrawerManager:0b14c84445' in dependencies.

How to import a .aar file into Android Studio 1.1.0 and use it in my code

I have read a lot answers related to this topic, but none of them have worked to solve my problem, so need help with this:
I need to import a .aar file into a project created with Android Studio 1.1.0, I have imported it using the "New Module" option and actually I don't receive any error, I can build the application and run it, but when I try to use a class from this .aar file Android Studio doesn´t find the reference to it, let's say it can´t recognize the package that I want to include in my code.
You are maybe thinking that I must add the dependency, I have already done that, It seems to not work.
So someone could tell me which is the correct way to import and use a .aar file in Android Studio 1.1.0
To import an .aar library:
Go to File>New>New Module
Select "Import .JAR/.AAR Package" and click next.
Enter the path to the .aar file and click finish.
Go to File>Project Structure (Ctrl+Shift+Alt+S).
Under "Modules," in left menu, select "app."
Go to "Dependencies" tab.
Click the green "+" in the upper right corner.
Select "Module Dependency"
Select the new module from the list.
After reading a lot of answers on Stackoverflow, I found the solution for my problem, I want you to know which were the steps I followed in order to reproduce it:
Add a .aar file in my libs folder.
Use "New Module" option under File menu.
Import the .aar file.
Build gradle and compile the project.
When I tried to use the new module in my app, It didn't recognize any class inside the new module.
The problem is related to the version of Gradle, I was using 1.1.0 and there is a bug in this version, so my suggestion is to change the version to 1.0.1, there is an Issue already open in order to fix this problem https://code.google.com/p/android/issues/detail?id=162634
You should change the version in the build.gradle file located in the root of your project.
buildscript {
repositories {
jcenter()
}
dependencies {
//classpath 'com.android.tools.build:gradle:1.1.0'
classpath 'com.android.tools.build:gradle:1.0.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
You can find additional information about this problem here https://groups.google.com/forum/#!topic/adt-dev/1Ho_c8dALQQ
I guess in version 1.2.0 this problem will be solved.
I follow steps in both answers but finally I need to add this line to my build.gradle:
allprojects {
repositories {
mavenCentral()
flatDir { dirs 'aars'} // this line
}
}
Use the gradle dependency
compile 'com.facebook.android:facebook-android-sdk:4.8.0'

Add library to AndroidStudio project: Configuration with name 'default' not found

I got a project from a client which I'm supposed to fix. The developer of the app just bailed out and now it's up to me to fix it.
Problem is, that he probably developed with eclipse, while I'm using AndroidStudio. So it wasn't build with gradle. But I managed to import the project and fix it so far, that I can sync gradle.
But he seemed to use an external library, this one: https://github.com/InQBarna/TableFixHeaders
I copied the content of the library folder into my project folder /libraries/tablefixheaders/.
I added include 'libraries:tablefixheaders' to my settings.grade and added compile project('libraries:tablefixheaders') to my dependencies in build.grade.
But if I want to rebuild the project now, I get Error:Configuration with name 'default' not found.. Does the external library have to have a build.gradle? If so, how does it look like? I tried several things but nothing worked for me.
Maybe it's a bit late :)
but I build a wrapper for InqBarna's library ready to use with gradle on this way:
allprojects {
repositories {
jcenter()
maven { url "https://jitpack.io" }
}
}
dependencies {
compile "com.github.miguelbcr:TableFixHeaders-Wrapper:0.1.1"
}

Categories

Resources