Adding LinkedIn SDK in android studio error: “Conf

2019-06-28 05:07发布

问题:

I am developing an application to login with LinkedIn. The things I have done are:

  • Downloaded LinkedIn SDK from this link
  • Copied the LinkedIn-SDK from that downloaded project and added it in my project-> libs folder.
  • Added:
    • compile project(':libs:linkedin-sdk') to build.gradle and
    • include ':libs:linkedin-sdk' to setting.gradle files

Then I am getting an error as:

"Gradle 'LinkdinApplication' project refresh failed Error:Configuration with name 'default' not found."

while building project.

So, Is the procedure that I followed is right? or How should I add it?

回答1:

After many searching over the Internet, I finally managed to import linkedin SDK.

In my app dependencies, instead of setting

compile project(':libs:linkedin-sdk')

I put

compile fileTree(dir: 'libs', include: ['linkedin-sdk'])

And magically Android Studio imported without problems the library.

Hope this helps



回答2:

I had the same issue. This is because the robolectric plugin. With the release of Robolectric 3.0, this plugin is no longer needed to run tests with Gradle. Please refer to http://robolectric.org/getting-started for instructions on how to get started with Gradle and Android Studio.

My build.gradle in linkedin-sdk folder:

allprojects {
    repositories {
        mavenCentral()
    }
}

buildscript {
   repositories {
     mavenCentral()
   }
}

apply plugin: 'android-library'

android {
    sourceSets {
        androidTest {
         setRoot('src/test')
        }
    }
    compileSdkVersion 17 
    buildToolsVersion "19.1.0"

    defaultConfig {
        minSdkVersion 8
        targetSdkVersion 16 
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

configurations {
}

dependencies {
    compile 'com.android.support:support-annotations:20.0.0'
    compile 'com.android.support:support-v4:21.0.+'
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile files('libs/volley.jar')
    androidTestCompile('junit:junit:4.12')
    testCompile "org.robolectric:robolectric:3.0"
}

It works for me.



回答3:

Android studio projects has two libs folders /libs and /app/libs. use the /libs folder to add linkedin-sdk.

  • compile project(':libs:linkedin-sdk') to build.gradle and
  • include':libs:linkedin-sdk' to setting.gradle files

this works perfectly.