Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gradle build failed to resolve aar library dependency (trnql sdk)

When I attempt to build my project using gradle, I get the following error:

Failed to resolve: com.trnql:lib-release 1.0.0

It seems it cannot find the android archive file (aar) that is in the libs folder. The dependencies section of the build.gradle file looks like this:

enter image description here

And the project structure looks like this:

enter image description here

The aar file is valid, it is just not resolved by the build system. What can I do to fix this problem?

like image 676
Cognitio Avatar asked Jan 18 '16 22:01

Cognitio


People also ask

Where is the AAR file in Android Studio?

Add your AAR or JAR as a dependency Navigate to File > Project Structure > Dependencies. In the Declared Dependencies tab, click and select Jar Dependency in the dropdown. In the Add Jar/Aar Dependency dialog, first enter the path to your . aar or .

How do I publish my AAR?

Uploading Android AAR to Local Maven RepositoryCreate an empty project without any activity. Create an AAR module. The URL file:\\DESKTOP-3PCHU10\site\ is a shared folder. Add “apply from: 'maven-publish.

What is flatDir in gradle?

flatDir(configureClosure) Adds an configures a repository which will look for dependencies in a number of local directories. flatDir(args) Adds a resolver that looks into a number of directories for artifacts. The artifacts are expected to be located in the root of the specified directories.

What is compileOnly in gradle?

compileOnly. Gradle adds the dependency to the compile classpath only (that is, it is not added to the build output). This is useful when you're creating an Android module and you need the dependency during compilation, but it's optional to have it present at runtime.


1 Answers

put your aar file in libs dir, then modify part of your build.gradle file like below, the difference is that you missed *.aar when compile fileTree

repositories {
    flatDir {
        dirs 'libs'
    }
}

compile fileTree(dir:'libs', include:['*.jar', '*.aar'])
like image 79
huangxin Avatar answered Sep 22 '22 02:09

huangxin