27

I want to compile the following library in my project in build.gradle:

https://github.com/theDazzler/Android-Bootstrap

It is forked from https://github.com/Bearded-Hen/Android-Bootstrap, but no documentation in the repository explains how to include in in project.

I tried something like this:

compile 'com.theDazzler:androidbootstrap:+'

but gradle failed and shows error that library not found.

Edit: Can anyone fork it and/or publish it?

mrcendre
  • 1,053
  • 2
  • 15
  • 28
xyz
  • 1,325
  • 5
  • 26
  • 50

4 Answers4

38

This fork isn't published in the maven central repo.

Then you can't use an import like compile com.theDazzler:androidbootstrap:+

You have to: - clone this library locally as a module in your project Clone the https://github.com/theDazzler/Android-Bootstrap/tree/master/AndroidBootstrap folder in your root/module1 folder.

  root:
      module1
        build.gradle
      app
        build.gradle
      settings.gradle
  • Change your settings.gradle file in

    include ':module1' include ':app'

In your app/build.gradle file you have to add:

dependencies {
    // Module Library
    compile project(':module1')
}

Finally in your module1/build.gradle you have to check the level used for gradle plugin.

EDIT 31/10/2015:

You can use another way to add a dependency with a github project,using the github repo and the jitpack plugin
In this case you have to add this repo tp your build.gradle

repositories {
        // ...
        maven { url "https://jitpack.io" }
    }

and the dependency:

dependencies {
        compile 'com.github.User:Repo:Tag'
    }
Gabriele Mariotti
  • 320,139
  • 94
  • 887
  • 841
  • can't you fork it and make a new repo and then publish it? – xyz Feb 26 '15 at 20:39
  • @GabrieleMariotti: Hello Sir, could you possibly help me out with my question [here](http://stackoverflow.com/q/36157555/3287204) ? Thank you ... :) – Yash Sampat Mar 23 '16 at 05:37
  • Please, note that you want to take *module* folder and include it in your project, not the whole project – charlag Oct 26 '17 at 11:53
  • @Gabriele Mariotti would you mind answering my question around your solution here: https://stackoverflow.com/questions/48070764/how-to-compile-a-specific-github-pr-into-my-android-studio-project-grade-error – sudoExclaimationExclaimation Jan 03 '18 at 03:31
  • 'Cannot invoke method include() on null object' it show me that error can you teel me why ?! – Mahmoud Ayman Jun 06 '18 at 00:53
7

It can be simply done by using Jitpack.

Step 1. Add the JitPack repository to your build file

allprojects {
        repositories {

            maven { url 'https://jitpack.io' }
        }
    }

Step 2. Add the dependency

dependencies {
        compile 'com.github.User:Repo:Tag'
    }

for eg: compile 'com.github.sachinvarma:JcPlayer:0.0.1'

Sachin Varma
  • 2,175
  • 4
  • 28
  • 39
3

The issue is: has that theDazzler/Android-Bootstrap been published anywhere? In any gradle/maven repo? The usual build.gradle file has a section repositories which should reference that maven repo.

So it is possible any project using theDazzler/Android-Bootstrap should reference the repo where it is published, And with a project like gradle-git-repo-plugin, you could publish that fork on its own release section to publish it.

That task gets wrapped into a publishToGithub task that handles committing and pushing the change. Then you can run

gradle -Porg=layerhq -Prepo=gradle-releases publishToGithub

You can also run

gradle -Porg=layerhq -Prepo=gradle-releases publish

to stage a release in the local github repo and commit it manually.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
3

Hi i had the same issue but with a different project :)

So first you should have the library code on your dev machine. Next steps are: add a new file called settings.gradle to the root of your project if its not already there.

inside add this:

include 'AndroidBootStrap'
project('AndroidBootStrap').path = "path/to/AndroidBootstrap/AndroidBootStrapLibrary"

also add include for your root project if its not there. Inside your build.gradle file add

compile project(':AndroidBootStrap')

to add the dependency.

How your folder Structure should look:

 root
   YourProject
      settings.gradle
      YourProjectModule
          build.gradle

   AndroidBootStrap
      AndroidBootStrapLibrary
          build.gradle

In the end the files look like this:

settings.gradle:

include 'AndroidBootStrap'
project('AndroidBootStrap').path = "../AndroidBootstrap/AndroidBootStrapLibrary"
include 'YourProjectModule'

build.gradle (YourModule):

...
dependencies {
   ...
   compile project(':AndroidBootStrap')
}

Maybe its necessary to modify some point but i hope you get the idea!

Cheers Neri

Neristance
  • 146
  • 3