昨天狠下心來終於升級了Android Studio到了4.0,就是怕有兼容問題遲遲沒有升級,升級完後項目提示需要使用更高版本的Gradle,在Android Studio 4.0需要使用Gradle6.0以上的版本,所以如果出現低版本的時候就會有報錯,根據提示升級了Gradle的版本然後Rebuild了項目,果然沒有失望的報了一個編譯異常:
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':matisse'.
> Could not create an instance of type com.novoda.release.internal.compat.gradle5_3.AndroidSoftwareComponentCompat_Gradle_5_3.
> org/gradle/api/internal/java/usagecontext/LazyConfigurationUsageContext
看到原因是知乎的Matisse庫裏的Gradle版本過低了,打開了Matisse裏沒有找到Gradle的版本配置相關的內容,然後去build.gradle裏去找了半天也沒有找到跟Gradle有關的配置,clean,rebuild都試過了也不好使,再仔細的看錯誤,發現了奇怪的包名com.novoda.release.internal,於是開始找跟這個包名相關的內容,果然找到了
apply plugin: 'com.novoda.bintray-release'
publish {
userOrg = 'zhihu'
groupId = 'com.zhihu.android'
artifactId = 'matisse'
publishVersion = '0.5.2-beta4'
desc = 'A well-designed local image selector for Android'
website = 'https://www.zhihu.com/'
}
把以上代碼刪除後就可以正常編譯了,在這個庫裏也找到了它確實是在使用低版本的Gradle。
因爲這一行代碼又半天過去了……希望可以幫助到有需要的朋友,真是美好而充實的一天……