我知道这很奇怪。我今天开始启动Android Studio,并且开始显示“ Gradle Sync Failed”消息,没有错误。一切工作正常,直到昨天我最后关闭了Android Studio。然后,我尝试运行该项目,该项目成功运行,但是仍然出现Gradle同步错误,并且由于gradle同步错误而未显示XML布局预览。我尝试了以下方法来摆脱它:
gradlew clean build --stacktrace
gradlew clearBuildCache
.gradle
文件夹app/build
文件夹以下是gradle日志。
INFO - e.project.sync.GradleSyncState - Started setup of project 'projectName'.
INFO - idea.project.IndexingSuspender - Consuming IndexingSuspender activation event: SETUP_STARTED
INFO - e.project.sync.GradleSyncState - Gradle sync failed (29 s 70 ms)
INFO - idea.project.IndexingSuspender - Consuming IndexingSuspender deactivation event: SYNC_FINISHED
INFO - idea.project.IndexingSuspender - Finishing batch update for project: Project
PS: Android Studio没什么问题,因为它可以与另一个项目正常工作。
修改
这是我的 app / build.gradle
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
apply plugin: 'io.fabric'
android {
compileSdkVersion 27
lintOptions {
abortOnError false
}
signingConfigs {
release {
keyAlias 'xxxx'
keyPassword 'xxxxx'
storeFile file('../keystore/xxxx-xxxx.jks')
storePassword 'xxxxxx'
}
}
defaultConfig {
applicationId "xxxx.xxxxxx.xxxxxx.xxxx.app"
minSdkVersion 19
targetSdkVersion 27
versionCode 1
versionName "1.0"
dataBinding {
enabled = true
}
vectorDrawables.useSupportLibrary = true
externalNativeBuild {
cmake {
cppFlags ""
}
}
}
externalNativeBuild {
cmake {
path "CMakeLists.txt"
}
}
buildTypes {
debug {
versionNameSuffix "-dev"
minifyEnabled false
signingConfig signingConfigs.release
}
release {
minifyEnabled true
proguardFiles /*getDefaultProguardFile('proguard-android.txt'),*/ 'proguard-rules.pro'
signingConfig signingConfigs.release
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
//Other
implementation 'com.android.support:multidex:1.0.3'
implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support:cardview-v7:27.1.1'
implementation 'uk.co.chrisjenx:calligraphy:2.3.0'
implementation 'com.crealsolutions.real-lib:real-lib:1.0.4'
//View
implementation 'com.wang.avi:library:2.1.3'
implementation 'com.android.support:recyclerview-v7:27.1.1'
implementation 'com.intuit.sdp:sdp-android:1.0.5'
implementation 'com.intuit.ssp:ssp-android:1.0.5'
implementation 'com.joooonho:selectableroundedimageview:1.0.1'
// Retrofit2
implementation 'com.squareup.retrofit2:retrofit:2.4.0'
implementation 'com.squareup.retrofit2:converter-gson:2.3.0'
implementation 'com.squareup.okhttp3:logging-interceptor:3.9.1'
//Glide
implementation 'com.github.bumptech.glide:glide:4.6.1'
kapt 'com.github.bumptech.glide:compiler:4.6.1'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
//Firebase
implementation 'com.google.firebase:firebase-core:16.0.4'
implementation 'com.crashlytics.sdk.android:crashlytics:2.9.5'
//Fingerprint
implementation 'me.aflak.libraries:fingerprint:2.5.3'
//OTP View
implementation 'com.chaos.view:pinview:1.4.2'
}
apply plugin: 'com.google.gms.google-services'
这是 project / build.gradle
buildscript {
ext.kotlin_version = '1.2.71'
repositories {
google()
jcenter()
mavenCentral()
maven {
url 'https://maven.google.com/'
}
maven {
url 'https://maven.fabric.io/public'
}
maven {
url 'https://dl.bintray.com/kotlin/kotlin-dev/'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.1.0'
classpath 'io.fabric.tools:gradle:1.25.4'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
mavenCentral()
maven {
url 'https://maven.google.com/'
}
maven {
url 'https://maven.fabric.io/public'
}
maven {
url 'https://dl.bintray.com/kotlin/kotlin-dev/'
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
答案 0 :(得分:0)
经过8个小时的奋斗,我通过从清单中删除该问题来解决此问题,这是图书馆要求的
<uses-sdk
android:minSdkVersion="19"
tools:overrideLibrary="me.aflak.libraries" />
要求:
implementation 'me.aflak.libraries:fingerprint:2.5.3'