Gradle sync failed: Gradle DSL method not found: 'compile()',Consult IDE log for more details

本文介绍了当遇到Gradle同步失败错误Gradle DSL method not found: ‘compile()’时的解决方法。错误通常由在同一行定义了多个依赖引起,解决方式是将这些依赖分开到不同行。

同步gradle出现
Gradle sync failed: Gradle DSL method not found: ‘compile()’,Consult IDE log for more details (Help | Show Log)
错误。
原因:多个依赖在一行里。
eg:
dependencies {
compile "com.android.support:appcompat-v7:${appcompat_library_version}" compile "com.android.support:support-v4:${support_library_version}" compile project(':libraries:BaseGameUtils')
}

解决办法:敲回车 分开 就可以了。
参考:http://stackoverflow.com/questions/35728671/gradle-sync-failed-gradle-dsl-method-not-found-compile-consult-ide-log-for

PS D:\ASSimpleDemo> ./gradlew build --warning-mode all Configuration on demand is an incubating feature. > Configure project : The RepositoryHandler.jcenter() method has been deprecated. This is scheduled to be removed in Gradle 8.0. JFrog announced JCenter's shutdown in February 2021. Use mavenCentral() instead. Consult the upgrading guide for further information: https://docs.gradle.org/7.0.2/userguide/upgrading_version_6.html#jcenter_deprecation at build_ce3ruzx0et0a87btopefgvs46$_run_closure1$_closure2.doCall(D:\ASSimpleDemo\build.gradle:11) (Run with --stacktrace to get the full stack trace of this deprecation warning.) > Configure project :app WARNING:Using flatDir should be avoided because it doesn't support any meta-data formats. Warning: This version only understands SDK XML versions up to 2 but an SDK XML file of version 3 was encountered. This can happen if you use versions of Android Studio and the command-line tools that were released at different times. Warning: 意外的元素 (uri:"", local:"extension-level")。所需元素为<{}codename>,<{}layoutlib>,<{}api-level> Warning: 意外的元素 (uri:"", local:"base-extension")。所需元素为<{}codename>,<{}layoutlib>,<{}api-level> WARNING:We recommend using a newer Android Gradle plugin to use compileSdk = 34 This Android Gradle plugin (7.0.2) was tested up to compileSdk = 31 This warning can be suppressed by adding android.suppressUnsupportedCompileSdk=34 to this project's gradle.properties The build will continue, but you are strongly encouraged to update your project to use a newer Android Gradle Plugin that has been tested with compileSdk = 34 > Task :app:processReleaseMainManifest D:\ASSimpleDemo\app\src\main\AndroidManifest.xml:21:5-79 Warning: Element uses-permission#android.permission.ACCESS_FINE_LOCATION at AndroidManifest.xml:21:5-79 duplicated with element declared at AndroidManifest.xml:12:5-79 D:\ASSimpleDemo\app\src\main\AndroidManifest.xml:22:5-65 Warning: Element uses-permission#android.permission.CAMERA at AndroidManifest.xml:22:5-65 duplicated with element declared at AndroidManifest.xml:16:5-64 D:\ASSimpleDemo\app\src\main\AndroidManifest.xml:23:5-80 Warning: Element uses-permission#android.permission.READ_EXTERNAL_STORAGE at AndroidManifest.xml:23:5-80 duplicated with element declared at AndroidManifest.xml:18:5-80 D:\ASSimpleDemo\app\src\main\AndroidManifest.xml:24:5-81 Warning: Element uses-permission#android.permission.WRITE_EXTERNAL_STORAGE at AndroidManifest.xml:24:5-81 duplicated with element declared at AndroidManifest.xml:5:5-81 > Task :app:processDebugResources FAILED FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':app:processDebugResources'. > A failure occurred while executing com.android.build.gradle.internal.res.LinkApplicationAndroidResourcesTask$TaskAction > AAPT2 aapt2-7.0.2-7396180-windows Daemon #0: Unexpected error during link, attempting to stop daemon. This should not happen under normal circumstances, please file an issue if it does. * 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 BUILD FAILED in 8s 36 actionable tasks: 12 executed, 24 up-to-date
最新发布
06-24
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值