2

I want to include the material-design library for android into my project, but I'm a bit confused where to find it and how to include it. I downloaded the library from github https://github.com/material-components/material-components-android.

I tried to build it with gradle, but I got the following error, to which I can't seem to find the solution:

> Configure project :catalog
Checking the license for package Android SDK Build-Tools 27.0.3 in /mnt/sda2/android/Sdk/licenses
Warning: License for package Android SDK Build-Tools 27.0.3 not accepted.

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':catalog'.
> Failed to install the following Android SDK packages as some licences have not been accepted.
     build-tools;27.0.3 Android SDK Build-Tools 27.0.3

I have the 'build-tools 27.0.3' installed through the SDK manager. Any hints please on how can I bypass this issue?

As far as I understood, I need to compile the library in the first place, then place it into the /lib folder, and then tell 'Ant' build tool to include this library in order to use it. Is this correct? Maybe there's a place from which I can simply download already pre-compiled lib? I couldn't seem to locate it in the SDK manager. Thank you!

I'm trying to build the project with Gradle now, this is my build.gradle file:

buildscript {
  repositories {
    google()
    jcenter()
  }
  dependencies {
        implementation 'com.google.android.material:material:1.0.0-beta01'
  }
}

allprojects {
  repositories {
    google()
    jcenter()
    mavenLocal()
  }
}

but I keep getting an error:

Could not find method implementation() for arguments [com.google.android.material:material:1.0.0-beta01] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

Any hints please?

UPDATE

I downloaded android studio, followed the instructions, here's a snippet of my build.gradle:

repositories {
    google()
    jcenter()
}
dependencies {
    classpath 'com.android.tools.build:gradle:3.1.3'
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    compile "com.android.support:design:27.1.1"
}

but now I'm getting a different error:

Could not find method compile() for arguments [com.android.support:design:25.1.0] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

Please install the Android Support Repository from the Android SDK Manager.
Open Android SDK Manager

I opened the SDK manager, but he Android Support Repository is already installed (rev47). Any hints please? Thanks!

0x29a
  • 733
  • 1
  • 7
  • 23
  • 1
    you dont need to download the library just use gradle to import it in your project. https://github.com/material-components/material-components-android/blob/master/docs/getting-started.md – tyczj Jul 24 '18 at 17:36
  • @tyczj thanks, but how can I do this if I'm using 'Ant' builder? – 0x29a Jul 24 '18 at 17:38
  • I dont believe and is supported. are you not using android studio? – tyczj Jul 24 '18 at 17:39
  • @tyczj thanks. For some reason it's extremely lagy on my laptop, I will download and give it another shot, thanks for the hint. Meanwhile can you please check my build.gradle, any hints on the error? Thanks! – 0x29a Jul 24 '18 at 17:55
  • @tyczj I installed android studio and did as mentioned in the instructions, but now I'm getting a different error. – 0x29a Jul 24 '18 at 20:34

2 Answers2

2

Make sure your compiledSdkVersion is 28

In build.gradle, make sure that the repositories section includes Google's Maven repository google() i.e.,

add this

allprojects {
  repositories {
    google()
    jcenter()
  }
}

Then, add the dependencies.

dependencies {
  implementation 'com.google.android.material:material:1.0.0'
}

Then Refactor to AndroidX.

Click on Refactor and then click on Migrate to AndroidX.

Then it will update your app's dependencies and code to use the newly packaged androidx and com.google.android.material libraries.

or

You can use com.android.support:design:28.0.0 dependency if you do not wish to switch to androidx.

Note: You cannot use both com.android.support and com.google.android.material dependencies in your app at the same time.

Madhu Jayarama
  • 415
  • 1
  • 5
  • 15
1

Hope following things help you :-

**A problem occurred configuring project ':catalog'.Failed to install the following Android SDK packages as some licences have not been accepted.
 build-tools;27.0.3 Android SDK Build-Tools 27.0.3**
  1. You need to accept the licence first, check the link here for your licence issue :- https://stackoverflow.com/a/41078173/2919483

  2. For adding material design library in Android studio :-

     In you build.gradle, add the dependency like:
    
     dependencies {
    compile 'com.android.support:design:25.1.0'
                  }
    

sync your project and start using that.

Rajshree Tiwari
  • 630
  • 1
  • 7
  • 27