Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Insert } to Complete ClassBody error even with matched braces

Tags:

java

android

Yes. I know this is trivial. But this is getting silly.

Image proving 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's 5 open and 5 close braces. This is my first attempt at an android app but I have 3 years of Java experience so this is pretty frustrating.

Run errors out. Refresh does nothing. Project clean does nothing. Auto code format in eclipse (CTRL + SHIFT + F) does nothing.

EDIT 1: Copying the code to a new class gets it to compile. I'm running the new version of Eclipse: Juno. I've done source -> cleanup and it just says "nothing to change" every time!

like image 461
fIwJlxSzApHEZIl Avatar asked Jul 07 '12 05:07

fIwJlxSzApHEZIl


3 Answers

Edit: Please upgrade to ADT 20.0.1, where this has been fixed.


Switch to the Lint view, use the Clean button to remove all lint errors. There is a bug with lint in ADT 20, that it sometimes takes over the Java compiler bugs.

You can verify if this is really the problem by looking at the "Origin" column of this bug in your Problems view. Normally that should be "Java problem" for this error, but it will be "Lint" instead.

like image 95
Bananeweizen Avatar answered Nov 03 '22 00:11

Bananeweizen


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

package com.example.my_application;
like image 1
Eng.Fouad Avatar answered Nov 02 '22 23:11

Eng.Fouad


There's gotta be a snapin in your eclipse with the issue. Have you tried a virgin eclipse install?

like image 1
MJB Avatar answered Nov 02 '22 22:11

MJB