【问题标题】:compile error while upgrading to 3.0 version升级到 3.0 版本时出现编译错误
【发布时间】:2017-12-13 06:30:28
【问题描述】:

我想在 android 3.0 版本中运行我的旧项目。但它显示运行时错误,请任何人帮助我解决我的问题。

我的项目包含子模块。

如果我在gradle 中将compile 更改为implementation,我也在使用apt,它显示apt error。我做的事。请帮我。提前致谢。

这是错误。

 Error:Cannot choose between the following configurations of project :library:
  - 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 'java-api' 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.
  - Found org.gradle.api.attributes.Usage 'java-runtime' but wasn't required.
  - Configuration 'releaseApiElements':
  - Found com.android.build.api.attributes.BuildTypeAttr 'release' 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 'release' but wasn't required.
  - Found org.gradle.api.attributes.Usage 'java-api' but wasn't required.
   - Configuration 'releaseRuntimeElements':
  - Found com.android.build.api.attributes.BuildTypeAttr 'release' 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 'release' but wasn't required.
  - Found org.gradle.api.attributes.Usage 'java-runtime' but wasn't required.

这是我的主要 Gradle:

      buildscript {
repositories {
    jcenter()
    google()
}
dependencies {
    classpath 'com.android.tools.build:gradle:3.0.1'
    classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3'
    classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.1'
    classpath 'com.google.gms:google-services:3.0.0'
    classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'


}
 }

 allprojects {
repositories {
    jcenter()
    maven {
        url "https://github.com/QuickBlox/quickblox-android-sdk-releases/raw/master/"
    }
    google()
}


ext {
    compileSdkVersion = 26
    buildToolsVersion = "26.0.1"

    minSdkVersion = 14
    targetSdkVersion = 23

    sourceCompatibility = JavaVersion.VERSION_1_7
    targetCompatibility = JavaVersion.VERSION_1_7

    lintAbortOnError = false

    // QuickBlox SDK version
    qbSdkVersion = '3.1.0'

    versionName = "3.0"

    testRunnerVersion = "0.4.1"


    // Dependency versions
    playServicesVersion = '9.8.0'
    supportV4Version = '23.1.1'
    appcompatV7Version = '23.1.1'
    recyclerviewV7Version = '23.2.1'
    supportAnnotationsVersion = '23.1.1'
    designVersion = '23.1.1'

    uilVersion = '1.9.0'
    glideVersion = '3.6.1'
    pullToRefreshVersion = '3.2.3'
    stickyListHeaders = '2.7.0'
    robotoTextViewVersion = '2.4.3'
    stickersVersion = '0.7.3'
    crashlyticsVersion = '2.2.2'
}


 }

这是我的应用 Gradle

  apply plugin: 'com.android.application'
 apply plugin: 'com.neenbedankt.android-apt'

 android {
compileSdkVersion 26
buildToolsVersion '26.0.2'
useLibrary 'org.apache.http.legacy'
defaultConfig {
    applicationId "com.sample"
    minSdkVersion 19
    targetSdkVersion 26
    multiDexEnabled true
}
lintOptions {
    checkReleaseBuilds false
    abortOnError false
}
configurations{
    all*.exclude module: 'servlet-api'
}
dexOptions {
    javaMaxHeapSize "4g"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
    }
}
packagingOptions {
    exclude 'META-INF/DEPENDENCIES.txt'
    exclude 'META-INF/LICENSE.txt'
    exclude 'META-INF/NOTICE.txt'
    exclude 'META-INF/NOTICE'
    exclude 'META-INF/LICENSE'
    exclude 'META-INF/DEPENDENCIES'
    exclude 'META-INF/notice.txt'
    exclude 'META-INF/license.txt'
    exclude 'META-INF/dependencies.txt'
    exclude 'META-INF/LGPL2.1'

}
configurations.all {
    resolutionStrategy {
        force 'com.android.support:support-annotations:23.3.0'
    }
}
configurations {
    // Initializes placeholder configurations that the Android plugin can use when targeting
    // the corresponding variant of the app.
    demoDebugCompile {}
    fullReleaseCompile {}

}
}

dependencies {
compile project(':library')
compile project(':simpl3r')

compile project(':androidHorizontalListView')


compile  'com.google.code.gson:gson:2.2.4'
compile  files('libs/acra-4.5.0.jar')
compile  files('libs/bugsense-3.6.jar')
compile  files('libs/espresso-1.1-bundled.jar')
compile  files('libs/sample-2.4.1.jar')
compile  files('libs/signpost-commonshttp4-1.2.1.1.jar')
compile  files('libs/signpost-core-1.2.1.1.jar')
compile  files('libs/twitter4j-core-4.0.2.jar')
compile  files('libs/universal-image-loader-1.9.2-SNAPSHOT-with-sources.jar')
compile  files('libs/volley.jar')
compile  files('libs/YouTubeAndroidPlayerApi.jar')
compile  files('libs/gcm.jar')

compile  files('libs/mint-5.2.1.jar')
compile project(':swipelibrary')


compile  files('libs/glide-3.7.0.jar')
compile  files('libs/glide-3.7.0-javadoc.jar')
compile  'org.jsoup:jsoup:1.8.3'
compile  'org.mozilla:rhino:1.7.7'
compile  'info.guardianproject.netcipher:netcipher:1.2'
compile  'com.nineoldandroids:library:2.4.0'
compile  'com.thefinestartist:utils:0.9.1'
apt  'com.thefinestartist:compilers:0.9.1'
compile  'com.android.support:recyclerview-v7:23.0.+'
compile  'in.srain.cube:grid-view-with-header-footer:1.0.12'
compile  'joda-time:joda-time:2.9.2'
compile  'com.writingminds:FFmpegAndroid:0.3.2'

//implemented retrofit.
testCompile 'junit:junit:4.12'
compile  'com.android.support:appcompat-v7:25.0.1'
compile  'com.squareup.retrofit:retrofit:1.9.0'

compile  'com.google.android.gms:play-services-analytics:9.8.0'
compile  'com.facebook.android:facebook-android-sdk:4.26.0'

compile  'com.android.support:design:23.4.0'
compile  'com.flurry.android:analytics:6.3.1'
compile project(':sample-chat')
compile project(':sample-pushnotifications')


compile  'com.quickblox:quickblox-android-sdk-core:3.1.0'
compile  "com.google.android.gms:play-services-gcm:9.8.0"

compile project(':sample-core')


}

ext {
compileSdkVersion = 26
buildToolsVersion = "23.0.2"

minSdkVersion = 14
targetSdkVersion = 23

sourceCompatibility = JavaVersion.VERSION_1_7
targetCompatibility = JavaVersion.VERSION_1_7

lintAbortOnError = false

// QuickBlox SDK version
qbSdkVersion = '3.1.0'

versionName = "3.0"

testRunnerVersion = "0.4.1"


// Dependency versions
playServicesVersion = '9.8.0'
supportV4Version = '23.1.1'
appcompatV7Version = '23.1.1'
recyclerviewV7Version = '23.2.1'
supportAnnotationsVersion = '23.1.1'
designVersion = '23.1.1'

uilVersion = '1.9.0'
glideVersion = '3.6.1'
pullToRefreshVersion = '3.2.3'
stickyListHeaders = '2.7.0'
robotoTextViewVersion = '2.4.3'
stickersVersion = '0.7.3'
crashlyticsVersion = '2.2.2'
}

请帮我解决我的问题。

【问题讨论】:

    标签: android build.gradle updates android-studio-3.0


    【解决方案1】:

    改变这个

    compile project(':library')
    compile project(':simpl3r')
    

    compile project(path: ':library', configuration: 'default')
    compile project(path: ':simpl3r', configuration: 'default')
    

    更新1

    implementation project(path: ':library')
    implementation project(path: ':simpl3r')
    .
    . 
    .
    

    【讨论】:

    • 如果我更改该行,我会收到另一个与 apt 相关的错误
    • 试试这个实现项目(':library')
    • 如果我这样更改,我会收到此错误......无法解析“:sample@debug/compileClasspath”的依赖关系:转换失败文件 'sample-chat-release.aar' 以匹配属性 {artifactType=android-exploded-aar} 使用变换 ExtractAarTransform
    • 删除配置:默认并尝试,检查更新的答案
    【解决方案2】:

    我在这里看到了多个问题:

    1. 使用不同版本的android支持库(例如:你的recyclerview是23.0.+但支持设计是23.4.0等)

    2. 用你的 lib 版本声明一个 ext,但实际上从未在任何地方使用它们?

    3. 在 app gradle 和 projects gradle 中声明了相同的 ext? (而不是在两者中都使用它们?)

    4. compileSdkVersion 26 与支持库的版本不匹配(您使用它的各种 23 版本)

    5. 使用非常旧的版本,例如 google play services 9.8.0 等。

    6. 仍在使用已弃用的 compile 而不是 implementation

    该列表可能不完整,但我希望这有助于您开始组织您的 gradle 文件

    【讨论】:

      【解决方案3】:

      改变这个。希望有帮助。

       compile project(':library')
       compile project(':simpl3r')
       compile project(':androidHorizontalListView')
       compile project(':swipelibrary')
       compile project(':sample-chat')
       compile project(':sample-pushnotifications')
      

       implementation project(':library')
       implementation project(':simpl3r')
       implementation project(':androidHorizontalListView')
       implementation project(':swipelibrary')
       implementation project(':sample-chat')
       implementation project(':sample-pushnotifications')
      

      更新: 您可以删除该行:

      apply plugin: 'com.neenbedankt.android-apt'
      

      您的应用级别 Gradle 依赖项应包括

      compile 'com.jakewharton:butterknife:8.8.1'
      annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
      

      【讨论】:

      • 如果我这样更改,我会收到此错误.......无法解析':tweak2@debug/compileClasspath'的依赖关系:无法解析项目:sample-pushnotifications。
      • 哈哈我变了。我收到另一个错误............错误:android-apt 插件与 Android Gradle 插件不兼容。请改用“annotationProcessor”配置。
      • 删除 apt 后 .Iam 出现此错误............ > 错误:java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2错误:查看日志了解详情
      • 尝试将这一行apt 'com.thefinestartist:compilers:0.9.1'改为annotationProcessor 'com.thefinestartist:compilers:0.9.1'
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-02-06
      • 2020-04-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多