Error reached end of file while parsing android studio

package com.example.vicky.videostory; import android.net.Uri; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.Button; imp...
package com.example.vicky.videostory;

import android.net.Uri;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.MediaController;
import android.widget.VideoView;

public class MainActivity extends AppCompatActivity {

    Button btnPlay;
    VideoView myvideo;
    MediaController mediaController;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        btnPlay=(Button) findViewById(R.id.btn_Play);
        myvideo=(videoView) findviewById(R.id.videoPlayer);

        mediaController = new MediaController( this) ;


        btnPlay.setOnClickListner(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

                String videoPath = "android.resource//com.example.vicky.videostory/"+R.raw.technology;
                Uri uri=Uri.parse(videoPath);
                myvideo.setVideoURI(uri);
                myvideo.setMediaController(mediaController);
                mediaController.setAnchorView(myvideo);
                myvideo.start();


            }

        }
    );

}

error: reached end of file while parsing
I think its just errors in brackets. Because when I click on an error it points towards brackets and says unexpected error.

this is the error please check whats wrong

  • android-studio

asked Oct 27, 2018 at 8:50

Vicky's user avatar

VickyVicky

13 bronze badges

3

  • If you really want help i sugest you to write your code and not post it as image, it’s easier for getting help.

    Oct 27, 2018 at 8:52

  • Your syntax is not completely okay. Please read documentations or follow tutorials. It seems you don’t even understand basics

    Oct 27, 2018 at 8:53

  • check now guys I edit the post if are using android studio u will identified the problem

    Oct 27, 2018 at 12:44

1 Answer

You have problem in your syntax correct it first and then Rebuild Project also remember that follow the basics properly before doing code.

answered Oct 27, 2018 at 8:57

Syed Muhammad Zeejah Hashmi ze's user avatar

0

  1. reached end of the file while parsing — Missing Class Curly Brace in Java
  2. reached end of the file while parsing — Missing if Curly Block Brace in Java
  3. reached end of the file while parsing — Missing Loop Curly Brace in Java
  4. reached end of the file while parsing — Missing Method Curly Brace in Java
  5. Avoiding the reached end of file while parsing Error in Java

Fix the Reach End of File While Parsing Error in Java

This tutorial introduces an error reach end of the file while parsing during code compilation in Java.

The reached end of the file while parsing error is a compile-time error. When a curly brace is missing for a code block or an extra curly brace is in the code.

This tutorial will look at different examples of how this error occurs and how to resolve it. The reached end of file while parsing error is the compiler’s way of telling it has reached the end of the file but not finding its end.

In Java, every opening curly place ({) needs a closing brace (}). If we don’t put a curly brace where it is required, our code will not work properly, and we will get an error.

reached end of the file while parsing — Missing Class Curly Brace in Java

We missed adding closing curly braces for the class in the example below.

When we compile this code, it returns an error to the console. The reached end of file while parsing error occurs if the number of curly braces is less than the required amount.

Look at the code below:

public class MyClass {
    public static void main(String args[]) {
  
      print_something();
    } 

Output:

MyClass.java:6: error: reached end of file while parsing
    }
     ^
1 error

The closing brace of the MyClass is missing in the above code. We can solve this issue by adding one more curly brace at the end of the code.

Look at the modified code below:

public class MyClass {
   static void print_something(){
     System.out.println("hello world");
   }
    public static void main(String args[]) {
  
      print_something();
    }  
  } 

Output:

Let us look at the examples where this error can occur.

reached end of the file while parsing — Missing if Curly Block Brace in Java

The if block is missing the closing curly brace in the code below. This leads to the reached end of the file while parsing error during code compilation in Java.

public class MyClass {
    public static void main(String args[]) {
      int x = 38;
      if( x > 90){
        // do something
          System.out.println("Greater than 90");
    }  
}

Output:

MyClass.java:8: error: reached end of file while parsing
}
 ^
1 error

We can resolve this error by adding the curly brace at the appropriate place (at the end of the if block). Look at the code below:

public class MyClass {
    public static void main(String args[]) {
      int x = 38;
      if( x > 90){
        // do something
          System.out.println("Greater than 90");
      } // this brace was missing
    }  
}

The above code compiles without giving any error.

Output:

reached end of the file while parsing — Missing Loop Curly Brace in Java

The missing curly braces can be from a while or a for loop. In the code below, the while loop block is missing the required closing curly brace, leading to a compilation failure.

See the example below.

public class MyClass {
    public static void main(String args[]) {
      int x = 38;
      while( x > 90){
        // do something
        System.out.println("Greater than 90");
        x--;
      
    }  
}

Output:

MyClass.java:10: error: reached end of file while parsing
}
 ^
1 error

We can resolve this error by putting the curly brace at the required position (at the end of the while loop). Look at the modified code below:

public class MyClass {
    public static void main(String args[]) {
      int x = 38;
      while( x > 90){
        // do something
        System.out.println("Greater than 90");
        x--;
      } // This brace was missing
    }  
}

The above code compiles without giving any error.

Output:

reached end of the file while parsing — Missing Method Curly Brace in Java

In this case, we have defined a method whose closing brace is missing, and if we compile this code, we get a compiler error. Look at the code below.

public class MyClass {
    
    public static void main(String args[]) {
      customFunction();
    }  
    static void customFunction(){
      System.out.println("Inside the function");
    
}

Output:

MyClass.java:9: error: reached end of file while parsing
}
 ^
1 error

We can resolve this error by putting the curly brace at the required position (at the end of the function body). Look at the modified code below:

public class MyClass {
    
    public static void main(String args[]) {
      customFunction();
    }  
    static void customFunction(){
      System.out.println("Inside the function");
    }
}

Output:

Avoiding the reached end of file while parsing Error in Java

This error is very common and very easy to avoid.

To avoid this error, we should properly indent our code. This will enable us to locate the missing closing curly brace easily.

We can also use code editors to automatically format our code and match each opening brace with its closing brace. This will help us in finding where the closing brace is missing.

The error Reached the end of the File Could appear for people working on their Android Smartphone Redmi 1S or while trying parsing on Java. In this article, we’ll go through different methods that could help you eliminate this error message on both Java and Redmi 1S smartphone.

This shows an error code message like,

Reached The End of The File

What has Reached the end of the File Error Issue?

This error message occurs on the Redmi 1S or sometimes on the Xiaomi Redmi 4A smartphone when a user tries to Downgrade from MIUI 6 to MIUI 5. The error also sometimes appears with a code message (0x80070026: Receiving Hello packet). The phone affected with this error message gets bricked and doesn’t respond to any commands.

What has Reached The End of The File Error Message in Java?

In Java, when a user tries parsing, and he misses out on a Closing Bracket in command, He gets the error message. The error could appear while creating a method or class. Here’s an example, you can see that method Main doesn’t conclude with a proper closing curl. Hence, the compiler doesn’t parse the information and throws the error.

public class Main {
public static void main(String[] args) {
System.out.Println(“Oops missed a curly bracket..”);
}

What has Reached The End of The File Error Message in Windows?

In windows computer, when a user tries to execute a specific chain of operation in Virtual application and the context of App-V. this error also appears with an Error message 29-00000026.

How to Fix & Solve Reached The End of The File Error Problem

In this article, we’ll discuss different methods that work to solve the Error Message. We’ll discuss three techniques that work for Redmi 1S smartphone, Virtual Application Server, and Windows computer.

1. Fix Reached the End of the File: Redmi 1S –

For Redmi 1S, you need to follow these steps to fix the Reached The End of The File while parsing error message.

redmi 1s

  • Download the Fastboot Version of ROM
  • Unzip ROM and Place in Directory such as the absolute address of following does not have any spaces
  • Install the MI flash App and Run it as Administrator
  • Open Device Manager
  • Select Qualcomm hs-USB diagnostic COM port from the device list
  • Right-click the selected item and update to the latest driver
  • Restart your computer and Press F8
  • Select Disable Driver Signature
  • Connect USB to your phone and Computer
  • Open MI Flash and see if the device is still in the list
  • Press Browse and select which drive ROM is located in
  • Press Magic Button – Flash on MI interface
  • You will see Success.JPG after sometime

2. Fix Reached the End of the File: Java –

In Java, the error is widespread. The error persists as someone misses a closing curling bracket in his code. The Reached The End of The File, while parsing error, is easily detectable as well as avoidable. You can use a code editor such as Visual Studio Code Editor. Also, an integrated development environment like Eclipse could be used. Code editors that sports Linters and Syntax Checkers for Java will unravel errors even before you attempt to compile.

java error

3. Fix Reached the End of the File: Windows –

In windows, while working on a virtual server or App-V. You may get this Reached The End of The File while parsing error while processing any commands. To avoid this mishap from occurring, use the command line that removes all the cache and Apps from the PC. (Not that you need to run these commands as Admin)

sftmime.exe remove obj:app /global /complete

Restart your computer once you’re done with this step. Hopefully, this error should be solved by then.

Conclusion:

In this article, we’ve discussed various methods that are used to fix Reached The End of The File while parsing error messages. We’ve talked about three ways that are helpful to fix the error message for Redmi 1S smartphone, Java Compilation as well as Windows Computer. The First method includes some real-time execution in the Redmi 1s Smartphone, and The second method describes fix for Java, whereas, in the third method, we fixed the error message for windows working on virtual servers. If you have any suggestions or you have faced any issues while performing the following ways, please comment below.

Let me know if you have any further issues while trying this Reached The End of The File while parsing guide with Redmi 1S smartphone, Java parsing, or Windows operating system. I will find an efficient solution and help you out with the same. Have a nice day!

Понравилась статья? Поделить с друзьями:
  • Error rate statistics
  • Error rate performance
  • Error rate none
  • Error rate limit exceeded awakened poe trade
  • Error rate formula