Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Studio gradle sync, try to download jar instead of aar by mistake

I am using Android Studio 1.4 preview 3, gradle plugin 1.3. Hi, i upload a aar package to bintray jcenter:

https://bintray.com/kevinho/maven/opencore-amr-android/view

And i setup repositories like this:

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.3.0'
        classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.2'
        classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3'
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

When I try to use it as a dependency,

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.hikvh:opencore-amr-android:1.0.0'
}

I get following error:

Error:A problem occurred configuring project ':app'. Could not find opencore-amr-android.jar (com.hikvh:opencore-amr-android:1.0.0). Searched in the following locations: https://jcenter.bintray.com/com/hikvh/opencore-amr-android/1.0.0/opencore-amr-android-1.0.0.jar

My question goes: Why gradle try to load jar instead aar file by default? And how to fix this?

like image 880
kvh Avatar asked Aug 26 '15 02:08

kvh


2 Answers

You need to tell Gradle that you're trying to refer an AAR, not a JAR.

Replace

compile 'com.hikvh:opencore-amr-android:1.0.0'

with

compile 'com.hikvh:opencore-amr-android:1.0.0@aar'

Hope it helps.

like image 159
Janus Varmarken Avatar answered Oct 21 '22 01:10

Janus Varmarken


Your dependency is loading as aar correctly.
Maybe library wasn't released by JCenter yet when you tried to download it.

Let's try to remove gradle cache.
1) Be sure that you have compile 'com.hikvh:opencore-amr-android:1.0.0' in your dependencies.
2) From your home directory rm -rf ~/.gradle/caches
3) From you project root rm -rf .gradle
4) Run gradlew from project ./gradlew assemble

like image 6
Stas Parshin Avatar answered Oct 21 '22 02:10

Stas Parshin