0
votes

Im a fresher in android app dev... using Android Studio 1.3, JDK 8

Event log : 12:44:13 AM Gradle build finished in 13s 724ms 12:59:50 AM Executing tasks: [:app:assembleDebug] 12:59:55 AM Gradle build finished with 2 error(s) in 5s 804ms

Gradle build: Error:(41, 31) error: ';' expected Error:Execution failed for task ':app:compileDebugJava'.

Compilation failed; see the compiler error output for details. Information:BUILD FAILED

Information:Total time: 5.088 secs

Information:2 errors

Information:0 warnings

Information:See complete output in console

Java class code:

package in.co.doordie.shankar.doordie;

import android.app.Activity;
import android.content.Intent;
import android.media.MediaPlayer;
import android.os.Bundle;

public class Splash extends Activity {

MediaPlayer ourSong;
@Override
protected void onCreate(Bundle Doordiesplash) {
    super.onCreate(Doordiesplash);
    setContentView(R.layout.splash);

    ourSong = MediaPlayer.create(Splash.this, R.raw.kalyanamala);
    ourSong.start();

    Thread timer = new Thread() {
        public void run() {
            try {
                sleep(50000);

            } catch (InterruptedException e) {
                e.printStackTrace();

            } finally {
                Intent openStartingPoint = new Intent("in.co.doordie.shankar.doordie.MAINACTIVITY");
                startActivity(openStartingPoint);

            }
        }

    };
    timer.start();

    @Override
    protected void onPause(){
        super.onPause();
        ourSong.release();
        finish();
    }

}
}

Help me ... do you know what went wrong?

1
You might want to upgrade your Android Studio as you are two versions behind... Quite a lot has changed in these past versions.Peter Gordon

1 Answers

1
votes

You have placed

@Override
protected void onPause(){
    super.onPause();
    ourSong.release();
    finish();
}

inside onCreate(). Simply move it out.

Next time select whole code and use shortcut CTRL-ALT-L to quick reformat code, it will be easier to find for you.

package in.co.doordie.shankar.doordie;

import android.app.Activity;
import android.content.Intent;
import android.media.MediaPlayer;
import android.os.Bundle;

public class Splash extends Activity {

    MediaPlayer ourSong;

    @Override
    protected void onCreate(Bundle Doordiesplash) {
        super.onCreate(Doordiesplash);
        setContentView(R.layout.splash);

        ourSong = MediaPlayer.create(Splash.this, R.raw.kalyanamala);
        ourSong.start();

        Thread timer = new Thread() {
            public void run() {
                try {
                    sleep(50000);

                } catch (InterruptedException e) {
                    e.printStackTrace();

                } finally {
                    Intent openStartingPoint = new Intent("in.co.doordie.shankar.doordie.MAINACTIVITY");
                    startActivity(openStartingPoint);

                }
            }

        };
        timer.start();

    }

    @Override
    protected void onPause() {
        super.onPause();
        ourSong.release();
        finish();
    }
}