本人的Android studio版本基础信息
Android Studio Bumblebee | 2021.1.1 Patch 3
Build #AI-211.7628.21.2111.8309675, built on March 17, 2022
Runtime version: 11.0.11+9-b60-7590822 amd64
VM: OpenJDK 64-Bit Server VM by Oracle Corporation
Windows 10 10.0
GC: G1 Young Generation, G1 Old Generation
Memory: 1280M
Cores: 12
Registry: external.system.auto.import.disabled=true, ide.windowSystem.autoShowProcessPopup=true, ide.tooltip.initialDelay=695
Non-Bundled Plugins: com.herbert.george.flutter-snippets (2.0.0-stable-1), Dart (211.7817), org.jetbrains.kotlin (211-1.6.21-release-334-AS7442.40), org.intellij.plugins.markdown (211.7142.37)
通过翻译可以知道:pluginManagement{}块必须出现在脚本中任何其他语句之前
正确如下:
pluginManagement {
repositories {
gradlePluginPortal()
mavenCentral()
//Jetpack
maven { url 'https://maven.aliyun.com/repository/google' }
maven { url 'https://maven.aliyun.com/repository/jcenter' }
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
...省略
}
}
rootProject.name = "IMultimedia"
include ':app'
错误原因是
我把 rootProject.name = "IMultimedia " include ':app' 语句放到pluginManagement{}方法上面导致报错。