Gradle编译错误“无方法签名”

i34xakig  于 2022-11-14  发布在  其他
关注(0)|答案(2)|浏览(240)

当我尝试从终端运行./gradlew build.gradle时,我一直收到以下错误:

> No signature of method: org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.compile() is applicable for argument types: (org.gradle.api.internal.project.DefaultProject_Decorated) values: [project ':TestMobile']
Possible solutions: module(java.lang.Object)

我已经尝试在根build.gradle文件和子项目上应用java插件。但我仍然得到同样的错误。
我的项目结构如下:

ProjectRepos
->build.gradle
->settings.gradle
->TestMobile (Android plugin)
   ->build.gradle
->ThirdParty/SlidingMenu (Android library)
  ->build.gradle

其中,顶级build.gradle包含:

// Top-level build file where you can add configuration options common to all sub-   projects/modules.
buildscript {
    repositories {
    mavenCentral()
}
dependencies {
    classpath 'com.android.tools.build:gradle:0.5.+'
    compile project(':TestMobile')
    compile project(':ThirdParty:SlidingMenu')      
}
}

设置。gradle包含以下:

include ':ThirdParty:SlidingMenu'
include ':TestMobile'

测试移动-〉构建.gradle包含以下:

apply plugin: 'android'

dependencies {
    compile fileTree(dir: 'libs', include: '*.jar')
    compile project(':ThirdParty:SlidingMenu')
}

android {
compileSdkVersion 18
buildToolsVersion "18.0.1"

sourceSets {
    main {
        manifest.srcFile 'AndroidManifest.xml'
        java.srcDirs = ['src']
        resources.srcDirs = ['src']
        aidl.srcDirs = ['src']
        renderscript.srcDirs = ['src']
        res.srcDirs = ['res']
        assets.srcDirs = ['assets']
    }

    // Move the tests to tests/java, tests/res, etc...
    instrumentTest.setRoot('tests')

    debug.setRoot('build-types/debug')
    release.setRoot('build-types/release')
 }
}

第三方/滑动菜单-〉build.gradle包含以下内容:

apply plugin: 'android-library'
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
}

android {
compileSdkVersion 18
buildToolsVersion "18.0.1"

sourceSets {
    main {
        ......
        ......

   }
 }
06odsfpq

06odsfpq1#

buildscript块中不能有compile依赖项,只能有classpath依赖项。同样,你也不能有项目依赖项。你可能只需要去掉这两行。

bd1hkmkf

bd1hkmkf2#

对我来说,这是一个简单的语法错误(缺少逗号)时,添加一个字符串资源:
错误:

resValue "string" "app_name" "My App Dev"

正确答案:

resValue "string", "app_name", "My App Dev"

相关问题