I am unable to include cwac:saferoom in the project


#1

I have this buildscript:

    repositories {
        google()
        jcenter()
        maven { url 'https://jitpack.io' }
        maven { url "https://s3.amazonaws.com/repo.commonsware.com" }
    }

and, this is my build.gradle for app:

    implementation 'com.commonsware.cwac:saferoom:0.4.1'

I get this error:

    Failed to resolve: com.commonsware.cwac:saferoom:0.4.1

I tried using following sources in buildscript as well:

   maven { url 'https://repo.commonsware.com.s3.amazonaws.com' }
   maven { url 'http://repo.commonsware.com' }

#2

The Failed to resolve line should be followed by a series of lines indicating where Gradle tried finding the artifact. What does it list for you?


#3

No, there is no line after this.

This seems odd. I think I used to see more lines before when I found such an error. But, if I misspell any other library’s implementation specification, it is always one line error.


#4

Also, it tries to download from bintray jcenter I think.


#5

In the Android Studio pane where you are seeing this output, click the second button down on the toolstrip on the left. This will switch you from the tree-structured output to what had been part of the “Gradle Console” in previous Android Studio releases. There is where you should find the lines that I was referring to (I hope).


#6

There’s no mention of an error in this output, plus I tried to find ‘cwac’ with CTRL + F. There’s no mention of it. Is there a direct URL to this? so that I can check if maybe my company’s network administrator is blocking something. I don’t think that would be the problem.

Event Log just says “Gradle Sync Failed”. Build is successful, problem is in Sync.

I missed old Gradle Console, thanks for the tip, but this still seems different.


#7

I tried your provider library too: Failed to resolve: com.commonsware.cwac:provider:0.5.3

I should try in a new project.


#8

If I comment out jcenter, I get better errors.


#9

OK, those are the sorts of messages that I was expecting that you would see. I do not know why you are not getting those messages for the CWAC artifacts. And Android Studio is clearly looking in the right place for artifacts, as it shows the https://s3.amazonaws.com/repo.commonsware.com lines for your missing Kotlin dependency.

You might try visiting https://s3.amazonaws.com/repo.commonsware.com/ itself in a Web browser. If you get an unformatted hunk of XML starting with a <ListBucketResult> element, it works. If you get something else, then perhaps this site is being blocked for some reason on your network.


#10

Yes, I get ListBucketResult.


#11

I tried on a different PC(not from company), same result.


#12

You might try switching to a command-line build for a bit. You will get the full Gradle output, and so you can see where Gradle is looking for those AARs. You can also include the --refresh-dependencies switch to force Gradle to re-check for dependencies, as it sometimes will only check once per day. So, in a typical Android Studio project, run ./gradlew --refresh-dependencies assembleDebug, and see what you get.


#13

There is a ArtifactResolveException, followed by ModuleVersionNotFoundException. Is it looking in the right place? The ‘Searched In’ list doesn’t have s3-amazonaws link.

Here’s the output.
This is the XML I get from that link. It doesn’t contain anything about cwac. Perhaps, it is not supposed to, I am not even familiar with gradle, not more than clicking a button and let it do stuff.


#14

The output that you show indicates that Gradle is not searching my repository for the artifact. I do not know why. Note that the maven { url "https://s3.amazonaws.com/repo.commonsware.com" } needs to be in the repositories closure that is not inside the buildscript closure. If you look at the build.gradle in the SafeRoom project root, you will see an example of this:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.0'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
        google()
        maven { url "https://s3.amazonaws.com/repo.commonsware.com" }
    }
}

In this project, I use allprojects to say “hey, every module in this project should get this configuration”, and inside of there I have a repositories closure that lists the CommonsWare repo (among others).

If your build.gradle is set up to be similar to the one shown above, then I cannot explain your symptoms.


#15

That does it, thanks.

I am sorry if this was obvious. I had it in buildscript enclosure. I, also, mentioned it in original post on first line.