繁体   English   中英

升级了Android Studio,现在我收到与项目gradle文件相关的消息“找不到属性'compile'...”

[英]Upgraded Android Studio, now I'm getting the message “Could not find property 'compile'…” related to my project gradle file

消息是

Error:(27, 0) Could not find property 'compile' on org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler_Decorated@64d9a7e6.   
Open File        

当我按Open file ,我build.gradle了我的项目的build.gradle ,并且我认为它试图向我展示我的依赖关系。 该页面如下所示:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.1"

    defaultConfig {
        applicationId "com.example.myname.myappname"
        minSdkVersion 15
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

def var = dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    //compile 'com.google.android.gms:play-services:9.2.1'
    compile
    'com.android.support:appcompat-v7:24.1.1' compile
    'com.squareup.okhttp:okhttp:2.7.2' compile
    'com.jakewharton:butterknife:7.0.1' compile
    'com.android.support:design:24.1.1' compile
    'com.android.support:multidex:1.0.1' compile 'com.google.android.gms:play-services:9.4.0'
    compile 'com.yayandroid:LocationManager:1.1.2'
    compile 'com.google.android.gms:play-services-ads:9.4.0'
    compile 'com.google.android.gms:play-services-identity:9.4.0'
    compile 'com.google.android.gms:play-services-gcm:9.4.0'
}

另外, var (来自def var = dependancies )显示为灰色,当我将其放在鼠标上时,它显示“未使用分配”,尽管我不知道这是否相关。 我使用的是一年左右以前的版本,但是我可以在新版本中使用其他一些项目。

def var = dependencies {似乎是废话,它应该只是dependencies { ,但这没有错误,只是废话。

我认为您的问题是换行符。 整个街区

def var = dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    //compile 'com.google.android.gms:play-services:9.2.1'
    compile
    'com.android.support:appcompat-v7:24.1.1' compile
    'com.squareup.okhttp:okhttp:2.7.2' compile
    'com.jakewharton:butterknife:7.0.1' compile
    'com.android.support:design:24.1.1' compile
    'com.android.support:multidex:1.0.1' compile 'com.google.android.gms:play-services:9.4.0'
    compile 'com.yayandroid:LocationManager:1.1.2'
    compile 'com.google.android.gms:play-services-ads:9.4.0'
    compile 'com.google.android.gms:play-services-identity:9.4.0'
    compile 'com.google.android.gms:play-services-gcm:9.4.0'
}

应该是

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    //compile 'com.google.android.gms:play-services:9.2.1'
    compile 'com.android.support:appcompat-v7:24.1.1'
    compile 'com.squareup.okhttp:okhttp:2.7.2'
    compile 'com.jakewharton:butterknife:7.0.1'
    compile 'com.android.support:design:24.1.1'
    compile 'com.android.support:multidex:1.0.1'
    compile 'com.google.android.gms:play-services:9.4.0'
    compile 'com.yayandroid:LocationManager:1.1.2'
    compile 'com.google.android.gms:play-services-ads:9.4.0'
    compile 'com.google.android.gms:play-services-identity:9.4.0'
    compile 'com.google.android.gms:play-services-gcm:9.4.0'
}

一切都应该再次工作。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM