gpt4 book ai didi

android - 升级了Android Studio,现在我收到消息 “Could not find property ' compile'…”与我的项目gradle文件相关

转载 作者:行者123 更新时间:2023-12-03 06:05:58 26 4
gpt4 key购买 nike

消息是

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中,并且我认为它是在向我展示我的依赖关系。该页面如下所示:
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'
}

并且一切都应该再次工作。

关于android - 升级了Android Studio,现在我收到消息 “Could not find property ' compile'…”与我的项目gradle文件相关,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38809514/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com