Paste} for a complete ClassBody error even with matched braces

Yes. I know this is trivial. But it becomes stupid.

Image confirming the error:

enter image description here

The code:

package apack.age; import android.app.Activity; import android.content.Intent; import android.net.Uri; import android.os.Bundle; import android.view.View; public class DisplayContactActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.display_contact_layout); } public void openSubreddit(View view) { startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.reddit.com"))); } public void openTwitter(View view) { startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://twitter.com"))); } public void openGmail(View view) { startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("www.gmail.com"))); } } 

Seriously. There are 5 open and 5 closed braces. This is my first attempt at an Android application, but I have 3 years of Java experience, so this is pretty annoying.

Run errors. The update does nothing. A clean project does nothing. The automatic code format in eclipse (CTRL + SHIFT + F) does nothing.

EDIT 1: Copying code into a new class allows you to compile it. I am launching a new version of Eclipse: Juno. I did source -> cleanup, and it just says "don't change anything" every time!

+6
source share
5 answers

Edit: upgrade to ADT 20.0.1 where it is fixed.


Switch to the Lint view, use the "Clear" button to remove all lint errors. There is a bug with lint in ADT 20 that sometimes incurs Java compiler errors.

You can check if this is really a problem by looking at the "Origin" column of this error in the "Problems" view. Usually it should be a “Java problem” for this error, but instead it will be “Lint”.

+5
source

Try to save the file with Ctrl+S , sometimes this happens to me. Also, it seems that you forgot to insert the package name at the beginning of the code:

 package com.example.my_application; 
+1
source

There should be a snapin in your eclipse with the problem. Have you tried installing virgin eclipse?

+1
source

Here are some tips for Eclipse users who are experiencing this issue. Try the following: I decided to use this download for the IDE: eclipse-SDK-4.2-macosx- cocoa -x86_64.tar):

1) mv offensive source .java file to a new file. 2) Update eclipse (project by right-clicking the project name). 3) mv the new file is returned to the original name. 4) Refresh the eclipse again.

This solved the problem for me. It was nothing about the code, it happened to me periodically during the coding session, even in a very small file, in which it was not easy to replace any closing curly braces :-)

0
source

I tried some of the solutions suggested here, no luck, and then tried the following, it seems good.

I moved the Java file from the source tree. Of course, compilation errors are highlighted throughout the tree.

I created a new Java file for the class. I right-clicked the error to create the file. I set the parent class in the dialog box.

I fixed the errors in the file - the constructor required due to the parent class - with a temporary code.

When the old code is opened in a text editor (Notepad ++), I chunk the old code, fixing the import, as required, by right-clicking on the errors.

Now it compiles.

Grumble Blocking tools. Grumble.

0
source

Source: https://habr.com/ru/post/919920/


All Articles