android studio:失败:构建失败并出现异常
Posted
技术标签:
【中文标题】android studio:失败:构建失败并出现异常【英文标题】:android studio: FAILURE: Build failed with an exception 【发布时间】:2021-12-21 15:51:08 【问题描述】:我正在尝试构建一个颤振应用程序,我在构建它时遇到了很多问题,并为所有这些问题找到了解决方案,但现在我从早上开始就被这个应用程序困住了:
> Task :firebase_auth:generateDebugRFile FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':firebase_auth:generateDebugRFile'.
> Could not resolve all files for configuration ':firebase_auth:debugCompileClasspath'.
> Could not find browser-1.0.0.aar (androidx.browser:browser:1.0.0).
Searched in the following locations:
https://dl.google.com/dl/android/maven2/androidx/browser/browser/1.0.0/browser-1.0.0.aar
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.7/userguide/command_line_interface.html#sec:command_line_warnings
BUILD FAILED in 37s
我的项目 build.gradle:
buildscript
ext.kotlin_version = '1.5.31'
repositories
google()
jcenter()
maven
url 'http://storage.googleapis.com/r8-releases/raw'
dependencies
classpath 'com.android.tools:r8:2.1.75'
classpath 'com.google.gms:google-services:4.3.2'
classpath 'com.android.tools.build:gradle:4.1.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
allprojects
repositories
google()
jcenter()
rootProject.buildDir = '../build'
subprojects
project.buildDir = "$rootProject.buildDir/$project.name"
subprojects
project.evaluationDependsOn(':app')
task clean(type: Delete)
delete rootProject.buildDir
我的应用程序 build.gradle:
buildscript
repositories
// ...
maven url 'https://plugins.gradle.org/m2/' // Gradle Plugin Portal
dependencies
// ...
// OneSignal-Gradle-Plugin
classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:[0.12.6, 0.99.99]'
apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists())
localPropertiesFile.withReader('UTF-8') reader ->
localProperties.load(reader)
def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null)
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null)
flutterVersionCode = '1'
def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null)
flutterVersionName = '1.0'
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists())
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
android
compileSdkVersion 30
sourceSets
main.java.srcDirs += 'src/main/kotlin'
lintOptions
disable 'InvalidPackage'
checkReleaseBuilds false
defaultConfig
applicationId "com.inspireui.fluxstore"
minSdkVersion 20
targetSdkVersion 30
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled true
resConfigs "en"
manifestPlaceholders = [
onesignal_app_id: 'PUT_YOUR_ONESIGNAL_APP_ID_HERE',
// Project number pulled from dashboard, local value is ignored.
onesignal_google_project_number: 'REMOTE'
]
signingConfigs
release
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile file(keystoreProperties['storeFile'])
storePassword keystoreProperties['storePassword']
buildTypes
release
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.release
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
debug
signingConfig signingConfigs.release
flutter
source '../..'
dependencies
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
implementation 'com.android.support:multidex:1.0.3'
implementation 'androidx.browser:browser:1.3.0'
// For checking GMS availability.
implementation "com.google.android.gms:play-services-base:17.6.0"
// Fix duplicate exoplayer
implementation 'com.google.android.exoplayer:exoplayer:2.14.1'
googleServices disableVersionCheck = true
//Fix android-r issue
subprojects
project.buildDir = "$rootProject.buildDir/$project.name"
project.evaluationDependsOn(':app')
afterEvaluate project ->
if (project.hasProperty("android") && project.property("android").compileSdkVersion.equals("android-R"))
android
compileSdkVersion 30
gradle.propertis:
org.gradle.jvmargs=-Xmx1536M
android.useAndroidX=true
android.enableJetifier=true
我尝试过的解决方案:
使缓存失效并重新启动 flutter clean && flutter pub get gradlew clean && gradlew build 删除 %USER%/.android 和 %USER%/.gradle 并删除所有与 android studio 相关的东西并重新安装它 使用 ***(尝试 3 次)但不幸的是,没有任何帮助
更多信息:我正在建设fluxstore app
【问题讨论】:
【参考方案1】:我仍然认为这是一个连接问题。 maven google 是否可以在没有 *** 的浏览器中使用?
如果没有,那么这里是我的一个老solution,关于如何配置 gradle 以正确使用您的 ***。因为你需要告诉 gradle 使用 gradle.properties 文件通过 *** 发送请求。
【讨论】:
以上是关于android studio:失败:构建失败并出现异常的主要内容,如果未能解决你的问题,请参考以下文章
Android Studio 构建失败,“在根项目‘MyProject’中找不到任务’。”
Android Studio 和 Gradle:“构建失败,出现异常。”
在android visuel studio 3.5.2上构建并运行odk收集失败
Android Studio 4.1更新后应用程序的Gradle构建错误