我正在使用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 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在settings.gradle中。
include ':app', ':retrofit-2.1.0', ':fabby-sdk-jni', ':linkedin-sdk'
可能是什么问题?
更新
我已从终端:gradlew任务启动此命令,并重现此错误:
> 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')
答案 0 :(得分:16)
由于您使用的是新的Android插件3.x,因此您必须遵循migration guidelines:
错误:无法解决:无法解析项目:linkedin-sdk。
要解决此错误,您需要指定" mylibrary"中的哪种构建类型。 (在你的情况下,linkedin-sdk)Android插件应该与应用程序的匹配" staging"构建类型。您可以使用应用的buildTypeMatching
文件中的build.gradle
媒体资源执行此操作,如下所示:
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
was replaced。{。}
您可以找到有关变体感知依赖关系管理的更多信息
here和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']
}
}
}
然后
无法找到项目的匹配配置:linkedin-sdk:
您可以使用
compile project(path: ':linkedin-sdk', configuration: 'default')
但您可以简单地使用以下内容来利用变体感知依赖项解析。
implementation project(':linkedin-sdk')
您可以在有关新依赖关系'implementation'
的部分中详细了解configurations
配置。
答案 1 :(得分:11)
我已经解决了我的问题。在build.gradle(模块应用程序)import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import org.junit.Test;
public class TimSortDateAndTimestampTest {
// the same test data with all Dates, all Timestamps, all Strings or all Longs does NOT fail.
// only fails with mixed Timestamp and Date objects
@Test
public void testSortWithTimestampsAndDatesFails() throws Exception {
List<Date> dates = new ArrayList<>();
dates.add(new Timestamp(1498621254602L));
dates.add(new Timestamp(1498621254603L));
dates.add(new Timestamp(1498621254603L));
dates.add(new Timestamp(1498621254604L));
dates.add(new Timestamp(1498621254604L));
dates.add(new Timestamp(1498621254605L));
dates.add(new Timestamp(1498621254605L));
dates.add(new Timestamp(1498621254605L));
dates.add(new Timestamp(1498621254605L));
dates.add(new Timestamp(1498621254606L));
dates.add(new Timestamp(1498621254607L));
dates.add(new Date(1498621254605L));
dates.add(new Timestamp(1498621254607L));
dates.add(new Timestamp(1498621254609L));
dates.add(new Date(1498621254603L));
dates.add(new Date(1498621254604L));
dates.add(new Date(1498621254605L));
dates.add(new Date(1498621254605L));
dates.add(new Date(1498621254607L));
dates.add(new Timestamp(1498621254607L));
dates.add(new Date(1498621254608L));
dates.add(new Timestamp(1498621254608L));
dates.add(new Date(1498621254611L));
dates.add(new Timestamp(1498621254612L));
dates.add(new Timestamp(1498621254613L));
dates.add(new Date(1498621254607L));
dates.add(new Timestamp(1498621254607L));
dates.add(new Timestamp(1498621254608L));
dates.add(new Timestamp(1498621254609L));
dates.add(new Timestamp(1498621254611L));
dates.add(new Date(1498621254603L));
dates.add(new Date(1498621254606L));
for (int i = 0; i < 200; i++) {
Collections.shuffle(dates);
Collections.sort(dates);
}
}
}
必须具有以下结构:
buildTypes
并且在build.gradle(Module linkedinn-sdk)中,buildTypes必须具有相同的结构。所以新代码是:
buildTypes {
debug {}
releaseApp {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
}
releaseSdk {
signingConfig signingConfigs.sdkTest
debuggable true
}
}
答案 2 :(得分:11)
我遇到了类似的错误:
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').
答案 3 :(得分:1)
更新到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{}
}
答案 4 :(得分:1)
是的,是
implementation project(path: ':linkedin-sdk', configuration: 'default')
有效
您还可以在左侧标签Build Variants
答案 5 :(得分:-1)
您需要将LinkedIn SDK作为模块导入Android Studio项目中。要做到这一点
答案 6 :(得分:-1)
暂时将Gradle降级为稳定的3. *版本(撰写本文时为3.5),将Gradle工具降级为稳定的2. *版本(目前为2.3.3)。它似乎是当前预览版本的一个错误。