Installing support repository for Android Studio - android

I'm using Android Studio on Arch Linux and I installed the Support Repository using the SKD Manager. However whenever I try to use it I get an error saying:
Error:Could not find method compile() for arguments [com.android.support:appcompat-v7:19.1.0] on root project 'Aaaa'.
Please install the Android Support Repository from the Android SDK Manager.
I tried appcompat v7, support v4 and support v13 (I checked all of them are installed). I tried running as root and I still get the same error. The path in local.properties is pointing to the right directory. I'm no really sure what else I should change.
I created a blank activity just to try and use this repository, here is the build.gradle file:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.9.+'
}
}
allprojects {
repositories {
mavenCentral()
}
}
dependencies {
compile 'com.android.support:appcompat-v7:19.1.0'
}

You've put your dependencies block in the wrong build.gradle file. Instead of the top-level build file, put it in your module's build file instead.

Related

How to include the material-design library

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!
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.
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**
You need to accept the licence first, check the link here for your licence issue :- https://stackoverflow.com/a/41078173/2919483
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.

Android Studio: Gradle Sync fail with v4 support library

I have been following the Android fragments tutorial which requests that I set up my project to work with the v4 library by following the Support Library Setup document here.
Here are the steps I followed.
1) Make sure you have downloaded the Android Support Repository using
the SDK Manager.
2) Open the build.gradle file for your application.
3) Add the support library to the dependencies section. For example,
to add the v4 support library, add the following lines:
dependencies {
...
compile "com.android.support:support-v4:24.1.1"
}
After following the three steps I receive these two errors:
Gradle project sync failed...
Error:Could not find method compile() for arguments [com.android.support:support-v4:24.1.1] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
Please install the Android Support Repository from the Android SDK Manager.
According to the Android SDK Manager, I do have the Android Support Repository installed.
I am going to continue investigating this issue as fragments appear to be a valuable tool to develop powerful Android mobile apps. Help approaching this issue would be appreciated.
As Sufian requested in the comments below, here are the contents of my build.gradle file.
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.3'
compile "com.android.support:support-v4:24.1.1"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Here is a screenshot of my Android Standalone SDK Manager showing that the Android Support Repository is installed.
There are two build.gradle files in your project, one rootlevel, and one for your application. You will also see a dependencies section in the other build.gradle. You need to place the compile "com.android.support:support-v4:24.1.1" in there.
You are adding compile "com.android.support:support-v4:24.1.1" in <PROJECT_ROOT>\build.gradle instead you should add the above dependency in <PROJECT_ROOT>\app\build.gradle

Android Studio fails to resolve repository

In my project, I'm trying to use the design support library. I have in my Gradle file:
dependencies {
....
compile 'com.android.support:design'
....
}
And when I try to build this, I get the error:
Normally I would just click Install Repository and sync project, however, this seems to not work anymore. Clicking this does absolutely nothing, even though clicking Open File works fine.
How can I manually install it?
I have the latest Android Support Repository (30.0.0), and Android Support Library (23.2.1) installed.
For me the solution was to add maven in the allprojects section. From the setup document: https://developer.android.com/topic/libraries/support-library/setup.html
in the project level settings.gradle file.
allprojects {
repositories {
jcenter()
maven{
url "https://maven.google.com"
}
}
}
Then double check the document for the latest version.
In the app level of the settings.gradle file add:
dependencies{
compile 'com.android.support:design:26.0.1'
}
And use Gradle to sync the project.
I think it is because you've not specified the version.
compile 'com.android.support:design:23.1.1'
change version to what you have downloaded.
You can go File->Settings->Gradle Look at the "Offline work" inbox,
If it's checked you can uncheck and try to sync again.

Gradle can not find google play dependency

I try to repair the dependency to google play services in my android project. It already worked but now it is broken. I think this happened in between the Android Studio beta- and release-version.
This is the dependency in the build.gradle file:
dependencies {
compile 'com.google.android.gms:play-services:6.5.87'
}
Android Studio was able to autocomplete the version string: '6.5.87' So I thought it knows how to solve the dependency. But it does not.. This is what I treid:
reinstaled Android Studio (1.0.1) and the Android SDK
used several play-service versions (incl. tried to use '+')
tried to 'gradlew clean' the project
installed almost everything from the Android SDK Manager. (incl. Google Repository and Android Support Repository)
set all environment variables to the correct path
But I still get this error if I try to do a gradle project sync:
Error:Could not find com.google.android.gms:play-services:6.5.87.
Searched in the following locations:
file:/C:/Users/MyName/.m2/repository/com/google/android/gms/play-services/6.5.87/play-services-6.5.87.pom
file:/C:/Users/MaName/.m2/repository/com/google/android/gms/play-services/6.5.87/play-services-6.5.87.jar
https://repo1.maven.org/maven2/com/google/android/gms/play-services/6.5.87/play-services-6.5.87.pom
https://repo1.maven.org/maven2/com/google/android/gms/play-services/6.5.87/play-services-6.5.87.jar
https://oss.sonatype.org/content/repositories/snapshots/com/google/android/gms/play-services/6.5.87/play-services-6.5.87.pom
https://oss.sonatype.org/content/repositories/snapshots/com/google/android/gms/play-services/6.5.87/play-services-6.5.87.jar
https://oss.sonatype.org/content/repositories/releases/com/google/android/gms/play-services/6.5.87/play-services-6.5.87.pom
https://oss.sonatype.org/content/repositories/releases/com/google/android/gms/play-services/6.5.87/play-services-6.5.87.jar
Required by:
code:android:1.0
UPDATE:
Gradle is searching in "file:/C:/Users/MyName/.m2/repository/" but it should use
"file:/C:/Users/MyName/AppData\Local\Android\sdk\extras\google\m2repository" .. I dont know why this is wrong and how to fix it..
UPDATE 2
I fixed it using this workaround:
repositories {
def androidHome = System.getenv("ANDROID_HOME")
maven { url "$androidHome/extras/android/m2repository/" }
maven { url "$androidHome/extras/google/m2repository/"}
}
But I am not happy with it. Does anybody know whats wrong with my gradle?
In Android SDK Manager download the "Google Repository"
Try download the sdk and use this library
compile 'com.google.android.gms:play-services:7.0.0'
After adding jcenter() to reposetories or top level gradle file I fixed the issue
buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.0.1'
classpath 'com.google.gms:google-services:1.5.0-beta2'
}
}

0.8.0 Gradle sync failed

So I'm trying to transfer to android studio but I've been getting this error all the time.
This is the only thing I'm getting in the log:
Error:Could not find method compile() for arguments [com.android.support:support-v4:20.0.0] on
org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler_Decorated#50a8e746.
Please install the Android Support Repository from the Android SDK
Manager. Open Android SDK Manager
The problem is that I have android support repo installed as well as pretty much everything else so I really don't have any idea how to fix this.
I've even tried deleting the .gradle and let it download again but it didn't fix anything.
Here's my build.gradle (I did make changes to it since I was getting a build error):
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
// do not use dynamic updating.
compile 'com.android.support:support-v4:20.0.0'
}
}
allprojects {
repositories {
jcenter()
}
}
Android SDK:
Don't put module-level dependencies in the buildscript block. The buildscript block is for dependencies for the build system itself, i.e. if you were adding more Gradle plugins. To add dependencies for your modules, place them in the build.gradle file in the module directory.

Categories

Resources