最近帮同事安装Android studio,安装完新建一个工程试一试,结果新建的Hello World都跑不起来,在这里记录一下遇到的问题和解决方法。
一、Android Gradle Plugin Version版本太高
用新的Android studio版本“北极狐”新建项目,Gradle版本直接最新的,编译的时候提示Java版本不对,进File-Project Structure改一下Gradle Plugin Version。我的设置是这样:
二、Could not find method dependencyResolutionManagement() for arguments
这个错误一般都是配置有问题,我解决的方法是把外面的build.gradle里的内容改为:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath "com.android.tools.build:gradle:4.1.3"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
再把settings.gradle里的多余的那一坨删了,只留下:
include ':app'
rootProject.name = "AppName"
进行完上述操作,再编译程序运行通过了!
新建的工程都跑不起来,这可真是太难了。