我收到此错误并尝试清理项目并重建它。但它没有用。
而且我也试图从gradle中删除一些代码,但仍无法正常工作。
请指教。
感谢。
错误:
这是Build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.2'
// classpath 'com.google.gms:google-services:1.3.0-beta1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
android {
compileSdkVersion 21
buildToolsVersion '20.0.0'
}
dependencies {
}
这是来自app \ build.gradle
apply plugin: 'com.android.application'
//apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 21
buildToolsVersion "20.0.0"
defaultConfig {
applicationId "me.kevingleason.pubnubchat"
minSdkVersion 15
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.pubnub:pubnub-android:3.7.4'
compile 'com.google.android.gms:play-services:7.5.0'
}
答案 0 :(得分:0)
尝试以下操作,看看是否有效。另外,为我提供你正在使用和构建工具版本的android studio版本。
的build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
应用程序/的build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion '24.0.0' //replace with your buildtoolsversion here
defaultConfig {
applicationId "me.kevingleason.pubnubchat"
minSdkVersion 15
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
provided 'com.android.support:support-annotations:23.3.0'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:design:23.4.0'
compile 'com.google.android.gms:play-services:9.0.2'
compile 'com.android.support:support-v4:23.4.0'
compile 'com.pubnub:pubnub-android:3.7.4' //erase if error is given and recompile
}
答案 1 :(得分:0)
您的问题首先是外部dependencies
中的第二个buil.gradle
。这实际上是错误消息中的第19行。删除它(在第一个末尾):
dependencies {
}
然后上面有一些NOTE
评论说明:
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
因此,根据经验,请记住始终将您的依赖项放在app-module build.gradle
中,而不是项目的依赖项。
希望您觉得这很有帮助。