我是一个安卓开发新手,我正在构建安卓应用,我正在使用gradle,我收到了错误信息A problem occurred configuring project ':app'。
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.0'
//classpath 'ext.supportLibraryVersion = 27.1.1'
classpath 'com.android.support:support-v4:27.1.1'
classpath 'com.google.gms:google-services:4.3.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}上面的代码是build.gradle文件的项目级别。以下代码是build.gradle文件的应用程序级别。
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "mm.com.fairway.firebaseauth"
minSdkVersion 22
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.0.2'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.google.firebase:firebase-analytics:17.2.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
}
apply plugin: 'com.google.gms.google-services'我搜索了解决方案来修复这个错误,但我还没有找到解决方案。对这个错误有任何想法,谢谢。
发布于 2019-11-08 23:52:20
classpath 'com.android.support:support-v4:27.1.1上面的代码行在错误的Gradle文件中。另外,将其从类路径更改为实现。
所以就像这样:
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.2'
//classpath 'ext.supportLibraryVersion = 27.1.1'
classpath 'com.google.gms:google-services:4.3.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}和
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "mm.com.fairway.firebaseauth"
minSdkVersion 22
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.google.firebase:firebase-analytics:17.2.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
apply plugin: 'com.google.gms.google-services'请注意,我将项目更新为28,其他依赖项也进行了升级。我这样做是因为我不再安装SDK 27。
发布于 2019-11-08 23:57:31
将Gradle构建工具升级到3.2或更高版本将解决此问题。
例如:
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.0'
//classpath 'ext.supportLibraryVersion = 27.1.1'
classpath 'com.android.support:support-v4:27.1.1'
classpath 'com.google.gms:google-services:4.3.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}这为我解决了问题,似乎也解决了另一个人的问题:
I have a gradle sync error JAVA_LETTER_OR_DIGIT when trying to add Firebase to my android project
https://stackoverflow.com/questions/58769485
复制相似问题