Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Provided dependencies can only be jars

I have an android projct in Android Studio, was all previously working the last time I used it, however, I've upgraded Android Studio and now I am getting a weird problem.

In the error output in Android Studio I have the following:

Warning: Project MyApp: provided dependencies can only be jars. com.google.android.gms:play-services.6.5.87 is an Android Library
Warning: Project MyApp: provided dependencies can only be jars. com.MyCompany.MyLibrary:aar:1.0 is an Android Library.

Below is my build.gradle file.

apply plugin: 'android'



android {
    compileSdkVersion 21
    buildToolsVersion "20.0.0"

    packagingOptions {
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
    }

    defaultConfig {
        //applicationId "com.MyCompany.MyApp"
        minSdkVersion 14
        targetSdkVersion 21
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
            debuggable false
        }
    }

    repositories {
        mavenLocal()
    }
}

dependencies {
    compile 'com.android.support:appcompat-v7:21.0.0'
    compile 'com.android.support:support-v4:21.0.0'
    compile 'com.MyCompany:CritiMon:1.0'
    compile 'com.MyCompany:Library:1.1'
    provided 'com.MyCompany:MyLibrary:1.0'
    compile 'com.MyCompany:NavigationDrawerManager:2.1'
    provided 'com.google.android.gms:play-services:+'
    compile files('libs/ksoap2-android-assembly-3.0.0-jar-with-dependencies.jar')
}
like image 806
Boardy Avatar asked Feb 27 '15 21:02

Boardy


2 Answers

Your provided dependencies can only be jars, your custom Android Libraries in your project should be compile at build time.

Change this:

provided 'com.MyCompany:MyLibrary:1.0'
provided 'com.google.android.gms:play-services:+'

to

compile 'com.MyCompany:MyLibrary:1.0'
compile 'com.google.android.gms:play-services:+'
like image 130
Peter Nguyen Avatar answered Sep 23 '22 06:09

Peter Nguyen


I restore the Android Plugin Version from 1.1.0 to 1.0.0 and it work.

You can do it by the order:

  1. Right-click your project.
  2. Select `Open Module Settings`
  3. Select `Project`
  4. Change the `Android Plugin Version`
like image 30
yinghuihong Avatar answered Sep 23 '22 06:09

yinghuihong