Gradle could not resolve project :linkedin-sdk
Asked Answered
F

6

53

I'm using Androis Studio 3.0 Canary 4. In my project i have the Linkedin-sdk, and it works. I can use it. The only problem is that i recive this message when i search to build Gradle. enter image description here

And because i'cant build it i cannot use the designe editor and the preview.

Here is my build.gradle project:

buildscript {
  repositories {
    jcenter()
    maven { url 'https://maven.google.com' }
  }
  dependencies {
    classpath 'com.android.tools.build:gradle:3.0.0-alpha4'
    classpath 'com.google.gms:google-services:3.0.0'
  }
}

allprojects {
   repositories {
       jcenter()
       maven {
           url 'https://maven.google.com'
       }
   }
}

task clean(type: Delete) {
     delete rootProject.buildDir
}

Build.Gradle Module:App

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    buildToolsVersion "26.0.0"
    defaultConfig {
           applicationId "com.cving_team.cving"
           minSdkVersion 19
           targetSdkVersion 26
           versionCode 1
           versionName "1.0"
           testInstrumentationRunner 
           "android.support.test.runner.AndroidJUnitRunner"
}
signingConfigs {...}
buildTypes {
    sdkTest {
        signingConfig signingConfigs.sdkTest
        debuggable true

    }
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 
        'proguard-rules.pro'
        signingConfig signingConfigs.release
    }
}
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    androidTestCompile('com.android.support.test.espresso:espresso-
        core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })

compile project(':retrofit-2.1.0')
compile project(':linkedin-sdk')
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.support:appcompat-v7:26.0.0-beta2'
compile 'com.android.support:customtabs:26.0.0-beta2'
compile 'com.android.support:design:26.0.0-beta2'
compile 'com.android.support:cardview-v7:26.0.0-beta2'
compile 'com.android.support:recyclerview-v7:26.0.0-beta2'
compile 'com.facebook.android:facebook-android-sdk:4.24.0'
compile 'com.squareup.retrofit2:converter-gson:2.1.0'
compile 'com.squareup.retrofit2:retrofit:2.2.0'
compile 'com.mutualmobile.android:cardstack:0.5.2'
compile 'com.google.android.gms:play-services-location:11.0.1'
compile 'com.google.android.gms:play-services-places:11.0.1'
compile 'com.squareup.okhttp3:okhttp:3.7.0'
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'com.github.bumptech.glide:okhttp3-integration:1.4.0@aar'
compile 'fr.avianey.com.viewpagerindicator:library:2.4.1.1@aar'
compile 'eu.davidea:flexible-adapter:5.0.0-rc1'
compile 'se.emilsjolander:StickyScrollViewItems:1.1.0'
compile 'com.google.firebase:firebase-core:11.0.1'
compile 'com.google.firebase:firebase-messaging:11.0.1'
testCompile 'junit:junit:4.12'
}

apply plugin: 'com.google.gms.google-services'

Linkedin-sdk is in settings.gradle to.

include ':app', ':retrofit-2.1.0', ':fabby-sdk-jni', ':linkedin-sdk'

What could be the problem?

UPDATE

I have launched this command from terminal: gradlew tasks, and recive this error:

> Configure project :app
Configuration 'compile' in project ':app' is deprecated. Use 'implementation' instead.
Configuration 'androidTestCompile' in project ':app' is deprecated. Use 'androidTestImplementation' instead.
Configuration 'testCompile' in project ':app' is deprecated. Use 'testImplementation' instead.
registerResGeneratingTask is deprecated, use registerGeneratedFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedFolders(FileCollection)

> Configure project :fabby-sdk-jni
Configuration 'compile' in project ':fabby-sdk-jni' is deprecated. Use 'implementation' instead.
Configuration 'androidTestCompile' in project ':fabby-sdk-jni' is deprecated. Use 'androidTestImplementation' instead.
Configuration 'testCompile' in project ':fabby-sdk-jni' is deprecated. Use 'testImplementation' instead.

> Configure project :linkedin-sdk
Configuration 'compile' in project ':linkedin-sdk' is deprecated. Use 'implementation' instead.
Configuration 'androidTestCompile' in project ':linkedin-sdk' is deprecated. Use 'androidTestImplementation' instead.


FAILURE: Build failed with an exception.

* What went wrong:
Could not determine the dependencies of task ':app:testSdkTestUnitTest'.
> Could not resolve all task dependencies for configuration ':app:sdkTestUnitTestRuntimeClasspath'.
   > Could not resolve project :linkedin-sdk.
     Required by:
         project :app
      > Unable to find a matching configuration of project :linkedin-sdk:
          - Configuration 'debugApiElements':
              - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'AndroidTypeAttr{name=Aar}' and found compatible value 'AndroidTypeAttr{name=Aar}'.
              - Required com.android.build.gradle.internal.dependency.BuildTypeAttr 'BuildTypeAttr{name=sdkTest}' and found incompatible value 'BuildTypeAttr{name=debug}'.
              - Found com.android.build.gradle.internal.dependency.VariantAttr 'VariantAttr{name=debug}' but wasn't required.
              - Required org.gradle.api.attributes.Usage 'for runtime' and found incompatible value 'for compile'.
          - Configuration 'debugRuntimeElements':
              - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'AndroidTypeAttr{name=Aar}' and found compatible value 'AndroidTypeAttr{name=Aar}'.
              - Required com.android.build.gradle.internal.dependency.BuildTypeAttr 'BuildTypeAttr{name=sdkTest}' and found incompatible value 'BuildTypeAttr{name=debug}'.
              - Found com.android.build.gradle.internal.dependency.VariantAttr 'VariantAttr{name=debug}' but wasn't required.
              - Required org.gradle.api.attributes.Usage 'for runtime' and found compatible value 'for runtime'.
          - Configuration 'releaseApiElements':
              - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'AndroidTypeAttr{name=Aar}' and found compatible value 'AndroidTypeAttr{name=Aar}'.
              - Required com.android.build.gradle.internal.dependency.BuildTypeAttr 'BuildTypeAttr{name=sdkTest}' and found incompatible value 'BuildTypeAttr{name=release}'.
              - Found com.android.build.gradle.internal.dependency.VariantAttr 'VariantAttr{name=release}' but wasn't required.
              - Required org.gradle.api.attributes.Usage 'for runtime' and found incompatible value 'for compile'.
          - Configuration 'releaseRuntimeElements':
              - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'AndroidTypeAttr{name=Aar}' and found compatible value 'AndroidTypeAttr{name=Aar}'.
              - Required com.android.build.gradle.internal.dependency.BuildTypeAttr 'BuildTypeAttr{name=sdkTest}' and found incompatible value 'BuildTypeAttr{name=release}'.
              - Found com.android.build.gradle.internal.dependency.VariantAttr 'VariantAttr{name=release}' but wasn't required.
              - Required org.gradle.api.attributes.Usage 'for runtime' and found compatible value 'for runtime'.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

SOLVED

Just chenage:

compile project(':linkedin-sdk')

to

compile project(path: ':linkedin-sdk', configuration: 'default')

Fraudulent answered 29/6, 2017 at 16:12 Comment(16)
Can you show your settings.gradle?Upbuild
Like i said before is already included. Have updated.Fraudulent
you don't have a second settings.gradle in app/, do you?Upbuild
And does the same error happen if you build from the commandline?Upbuild
No i haven't. I haven't try to build from commandline. Try and tell youFraudulent
Sorry, how can i do it?Fraudulent
gradlew ___________Upbuild
Ok, also i runned gradlew in the terminal, had the problem "could not find gradle 3.0.0-alpha4". So i have fixed him (Updated my gradle.build code above). Then i have relaunched gradlew and had no issues. But still when i try to sync i recive the same "could not resolve project" error.Fraudulent
Waith, have tried new thing. Have updated my questionFraudulent
This looks like android specific problem, so I'm out of the loop, but maybe now with the additional infos someone can find the right answerUpbuild
Where do you have the linkedin-sdk project?Bucovina
@Bucovina I have solved the problem. Look at question on the bottomFraudulent
You should post the solution as an answer instead of editing your question.Bucovina
I don't know that. ThanksFraudulent
Also, it will help if you edit your question to show what version of Android Studio you are using.Bucovina
Related - https://mcmap.net/q/353543/-gradle-plugin-3-0-0-beta-4-quot-buildtypematching-has-been-removed-use-buildtypes-lt-name-gt-fallbacks-quotSublett
F
15

I have solved my problem. In build.gradle(Module app) buildTypes must have this structure:

buildTypes {
    debug {}
    releaseApp {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        signingConfig signingConfigs.release
    }
    releaseSdk {
        signingConfig signingConfigs.sdkTest
        debuggable true
    }
}

and in build.gradle(Module linkedinn-sdk) buildTypes must have same structure. So the new code is:

buildTypes {
    debug {}
    releaseApp  {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
    releaseSdk {}
}
Fraudulent answered 29/6, 2017 at 17:41 Comment(1)
Almost a year later and this is still the best answer. buildTypes across modules need to have the same types.London
S
28

Since you are using the new android plugin 3.x you have to follow the migration guidelines:

Error:Failed to resolve: Could not resolve project :linkedin-sdk.

To resolve this error, you need to specify which build type from "mylibrary" (linkedin-sdk in your case) the Android plugin should match to the app's "staging" build type. You can do this with the buildTypeMatching property in the app's build.gradle file, as shown below:

android {
    ...
    // Tells the Android plugin to use a library's 'debug' build type
    // when a 'staging' build type is not available. You can include
    // additional build types, and the plugin matches 'staging' to the
    // first build type it finds from the one's you specify. That is,
    // if 'mylibrary' doesn't include a 'debug' build type either, the
    // plugin matches 'staging' with the producer's 'release' build type.
    buildTypeMatching 'staging', 'debug', 'release'
}

Edit: buildTypeMatching was replaced by matchingFallbacks.
You can find more info about the variant-aware dependency management here and here.

android {
    buildTypes {
        debug {}
        release {}
        staging {
            // Specifies a sorted list of fallback build types that the
            // plugin should try to use when a dependency does not include a
            // "staging" build type. You may specify as many fallbacks as you
            // like, and the plugin selects the first build type that's
            // available in the dependency.
            matchingFallbacks = ['debug', 'qa', 'release']
        }
    }
}

Then

Unable to find a matching configuration of project :linkedin-sdk:

You can use

compile project(path: ':linkedin-sdk', configuration: 'default')

but you can simply use the following to take advantage of variant-aware dependency resolution. .

implementation project(':linkedin-sdk')

You can learn more about the 'implementation' configuration in the section about new dependency configurations.

Staphylorrhaphy answered 25/8, 2017 at 9:45 Comment(5)
i use this in android 3.2 for multiple module geofence,chat and work...thanksMumbletypeg
This seems to be removed in newer gradle versions - one should now define "fallback" build types as per this related answerSublett
Do you import the linkedln sdk via jar library or the lib. project ?Teacup
Gradle DSL method not found: 'buildTypeMatching()'Alurta
@Alurta buildTypeMatching was replaced by matchingFallbacks with plugin 3.0 beta4. You can find more info here: developer.android.com/studio/build/dependencies#variant_aware and here: developer.android.com/studio/build/…Staphylorrhaphy
F
15

I have solved my problem. In build.gradle(Module app) buildTypes must have this structure:

buildTypes {
    debug {}
    releaseApp {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        signingConfig signingConfigs.release
    }
    releaseSdk {
        signingConfig signingConfigs.sdkTest
        debuggable true
    }
}

and in build.gradle(Module linkedinn-sdk) buildTypes must have same structure. So the new code is:

buildTypes {
    debug {}
    releaseApp  {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
    releaseSdk {}
}
Fraudulent answered 29/6, 2017 at 17:41 Comment(1)
Almost a year later and this is still the best answer. buildTypes across modules need to have the same types.London
A
13

I got similar error that I was able to resolve:

21:13   Gradle sync failed: Cannot choose between the following configurations of project :sTLivenessLibrary:
        - debugApiElements
        - debugRuntimeElements
        - releaseApiElements
        - releaseRuntimeElements
        All of them match the consumer attributes:
        - Configuration 'debugApiElements':
        - Found com.android.build.api.attributes.BuildTypeAttr 'debug' but wasn't required.
        - Found com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' but wasn't required.
        - Found com.android.build.gradle.internal.dependency.VariantAttr 'debug' but wasn't required.
        - Found org.gradle.api.attributes.Usage 'for compile' but wasn't required.
        - Configuration 'debugRuntimeElements':
        - Found com.android.build.api.attributes.BuildTypeAttr 'debug' but wasn't required.
        - Found com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' but wasn't required.
        - Found com.android.build.gradle.internal.dependency.VariantAttr 'debug' but wasn't required.

I fixed this by changing the compile config:

compile project(':linkedin-sdk')

to

compile project(path: ':linkedin-sdk', configuration: 'default').
Ataliah answered 5/8, 2017 at 13:19 Comment(1)
Kotlin DSL: implementation(project(":linkedin-sdk", configuration = "default"))Martyrdom
H
3

Yes, it is

implementation project(path: ':linkedin-sdk', configuration: 'default') works

And you can choose flavour type in left tab Build Variants

Headachy answered 9/7, 2018 at 13:9 Comment(0)
F
1

I also faced this issue when updated to android studio 3.0

This was my build types block in app gralde file

 buildTypes {
    staging {
        buildConfigField 'String', 'HOST', '"http://compute.amazonaws.com/"'
        buildConfigField 'String', 'REGION_CODE', '"1"'
        debuggable true
        signingConfig signingConfigs.debug
    }
    QA {
        buildConfigField 'String', 'HOST', '"com.amazo/"'
        buildConfigField 'String', 'REGION_CODE', '"92"'
        debuggable true
        signingConfig signingConfigs.debug
    }
    notificationTest {
        buildConfigField 'String', 'HOST', '"http://a6a"'
        buildConfigField 'String', 'REGION_CODE', '"92"'
        debuggable true
        signingConfig signingConfigs.debug
    }
}

and this was my project dependencies

compile project(':slideDateTimePicker')
compile project(':scatter')

I opened scatter build.gradle and slideDateTimePicker build.gradle files and replaced android block with this one.

  buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
    QA {}
    notificationTest{}
    releaseApp {}
    releaseSdk {}
    staging{}
}
Foeticide answered 27/10, 2017 at 5:50 Comment(0)
B
-2

You need to import the LinkedIn SDK as a module in your Android Studio project. To do this

  1. Extract the project from the ZIP file which you downloaded from LinkedIn.
  2. In the Android Studio menu, navigate to Android File -> New -> Import module and then select the folder which you created in step 1.

Source: https://mcmap.net/q/353544/-how-to-add-linkedin-sdk-to-a-new-android-studio-project

Bucovina answered 29/6, 2017 at 17:37 Comment(1)
Like i said on the question i have solved the problem. And the linkedin sdk as always worked. It was not a problem of import. It was just a bug of Gradle. Here is some more information: #44114544Fraudulent

© 2022 - 2024 — McMap. All rights reserved.