Android Studio 海豚构建.gradle文件插件{id 'com.android.application'版本'7.3.1'假id 'com.android.library'版本'7.3.1'假

baubqpgj  于 2022-11-16  发布在  Android
关注(0)|答案(1)|浏览(163)

**我正在尝试将Firebase添加到我的android项目中,它需要以下步骤:**要使google-services.json配置值可供Firebase SDK访问,您需要Google服务Gradle插件。android studio海豚2021.3.1

将插件作为buildscript依赖项添加到项目级build.gradle文件:
根级别(项目级别)Gradle文件(/build.gradle):

buildscript {
  repositories {
    // Make sure that you have the following two repositories
    google()  // Google's Maven repository

    mavenCentral()  // Maven Central repository

  }
  dependencies {
    ...
    // Add the dependency for the Google services Gradle plugin
    classpath 'com.google.gms:google-services:4.3.13'

  }
}

allprojects {
  ...
  repositories {
    // Make sure that you have the following two repositories
    google()  // Google's Maven repository

    mavenCentral()  // Maven Central repository

  }
}

但在我的build.gradle文件中,没有类似的内容。它几乎是空的,只有这两行:

// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
    id 'com.android.application' version '7.3.1' apply false
    id 'com.android.library' version '7.3.1' apply false

}

我试图回到旧版本,但它导致错误。我寻找代理设置,但我找不到任何东西。我试图禁用防火墙,并重新启动没有发生任何事情。我下载了Android花栗鼠到另一台PC,但它是游戏错误与7. 2. 2
编译. graddle(应用程序)

plugins {
    id 'com.android.application'

}

android {
    namespace 'com.example.proje_15ig'
    compileSdk 32

    defaultConfig {
        applicationId "com.example.proje_15ig"
        minSdk 23
        targetSdk 32
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

dependencies {

    implementation 'androidx.appcompat:appcompat:1.5.1'
    implementation 'com.google.android.material:material:1.7.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.3'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}

设置.gradle

pluginManagement {
    repositories {
        gradlePluginPortal()
        google()
        mavenCentral()
    }
}

dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        google()
        mavenCentral()
    }
}
rootProject.name = "proje_15ig"
include ':app'

Gradle Package 属性

#Sun Oct 30 18:28:07 TRT 2022
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME

Gradle属性

# Project-wide Gradle settings.
# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
# AndroidX package structure to make it clearer which packages are bundled with the
# Android operating system, and which are packaged with your app's APK
# https://developer.android.com/topic/libraries/support-library/androidx-rn
android.useAndroidX=true
# Enables namespacing of each library's R class so that its R class includes only the
# resources declared in the library itself and none from the library's dependencies,
# thereby reducing the size of the R class for that library

我试图回到旧版本,但它导致错误。我寻找代理设置,但我找不到任何东西。我试图禁用防火墙并重新启动,但没有发生任何事情

xwbd5t1u

xwbd5t1u1#

添加到项目级Gradle文件的顶部

buildscript {
        dependencies {
            classpath 'com.google.gms:google-services:4.3.10'
        }
}

You can follow this image

相关问题