簡體   English   中英

Gradle無法解析項目:linkedin-sdk

[英]Gradle could not resolve project :linkedin-sdk

我正在使用Androis Studio 3.0 Canary 4.在我的項目中,我有Linkedin-sdk,它的工作原理。 我可以用它。 唯一的問題是,當我搜索構建Gradle時,我會收到此消息。 在此輸入圖像描述

因為我不能構建它我不能使用設計編輯器和預覽。

這是我的build.gradle項目:

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模塊: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在settings.gradle中。

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

可能是什么問題呢?

UPDATE

我從terminal:gradlew tasks啟動了這個命令,並發現了這個錯誤:

> 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.

解決了

只是chenage:

compile project(':linkedin-sdk')

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

由於您使用的是新的Android插件3.x,因此您必須遵循遷移准則

錯誤:無法解決:無法解析項目:linkedin-sdk。

要解決此錯誤,您需要指定Android插件應與應用程序的“staging”構建類型匹配的“mylibrary”(在您的情況下為linkedin-sdk)中的構建類型。 您可以使用app的build.gradle文件中的buildTypeMatching屬性執行此操作,如下所示:

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'
}

編輯buildTypeMatching matchingFallbacks 取代
您可以 此處找到有關變體感知依賴關系管理的更多信息。

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']
        }
    }
}

然后

無法找到項目的匹配配置:linkedin-sdk:

您可以使用

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

但您可以簡單地使用以下內容來利用變體感知依賴項解析。

implementation project(':linkedin-sdk')

您可以在有關新依賴關系configurations的部分中了解有關'implementation'配置的更多信息。

我已經解決了我的問題。 在build.gradle(模塊應用程序)中, buildTypes必須具有以下結構:

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

在build.gradle(Module linkedinn-sdk)中,buildTypes必須具有相同的結構。 所以新代碼是:

buildTypes {
    debug {}
    releaseApp  {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
    releaseSdk {}
}

我得到了類似的錯誤,我能夠解決:

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.

我通過更改編譯配置修復此問題:

compile project(':linkedin-sdk')

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

更新到android studio 3.0時我也遇到了這個問題

這是app gralde文件中的構建類型塊

 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
    }
}

這是我的項目依賴項

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

我打開了scatter build.gradle和slideDateTimePicker build.gradle文件,用這個替換了android塊。

  buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
    QA {}
    notificationTest{}
    releaseApp {}
    releaseSdk {}
    staging{}
}

是的

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

您可以在左側選項卡Build Variants選擇風味類型

您需要將LinkedIn SDK作為模塊導入Android Studio項目中。 去做這個

  1. 從您從LinkedIn下載的ZIP文件中提取項目。
  2. 在Android Studio菜單中,導航到Android文件 - >新建 - >導入模塊,然后選擇您在步驟1中創建的文件夾。

資料來源: https//stackoverflow.com/a/38998826/1440565

將Gradle降級為穩定的3. *版本(撰寫本文時為3.5),將Gradle工具降級為穩定的2. *版本(目前為2.3.3)。 它似乎是當前預覽版本的錯誤。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM