Why does upgrading to AGP 8.3.0-alpha06 make build fail with "No value passed for parameter 'providers'"
Asked Answered
F

2

17

I have upgraded my android studio version to

Android Studio Iguana | 2023.2.1 Canary 6
Build #AI-232.9921.47.2321.10875067, built on September 28, 2023
Runtime version: 17.0.8+0-17.0.8b1000.22-10799086 x86_64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
macOS 12.6.1
GC: G1 Young Generation, G1 Old Generation
Memory: 5120M
Cores: 12
Metal Rendering is ON
Registry:
    external.system.auto.import.disabled=true
    debugger.new.tool.window.layout=true
    ide.text.editor.with.preview.show.floating.toolbar=false
    ide.instant.shutdown=false
    ide.experimental.ui=true
    ide.images.show.chessboard=true

Non-Bundled Plugins:
    com.github.rmehri01.onenord (0.0.7)
    com.arcticicestudio.nord.jetbrains (0.13.0)

and the AGP to version 8.3.0-alpha06

now my build fails on these two lines

import com.android.build.gradle.internal.cxx.configure.gradleLocalProperties

val googleApiKey: String = gradleLocalProperties(rootDir).getProperty("GOOGLE_API_KEY")
val googleCrashReportingApiKey: String = gradleLocalProperties(rootDir).getProperty("GOOGLE_CRASH_REPORTING_API_KEY")


* What went wrong:
Script compilation errors:

  Line 16: val googleApiKey: String = gradleLocalProperties(rootDir).getProperty("GOOGLE_API_KEY")
                                                            ^ No value passed for parameter 'providers'

  Line 17: val googleCrashReportingApiKey: String = gradleLocalProperties(rootDir).getProperty("GOOGLE_CRASH_REPORTING_API_KEY")
                                                                          ^ No value passed for parameter 'providers'

2 errors

Im guessing rootDir is null, however how do I resolve this issue? What is the root cause?

I have now upgraded to Canary 7 and i get this issue when attempting to upgrade the AGP

enter image description here

I fixed this issue by replacing with

val properties = Properties().apply { load(FileInputStream(File(rootProject.rootDir, "local.properties"))) }

val googleApiKey: String = properties.getProperty("GOOGLE_API_KEY")
val googleCrashReportingApiKey: String = properties.getProperty("GOOGLE_CRASH_REPORTING_API_KEY")
Fresno answered 6/10, 2023 at 6:20 Comment(0)
R
11

I fixed the problem by replacing this:

gradleLocalProperties(rootDir).getProperty("GOOGLE_API_KEY")

By adding the providers parameter like this:

gradleLocalProperties(rootDir, providers).getProperty("GOOGLE_API_KEY")
Remora answered 28/2, 2024 at 16:6 Comment(3)
Perhaps you meant "gradleLocalProperties(rootDir, providers)" instead of "gradleLocalProperties(rootDir, provider)"?Engen
that does not work, i get: "Too many arguments for public fun gradleLocalProperties(projectRootDir: File): Properties defined in com.android.build.gradle.internal.cxx.configure"Sideshow
@Sideshow Do not trust the red lint. If you add the providersparameter and resync the gradle project, it will work like expected.Remora
H
5

Environment

com.android.application 8.3.0

Need to add providers field and resync your project (don't need to create this filed)

gradleLocalProperties(rootDir, providers).apply {
    storePassword = getProperty("storePwd")
    keyAlias = getProperty("keyAlias")
    keyPassword = getProperty("keyPwd")
}
Hufford answered 1/3, 2024 at 9:24 Comment(1)
where to add that environment?Sideshow

© 2022 - 2025 — McMap. All rights reserved.