Gradle托管设备引入了一项新功能(例如,请参见此处:(第10页)
安装程序看起来很简单,只需要复制几行到模块级的build.gradle
文件中,一切都应该可以正常工作。
很遗憾,我的情况不是这样,我争取一些建议,请。代码是红色的,脚本没有成功。请看我的build.gradle.kts
文件:
带下划线的ManagedVirtualDevice显示以下错误:
我的Android工作室版本是Android工作室大黄蜂|2021.1.1金丝雀11构建编号AI-211.7628.21.2111.7676841,构建日期2021年8月26日。
同步Gradle显示:
org.gradle.internal.exceptions.LocationAwareException: Build file '/*****/app/build.gradle.kts' line: 112
Script compilation errors:
Line 112: pixel2api29 (com.android.build.api.dsl.ManagedVirtualDevice) {
^ Unresolved reference: pixel2api29
Line 112: pixel2api29 (com.android.build.api.dsl.ManagedVirtualDevice) {
^ Classifier 'ManagedVirtualDevice' does not have a companion object, and thus must be initialized here
Line 114: device = "Pixel 2"
^ Unresolved reference: device
Line 115: apiLevel = 29
^ Unresolved reference: apiLevel
Line 117: systemImageSource = "google"
^ Unresolved reference: systemImageSource
Line 118: abi = "x86"
^ Unresolved reference: abi
6 errors
at org.gradle.kotlin.dsl.execution.Interpreter$ProgramHost$compileSecondStageOf$cacheDir$1.invoke(Interpreter.kt:666)
at org.gradle.kotlin.dsl.execution.Interpreter$ProgramHost$compileSecondStageOf$cacheDir$1.invoke(Interpreter.kt:387)
at org.gradle.kotlin.dsl.provider.CompileKotlinScript.execute(KotlinScriptEvaluator.kt:375)
at org.gradle.internal.execution.steps.ExecuteStep.executeInternal(ExecuteStep.java:89)
at org.gradle.internal.execution.steps.ExecuteStep.access$000(ExecuteStep.java:40)
at org.gradle.internal.execution.steps.ExecuteStep$1.call(ExecuteStep.java:53)
at org.gradle.internal.execution.steps.ExecuteStep$1.call(ExecuteStep.java:50)
at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:200)
at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:195)
at org.gradle.internal.operations.DefaultBuildOperationRunner$3.execute(DefaultBuildOperationRunner.java:75)
...
哪一个
2条答案
按热度按时间i86rm4rw1#
刚刚遇到了同样的问题-您需要示例化一个
ManagedVirtualDevice
对象并对其进行配置,然后再将其添加到您的设备列表:请注意,导入与Google文档中的描述略有不同--在他们的示例中,他们传递的是接口,而不是实现。
2j4z5cfb2#
正确的等效方法是使用
NamedDomainObjectContainer
的方法:或者在需要引用设备时使用
by
(例如,组):请参阅中的
org.gradle.kotlin.dsl.NamedDomainObjectContainerScope
gradle-kotlin-dsl-7.4.jar!/org/gradle/kotlin/dsl/NamedDomainObjectContainerExtensionsKt.class