android studio 3.0 无法创建活动

android studio 3.0 unable to create activities

从 Android Studio 2.3.3 升级到 Android Studio 3.0,我在其中编辑了此文件 simple.xml.ftl 以使用 RelativeLayout 而不是 ConstraintLayout 在更新 I 之前一切正常将 post 以下两种 ftl 文件格式。我的问题是为什么会这样?我查看了错误日志并且几乎没有学习 ftl 语法的愿望 有人会复制此文件中包含 Android Studio 2.3.3 或 3.0 和 post 的代码作为答案吗?这个文件的路径是AndroidStudio/plugins/android/lib/templates/activities/common/root/res/layout /simple.xml.ftl” 使用记事本或 Sublime Text 打开文件并复制内容。

这是我的原始文件的样子

   <?xml version="1.0" encoding="utf-8"?>
   <android.support.constraint.ConstraintLayout
   xmlns:android="http://schemas.android.com/apk/res/android"
   xmlns:tools="http://schemas.android.com/tools"
   xmlns:app="http://schemas.android.com/apk/res-auto"
   android:layout_width="match_parent"
   android:layout_height="match_parent"
   <#if hasAppBar && appBarLayoutName??>
   tools:showIn="@layout/${appBarLayoutName}"
   </#if>
   tools:context="${relativePackage}.${fragmentClass}">

   <#if isNewProject!false>
   <TextView
   <#if includeCppSupport!false>
    android:id="@+id/sample_text"
   </#if>
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Hello World!"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toRightOf="parent"
    app:layout_constraintTop_toTopOf="parent" />
    </#if>

   </android.support.constraint.ConstraintLayout>

  This is my change that worked until Android Studio 3.0

  <?xml version="1.0" encoding="utf-8"?>
  <RelativeLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:tools="http://schemas.android.com/tools"
  xmlns:app="http://schemas.android.com/apk/res-auto"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  <#if hasAppBar && appBarLayoutName??>
  app:layout_behavior="@string/appbar_scrolling_view_behavior"
  tools:showIn="@layout/${appBarLayoutName}"
  </#if>


  tools:context="${relativePackage}.${activityClpackageNamsNewProject!false>
    <TextView
    <#if includeCppSupport!false>
    android:id="@+id/sample_text"
    </#if>
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Hello World!"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toRightOf="parent"
    app:layout_constraintTop_toTopOf="parent" />

    </#if>
    </RelativeLayout>

这是你的相对布局 simple.xml.ftl 文件中的错误我将 post 我的文件更改为相对布局它工作得很好首先我将 post 你的代码我的代码一个很大的建议是从 Sublime Text 中保存为并替换文件不要打开文件并尝试仅根据过去使用其他 NetBeans 文件的经验以这种方式保存代码

您的代码

  tools:context="${relativePackage}.${activityClpackageNamsNewProject!false>

我的代码

tools:context="${packageName}.${activityClass}">

这是完整的代码让我们知道它是否有效

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
<#if hasAppBar && appBarLayoutName??>
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:showIn="@layout/${appBarLayoutName}"
</#if>
tools:context="${packageName}.${activityClass}">

<#if isNewProject!false>
<TextView
<#if includeCppSupport!false>
    android:id="@+id/sample_text"
</#if>
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Hello World!"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toRightOf="parent"
    app:layout_constraintTop_toTopOf="parent" />

</#if>
</RelativeLayout>