Android Studio 升级gradle异常

升级gradle
dependencies {
    classpath 'com.android.tools.build:gradle:3.4.1'
    classpath 'com.jakewharton:butterknife-gradle-plugin:8.5.1'
}

各种惊喜:

Cannot set the value of read-only property 'outputFile' for ApkVariantOutputImpl_Decorated{apkData=Main{type=MAIN, fullName=choutiDebug, filters=[], versionCode=300330, versionName=3.3.3}} of type com.android.build.gradle.internal.api.ApkVariantOutputImpl.

 解决方法:

 applicationVariants.all { variant ->
    variant.outputs.each { output ->
          def outputFile = output.outputFile
          def fileName = "name_${getVersionName()}_${variant.productFlavors[0].name}.apk"
          output.outputFileName = fileName
                }
       }

ERROR: The Android Gradle plugin supports only Butterknife Gradle plugin version 9.0.0-rc2 and higher.
The following dependencies do not satisfy the required version:
root project 'chouti-android' -> com.jakewharton:butterknife-gradle-plugin:8.5.1
Affected Modules: chouti-android

解决方法:

升级Butterknife 版本,并且把compile 全部替换为implementation

ERROR: All flavors must now belong to a named flavor dimension. Learn more at https://d.android.com/r/tools/flavorDimensions-missing-error-message.html
Affected Modules: chouti-android

解决方法:

flavorDimensions "channel"
productFlavors {
    productFlavors.all { flavor ->
         dimension "channel"
    }
 }

ERROR: The SourceSet 'instrumentTest' is not recognized by the Android Gradle Plugin. Perhaps you misspelled something?
Affected Modules: chouti-android

解决方法:

instrumentTest.setRoot('tests') 替换为:androidTest.setRoot('tests')

> Task :mergeExtDexChoutiDebug FAILED
AGPBI: {"kind":"error","text":"Static interface methods are only supported starting with Android N (--min-api 24): void butterknife.Unbinder.lambda$static$0()","sources":[{}],"tool":"D8"}

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':mergeExtDexChoutiDebug'.
> Could not resolve all files for configuration ':choutiDebugRuntimeClasspath'.
   > Failed to transform artifact 'butterknife-runtime.aar (com.jakewharton:butterknife-runtime:9.0.0-rc2)' to match attributes {artifactType=android-dex, dexing-is-debuggable=true, dexing-min-sdk=16}.
      > Execution failed for DexingTransform: ******\.gradle\caches\transforms-2\files-2.1\e7c412e8645b205cce2243e763339353\jars\classes.jar.
         > Error while dexing.

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

* Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/5.4.1/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 19s
56 actionable tasks: 6 executed, 50 up-to-date
 

解决方法:

 compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
 }

D:\chouti\chouti-android\AndroidManifest.xml:28:13-35 Error:
    Attribute meta-data#android.support.VERSION@value value=(26.0.0) from [com.android.support:design:26.0.0] AndroidManifest.xml:28:13-35
    is also present at [com.android.support:support-v4:26.1.0] AndroidManifest.xml:28:13-35 value=(26.1.0).
    Suggestion: add 'tools:replace="android:value"' to <meta-data> element at AndroidManifest.xml:26:9-28:38 to override.

See http://g.co/androidstudio/manifest-merger for more information about the manifest merger.


FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':processChoutiDebugManifest'.
> Manifest merger failed : Attribute meta-data#android.support.VERSION@value value=(26.0.0) from [com.android.support:design:26.0.0] AndroidManifest.xml:28:13-35
      is also present at [com.android.support:support-v4:26.1.0] AndroidManifest.xml:28:13-35 value=(26.1.0).
      Suggestion: add 'tools:replace="android:value"' to <meta-data> element at AndroidManifest.xml:26:9-28:38 to override.

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

* Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/5.4.1/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 11s
 

解决方法:

在build.gradle中添加如下内容

configurations.all {
    resolutionStrategy.eachDependency { DependencyResolveDetails details ->
        def requested = details.requested
        if (requested.group == 'com.android.support') {
            if (!requested.name.startsWith("multidex")) {
                details.useVersion '26.1.0'//support版本号
            }
        }
    }
}

 

ERROR: The minSdk version should not be declared in the android manifest file. You can move the version from the manifest to the defaultConfig in the build.gradle file.
Remove minSdkVersion and sync project
Affected Modules: chouti-android

解决方法:

删除AndroidManifest.xml中

 <uses-sdk
        android:minSdkVersion="16"
        android:targetSdkVersion="26" />

 

所有问题解决 编译成功运行正常。

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值