0

So, I made a new Android project with the default sign in activity. Since then, I have made some changes to GUI through the XML. But then, when I tried to add a new Java class. I have encountered this error I haven't added any new Java code to the template before doing so before, since starting this project. I looked around this site for a solution.

This one talked about a bug. But doesn't seem like a bug to me. This question was closed because it was off-topic.

This one is similar to my problem because I don't think coding is the problem, but it the question was closed due to ambiguity.

So it is the same problem, but a different cause.

UPDATE 8/15/17

I did what star4z recommended. I made a new Android project with the default sign in activity template. That's all I did. I didn't do any XML changes at all this time. Then, as soon as I added a new Java class, I encountered the same error.

3 Answers3

2

I am using Android Studio and I was facing exactly the same error after I upgraded to java 8. I resolved it by going through menu options in Android Studio.

help>Edit custom VM (If Android studion asks you the permission to creat this file, select YES).

It will open a file named studio64.exe.vmoptions then add below line in the file.

-Djdk.util.zip.ensureTrailingSlash=false

Finally go to file and select Invalidate cache/restart and you are good to go.

It seems to pe an error resolved by oracle to the Java 8 Update 144.

Maniya Joe
  • 761
  • 6
  • 24
1

Go to File->setting->editor->file and code templates, select Class in the files tab and write this:

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

}
#elseif (${Is_your_class_abstract_Reply_yes_no} == "yes")
#parse("File Header.java") public abstract class ${NAME} {

}
#end
Ben Hare
  • 4,365
  • 5
  • 27
  • 44
0

Your question is a little confusing: "But then, when I tried to add a new Java class" seems to be missing its second half.

I think your question is analogous to the first reference you posted based on the screenshot. You appear to be creating a class the proper way; it would be impossible to figure out the source of the problem without someone looking at everything in your project and editor, though I suspect some files got deleted that shouldn't have at some point.

I would suggest starting a new project and copying the changes you've made to files in this project over.

star4z
  • 377
  • 3
  • 10