col*_*ole 72 java android android-studio android-gradle-plugin
我试图在android studio中打开现有的android项目,并且gradle无法在没有错误的情况下构建应用程序
android studio继续抛出错误
Error:(74, 1) A problem occurred evaluating project ':app'.
> Could not find method implementation() for arguments
[com.android.support:appcompat-v7:26.0.0] on object of type
org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
Run Code Online (Sandbox Code Playgroud)
build.gradle中的我的代码这有助于理解我的问题我的依赖关系
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
// google & support
implementation "com.android.support:appcompat-v7:$supportVersion"
implementation "com.android.support:cardview-v7:$supportVersion"
implementation "com.android.support:recyclerview-v7:$supportVersion"
implementation "com.android.support:design:$supportVersion"
implementation "com.android.support:palette-v7:$supportVersion"
implementation "com.android.support:customtabs:$supportVersion"
implementation "com.android.support:support-v4:$supportVersion"
implementation 'com.google.android.exoplayer:exoplayer:r2.0.4'
// utils
implementation 'com.github.bumptech.glide:glide:4.0.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.0.0'
implementation 'com.koushikdutta.ion:ion:2.1.7'
implementation 'com.github.Commit451:bypasses:1.0.4'
implementation 'com.jakewharton:butterknife:8.8.0'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.0'
implementation 'com.drewnoakes:metadata-extractor:2.9.1'
implementation "com.orhanobut:hawk:2.0.1"
}
Run Code Online (Sandbox Code Playgroud)
请帮忙解决问题
Sau*_*rat 83
替换compile
为implementation
.
compile
最近被弃用并由implementation
或替换api
Sun*_*mar 54
Make sure you're adding these dependencies in android/app/build.gradle, not android/build.gradle
小智 27
确保你的gradle版本3 .在使用"实施"之前或更高.
在依赖项下打开项目级gradle文件
dependencies{
classpath 'com.android.tools.build:gradle:3.1.2'
}
Run Code Online (Sandbox Code Playgroud)
open gradle wrapper-properties使用分发URL作为
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
Run Code Online (Sandbox Code Playgroud)
或最新版本
synk项目,希望这解决了你的问题
don*_*uxx 22
您至少需要使用Gradle 3.4或更高版本才能使用implementation
.不建议继续使用已弃用的,compile
因为这会导致构建时间变慢.有关更多详细信息,请参阅官方Android开发者指南
当您的模块配置实现依赖项时,它让Gradle知道模块不希望在编译时将依赖项泄漏给其他模块.也就是说,依赖性仅在运行时可用于其他模块.使用此依赖项配置而不是api或compile可以显着缩短构建时间,因为它减少了构建系统需要重新编译的项目数量.例如,如果实现依赖项更改其API,则Gradle仅重新编译该依赖项以及直接依赖于它的模块.大多数应用和测试模块都应使用此配置.
https://developer.android.com/studio/build/gradle-plugin-3-0-0-migration.html#new_configurations
更新: compile
将在2018年底之前删除,因此请确保您仅使用implementation
现在:
警告:配置'compile'已过时,已替换为'implementation'.它将在2018年底删除
小智 19
通过在应用程序文件夹中添加我的依赖项解决了这个问题
转到:app -> Gradle Scripts -> gradle.build(Module: app) 并在该文件中添加依赖项,而不是全局 build.gradle 文件
太可笑了,但我还是想分享一下我的经验,以防有人遇到像我这样的情况。
请检查您是否更改:compileSdkVersion
-->implementationSdkVersion
错误
对我来说,我把我的依赖放在了错误的位置。
buildscript {
dependencies {
//Don't put dependencies here.
}
}
dependencies {
//Put them here
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
133646 次 |
最近记录: |