简体   繁体   English

android studio:FAILURE:构建失败,出现异常

[英]android studio: FAILURE: Build failed with an exception

I am trying to build a flutter app I get so many problems while building it and found a solutions for all of them but now I am stuck since the morning with this one:我正在尝试构建一个颤振应用程序,我在构建它时遇到了很多问题,并为所有这些问题找到了解决方案,但现在我从早上开始就被这个问题困住了:

> 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

my project build.gradle:我的项目 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
}

my app build.gradle:我的应用程序 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: gradle.propertis:

org.gradle.jvmargs=-Xmx1536M
android.useAndroidX=true
android.enableJetifier=true

Solutions I tried:我试过的解决方案:

  • invalidate cache and restart使缓存无效并重新启动
  • flutter clean && flutter pub get flutter clean && flutter pub get
  • gradlew clean && gradlew build gradlew 清洁 && gradlew 构建
  • delete the %USER%/.android and %USER%/.gradle and delete every thing related to android studio and reinstalled it删除 %USER%/.android 和 %USER%/.gradle 并删除与 android studio 相关的所有内容并重新安装它
  • use a VPN ( tried 3 )使用 VPN(尝试 3 次)

but unfortunatly, nothing helped me但不幸的是,没有任何帮助我

for further info: I am building fluxstore app更多信息:我正在构建fluxstore应用程序

I still think its a connection issue .我仍然认为它是一个连接问题。 is maven google available in your browser with no VPN ?在没有 VPN 的情况下,maven google 是否可以在您的浏览器中使用?

if no then here is a old solution of mine , on how to configure gradle to use you VPN properly .如果不是,那么这里是我的一个旧解决方案,关于如何配置 gradle 以正确使用您的 VPN。 Because you need to tell gradle to send request over VPN using gradle.properties file .因为您需要告诉 gradle 使用 gradle.properties 文件通过 VPN 发送请求。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM