无法解析模板“类”

2022-09-01 01:10:48

我正在尝试在Android中创建类,但我得到了这个错误

无法解析模板“类”错误消息:此模板未生成 Java 类或接口

在事件日志中,我得到了这个错误

FileNotFoundException: Entry fileTemplates//code/Google Test Fixture SetUp Method.cc.ft 在 /D:/Android%20Studio/lib/idea 中找不到.jar

这是我的应用程序 bulid gradle

apply plugin: 'com.android.application'

android
  {

compileSdkVersion 23
buildToolsVersion '25.0.0'

defaultConfig {
    applicationId "com.hh.ss.msed"
    minSdkVersion 14
    targetSdkVersion 26
    versionCode 1
    versionName "1.0"
    multiDexEnabled true


}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}


dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'

    compile 'com.android.support:appcompat-v7:23.0.0'
    compile 'com.google.firebase:firebase-core:11.0.1'
    compile 'com.google.firebase:firebase-database:11.0.1'
    compile 'com.google.firebase:firebase-crash:11.0.1'
    compile 'com.google.firebase:firebase-storage:11.0.1'
    compile 'com.android.support:recyclerview-v7:23.0.0'
    compile 'com.android.support:cardview-v7:23.0.0'
    compile 'com.firebaseui:firebase-ui-database:0.6.2'


    compile 'com.firebase:firebase-client-android:2.4.0'
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'com.android.support:support-v4:23.0.0'


}


packagingOptions {
    exclude 'META-INF/DEPENDENCIES.txt'
    exclude 'META-INF/LICENSE.txt'
    exclude 'META-INF/NOTICE.txt'
    exclude 'META-INF/NOTICE'
    exclude 'META-INF/LICENSE'
    exclude 'META-INF/DEPENDENCIES'
    exclude 'META-INF/notice.txt'
    exclude 'META-INF/license.txt'
    exclude 'META-INF/dependencies.txt'
    exclude 'META-INF/LGPL2.1'
   }
  }
  apply plugin: 'com.google.gms.google-services'

这个建筑项目

// Top-level build file where you can add configuration options common to all sub-projects/modules.

  buildscript {
  repositories {
    jcenter()
  }
  dependencies {
    classpath 'com.android.tools.build:gradle:2.3.3'
    classpath 'com.google.gms:google-services:3.1.0'

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
    }
 }

 allprojects {
  repositories {
    jcenter()
  }
}

task clean(type: Delete) {
  delete rootProject.buildDir
}

怎么了?


答案 1

转到“文件>设置>编辑器>文件和代码模板”,在“文件”选项卡中选择“类”并粘贴以下内容:

#if (${PACKAGE_NAME} && ${PACKAGE_NAME} != "")package ${PACKAGE_NAME};#end #parse("File Header.java") public class ${NAME} { }

Screenshot of editor


答案 2

我有同样的问题,并通过添加或以下行来解决它:idea.vmoptionsidea64.vmoptions

-Djdk.util.zip.ensureTrailingSlash=false

用户 Wojciech Fred 在 JetBrains 支持中所示

似乎是预言机应用于 Java 8 Update 144 的修复程序

我希望它能帮助:D

编辑:在Android Studio中,该文件称为studio.vmoptions,可以在配置目录中找到,但是如果您转到“帮助>编辑自定义VM选项”菜单,则更容易:Android Studio配置


推荐