Cannot create new activity in android studio

2019-03-29 02:09发布

I keep getting an IllegalStateException error in the event log while creating new activity in android studio:

11:27:15 InvalidReferenceException: Error executing FreeMarker template: The following has evaluated to null or missing:
==> srcDir  [in template "root://activities/common/common_globals.xml.ftl" at line 41, column 34]

Tip: If the failing expression is known to be legally null/missing, either specify a default value with myOptionalVar!myDefault, or use when-presentwhen-missing. (These only cover the last step of the expression; to cover the whole expression, use parenthessis: (myOptionVar.foo)!myDefault, (myOptionVar.foo)??

7条回答
The star\"
2楼-- · 2019-03-29 02:47

In the file build.gradle, add

buildDir = "C:/tmp/${rootProject.name}/${project.name}"

sychronize gradle then remove it and synchronize again. This worked for me.

allprojects {
buildDir = "C:/tmp/${rootProject.name}/${project.name}"
repositories {
    jcenter()
}

}

查看更多
登录 后发表回答