Android Studio 无法创建新项目
Android Studio can't create new project
我将 Android studio 更新到 2.2.1,但我创建了一个新项目,但出现了 RuntimeException。
java.lang.RuntimeException:
com.android.tools.idea.templates.FreemarkerUtils$TemplateProcessingException:
freemarker.core.ParseException: Parsing error in template
"root://gradle-projects/NewAndroidModule/recipe.xml.ftl" in line 6,
column 2:Unknown directive: #ifues. Help (latest version):
http://freemarker.org/docs/ref_directive_alphaidx.html; you're using
FreeMarker 2.3.20.
由于某种原因,您的模板文件在安装过程中损坏了。
让我附上我的文件如下。如需申请,请按以下步骤操作。
- 关闭Android工作室。
- 使用文本编辑器(即 Notepad++)打开位于
C:\Program Files\Android\Android Studio\plugins\android\lib\templates\gradle-projects\NewAndroidModule
目录的 recipe.xml.ftl
文件
- 复制粘贴下面的代码,然后保存。 (
UTF-8
格式)
- 重新运行 Android Studio。
注意文件来自AndroidStudio版本2.2.1
<?xml version="1.0"?>
<recipe>
<#if backwardsCompatibility!true>
<dependency mavenUrl="com.android.support:appcompat-v7:${buildApi}.+"/>
</#if>
<#if unitTestsSupported>
<dependency mavenUrl="junit:junit:4.12" gradleConfiguration="testCompile" />
</#if>
<#if !createActivity>
<mkdir at="${escapeXmlAttribute(srcOut)}" />
</#if>
<mkdir at="${escapeXmlAttribute(projectOut)}/libs" />
<merge from="root/settings.gradle.ftl"
to="${escapeXmlAttribute(topOut)}/settings.gradle" />
<instantiate from="root/build.gradle.ftl"
to="${escapeXmlAttribute(projectOut)}/build.gradle" />
<instantiate from="root/AndroidManifest.xml.ftl"
to="${escapeXmlAttribute(manifestOut)}/AndroidManifest.xml" />
<mkdir at="${escapeXmlAttribute(resOut)}/drawable" />
<#if copyIcons && !isLibraryProject>
<copy from="root/res/mipmap-hdpi"
to="${escapeXmlAttribute(resOut)}/mipmap-hdpi" />
<copy from="root/res/mipmap-mdpi"
to="${escapeXmlAttribute(resOut)}/mipmap-mdpi" />
<copy from="root/res/mipmap-xhdpi"
to="${escapeXmlAttribute(resOut)}/mipmap-xhdpi" />
<copy from="root/res/mipmap-xxhdpi"
to="${escapeXmlAttribute(resOut)}/mipmap-xxhdpi" />
<copy from="root/res/mipmap-xxxhdpi"
to="${escapeXmlAttribute(resOut)}/mipmap-xxxhdpi" />
</#if>
<#if makeIgnore>
<copy from="root/module_ignore"
to="${escapeXmlAttribute(projectOut)}/.gitignore" />
</#if>
<#if enableProGuard>
<instantiate from="root/proguard-rules.txt.ftl"
to="${escapeXmlAttribute(projectOut)}/proguard-rules.pro" />
</#if>
<#if !(isLibraryProject??) || !isLibraryProject>
<instantiate from="root/res/values/styles.xml.ftl"
to="${escapeXmlAttribute(resOut)}/values/styles.xml" />
<#if buildApi gte 22>
<copy from="root/res/values/colors.xml"
to="${escapeXmlAttribute(resOut)}/values/colors.xml" />
</#if>
</#if>
<instantiate from="root/res/values/strings.xml.ftl"
to="${escapeXmlAttribute(resOut)}/values/strings.xml" />
<instantiate from="root/test/app_package/ExampleInstrumentedTest.java.ftl"
to="${escapeXmlAttribute(testOut)}/ExampleInstrumentedTest.java" />
<#if unitTestsSupported>
<instantiate from="root/test/app_package/ExampleUnitTest.java.ftl"
to="${escapeXmlAttribute(unitTestOut)}/ExampleUnitTest.java" />
</#if>
<#if includeCppSupport!false>
<instantiate from="root/CMakeLists.txt.ftl"
to="${escapeXmlAttribute(projectOut)}/CMakeLists.txt" />
<mkdir at="${nativeSrcOut}" />
<instantiate from="root/native-lib.cpp.ftl" to="${nativeSrcOut}/native-lib.cpp" />
</#if>
</recipe>
我将 Android studio 更新到 2.2.1,但我创建了一个新项目,但出现了 RuntimeException。
java.lang.RuntimeException:
com.android.tools.idea.templates.FreemarkerUtils$TemplateProcessingException:
freemarker.core.ParseException: Parsing error in template
"root://gradle-projects/NewAndroidModule/recipe.xml.ftl" in line 6,
column 2:Unknown directive: #ifues. Help (latest version):
http://freemarker.org/docs/ref_directive_alphaidx.html; you're using
FreeMarker 2.3.20.
由于某种原因,您的模板文件在安装过程中损坏了。
让我附上我的文件如下。如需申请,请按以下步骤操作。
- 关闭Android工作室。
- 使用文本编辑器(即 Notepad++)打开位于
C:\Program Files\Android\Android Studio\plugins\android\lib\templates\gradle-projects\NewAndroidModule
目录的recipe.xml.ftl
文件 - 复制粘贴下面的代码,然后保存。 (
UTF-8
格式) - 重新运行 Android Studio。
注意文件来自AndroidStudio版本2.2.1
<?xml version="1.0"?>
<recipe>
<#if backwardsCompatibility!true>
<dependency mavenUrl="com.android.support:appcompat-v7:${buildApi}.+"/>
</#if>
<#if unitTestsSupported>
<dependency mavenUrl="junit:junit:4.12" gradleConfiguration="testCompile" />
</#if>
<#if !createActivity>
<mkdir at="${escapeXmlAttribute(srcOut)}" />
</#if>
<mkdir at="${escapeXmlAttribute(projectOut)}/libs" />
<merge from="root/settings.gradle.ftl"
to="${escapeXmlAttribute(topOut)}/settings.gradle" />
<instantiate from="root/build.gradle.ftl"
to="${escapeXmlAttribute(projectOut)}/build.gradle" />
<instantiate from="root/AndroidManifest.xml.ftl"
to="${escapeXmlAttribute(manifestOut)}/AndroidManifest.xml" />
<mkdir at="${escapeXmlAttribute(resOut)}/drawable" />
<#if copyIcons && !isLibraryProject>
<copy from="root/res/mipmap-hdpi"
to="${escapeXmlAttribute(resOut)}/mipmap-hdpi" />
<copy from="root/res/mipmap-mdpi"
to="${escapeXmlAttribute(resOut)}/mipmap-mdpi" />
<copy from="root/res/mipmap-xhdpi"
to="${escapeXmlAttribute(resOut)}/mipmap-xhdpi" />
<copy from="root/res/mipmap-xxhdpi"
to="${escapeXmlAttribute(resOut)}/mipmap-xxhdpi" />
<copy from="root/res/mipmap-xxxhdpi"
to="${escapeXmlAttribute(resOut)}/mipmap-xxxhdpi" />
</#if>
<#if makeIgnore>
<copy from="root/module_ignore"
to="${escapeXmlAttribute(projectOut)}/.gitignore" />
</#if>
<#if enableProGuard>
<instantiate from="root/proguard-rules.txt.ftl"
to="${escapeXmlAttribute(projectOut)}/proguard-rules.pro" />
</#if>
<#if !(isLibraryProject??) || !isLibraryProject>
<instantiate from="root/res/values/styles.xml.ftl"
to="${escapeXmlAttribute(resOut)}/values/styles.xml" />
<#if buildApi gte 22>
<copy from="root/res/values/colors.xml"
to="${escapeXmlAttribute(resOut)}/values/colors.xml" />
</#if>
</#if>
<instantiate from="root/res/values/strings.xml.ftl"
to="${escapeXmlAttribute(resOut)}/values/strings.xml" />
<instantiate from="root/test/app_package/ExampleInstrumentedTest.java.ftl"
to="${escapeXmlAttribute(testOut)}/ExampleInstrumentedTest.java" />
<#if unitTestsSupported>
<instantiate from="root/test/app_package/ExampleUnitTest.java.ftl"
to="${escapeXmlAttribute(unitTestOut)}/ExampleUnitTest.java" />
</#if>
<#if includeCppSupport!false>
<instantiate from="root/CMakeLists.txt.ftl"
to="${escapeXmlAttribute(projectOut)}/CMakeLists.txt" />
<mkdir at="${nativeSrcOut}" />
<instantiate from="root/native-lib.cpp.ftl" to="${nativeSrcOut}/native-lib.cpp" />
</#if>
</recipe>