0

I want to add AdView to my activity and I click on download and then it automatically implements the necessary library. But then I get the following error: Error 1

I get the same error when I try to add GridLayout to my library.

Here is my gradle file: gradle file

I already tried to set the Global Gradle settings to offline work but it doesn't help.

I have android studio 3.4.2

This is a problem that bothers me for a while now and there seems no solution to this. Is it possible that these things are not available for androidx yet? Thank you for your help!

Daniel Spatz
  • 77
  • 1
  • 14

2 Answers2

0

From the documentation:

To make the Google Play services APIs available to your app:

Open the build.gradle file inside your application module directory. Note: Android Studio projects contain a top-level build.gradle file and a build.gradle file for each module. Be sure to edit the file for your application module. See Building Your Project with Gradle for more information about Gradle. Add a new build rule under dependencies for the latest version of play-services, using one of the APIs listed below. Ensure that your top-level build.gradle contains a reference to the google() repo or to maven { url "https://maven.google.com" }. Save the changes, and click Sync Project with Gradle Files in the toolbar. You can now begin developing features with the Google Play services APIs.

This is often a common mistake. If you have multiple repositories in your gradle, make sure that maven google is at the top of the list.

eg.

repositories {
        maven { url "https://maven.google.com" }

        ...
    }
Nikos Hidalgo
  • 3,666
  • 9
  • 25
  • 39
0

This package:

// https://mvnrepository.com/artifact/com.google.android.gms/play-services-ads
implementation "com.google.android.gms:play-services-ads:18.1.1"

is either available from repository google() or from repository mavenCentral():

repositories {
    google()
    mavenCentral()
    ...
}

see the quick-start.

Martin Zeitler
  • 1
  • 19
  • 155
  • 216