gpt4 book ai didi

android - Gradle 同步失败但项目运行正常

转载 作者:行者123 更新时间:2023-11-29 23:28:31 28 4
gpt4 key购买 nike

我知道这很奇怪。我今天启动了 Android Studio,开始显示“Gradle Sync Failed”消息,没有错误。在我昨天最后一次关闭 Android Studio 之前,一切都运行良好。然后我尝试运行该项目,它运行成功但仍然显示 Gradle 同步错误并且由于 gradle 同步错误未显示 XML 布局预览。我尝试了以下方法来摆脱它:

  1. 运行命令gradlew clean build --stacktrace
  2. gradlew clearBuildCache
  3. 使 Android Studio 失效/重启
  4. 删除C:\Users中的.gradle文件夹
  5. 手动删除了 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
}

最佳答案

经过 8 小时的努力,我通过从图书馆所需的 list 中删除它来解决问题

<uses-sdk
android:minSdkVersion="19"
tools:overrideLibrary="me.aflak.libraries" />

要求:

implementation 'me.aflak.libraries:fingerprint:2.5.3'

关于android - Gradle 同步失败但项目运行正常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53114497/

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