android - Unfortunately App has stopped working In Emulator -


i got error while running app in emulator:

unfortunately app has stopped

my app music player app simple functionality.

all other apps running in same emulator. app not working.

after looking @ log, see error:

09-10 16:01:28.460: e/androidruntime(1200): caused by: java.lang.instantiationexception: can't instantiate class com.example.musicplayer.mainactivity

code mainactivity.java:

package com.example.musicplayer;  import com.example.musicplayer.r;  //import com.example.musicplayer.secondscreen;  import android.app.activity; import android.content.context; import android.content.intent; import android.media.mediaplayer; import android.os.bundle; import android.os.handler; import android.view.view; import android.view.view.onclicklistener; import android.widget.button; import android.widget.imagebutton; import android.widget.seekbar; import android.widget.textview;  public abstract class mainactivity extends activity implements onclicklistener {     seekbar seek_bar;     button play_button, pause_button;     mediaplayer player;     textview text_shown;     handler seekhandler = new handler();     imagebutton button;      /** called when activity first created. */     @override     public void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);         setcontentview(r.layout.activity_main);          getinit();         seekupdation();         addlisteneronbutton();     }   //function button press change screen      public void addlisteneronbutton() {          final context context = this;          button = (imagebutton) findviewbyid(r.id.btnforward);          button.setonclicklistener(new onclicklistener() {              @override             public void onclick(view arg0) {                  intent intent = new intent(context, secondscreen.class);                             startactivity(intent);                 }          });      }      //function play/pause audio      public void getinit() {         seek_bar = (seekbar) findviewbyid(r.id.seek_bar);         play_button = (button) findviewbyid(r.id.btnplay);         pause_button = (button) findviewbyid(r.id.btnpause);         //text_shown = (textview) findviewbyid(r.id.text_shown);         play_button.setonclicklistener(this);         pause_button.setonclicklistener(this);         player = mediaplayer.create(this, r.raw.fat); //ye wo audio file hai jo chalarae         seek_bar.setmax(player.getduration());      }      runnable run = new runnable() {          @override         public void run() {             seekupdation();         }     };      // function update seekbar      public void seekupdation() {         seek_bar.setprogress(player.getcurrentposition());         seekhandler.postdelayed(run, 1000);     } 

code activity_main.xml:

<?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android"      android:layout_width="match_parent"     android:layout_height="match_parent" >       <!-- player header -->     <linearlayout         android:id="@+id/player_header_bg"         android:layout_width="fill_parent"         android:layout_height="60dip"          android:layout_alignparenttop="true"         android:paddingleft="5dp"         android:paddingright="5dp">          <!-- audio title -->         <textview              android:id="@+id/audiotitle"             android:layout_width="wrap_content"             android:layout_height="wrap_content"             android:layout_weight="1"             android:textcolor="#04b3d2"             android:textsize="16dp"             android:paddingleft="10dp"             android:textstyle="bold"             android:text="1"             android:layout_margintop="10dp"/>          <!-- playlist button -->         <imagebutton              android:id="@+id/btnplaylist"             android:layout_width="wrap_content"             android:layout_height="fill_parent"             android:src="@drawable/btn_playlist"             android:background="@null"/>     </linearlayout>      <!-- sabak  image -->      <linearlayout         android:id="@+id/audiothumbnail"         android:layout_width="fill_parent"         android:layout_height="wrap_content"          android:gravity="center"         android:paddingbottom="10dp"         android:paddingtop="10dp" >          <imageview             android:layout_width="292dp"             android:layout_height="283dp"             android:src="@drawable/fatiha" />      </linearlayout>      <!-- player footer -->     <linearlayout          android:id="@+id/player_footer_bg"         android:layout_width="fill_parent"         android:layout_height="100dp"         android:layout_alignparentbottom="true"          android:gravity="center">          <!-- player buttons -->         <linearlayout              android:layout_width="wrap_content"             android:layout_height="wrap_content"             android:orientation="horizontal"             android:gravity="center_vertical"              android:paddingleft="10dp"             android:paddingright="10dp">             <!-- previous button -->             <!-- backward button -->             <imagebutton                  android:id="@+id/btnbackward"                 android:src="@drawable/btn_backward"                 android:layout_width="wrap_content"                 android:layout_height="wrap_content"                 android:background="@null"/>              <!-- pause button -->               <imagebutton                 android:id="@+id/btnpause"                 android:layout_width="wrap_content"                 android:layout_height="wrap_content"                 android:background="@null"                 android:enabled="false"                 android:gravity="center"                 android:src="@drawable/btn_pause" />   <!-- play button -->             <imagebutton                 android:id="@+id/btnplay"                 android:layout_width="wrap_content"                 android:layout_height="wrap_content"                 android:background="@null"                 android:src="@drawable/btn_play"                 android:gravity="center" />    <!-- forward button -->              <imagebutton                 android:id="@+id/btnforward"                 android:layout_width="wrap_content"                 android:layout_height="wrap_content"                 android:background="@null"                 android:src="@drawable/btn_forward" />         </linearlayout>     </linearlayout>      <!-- sabak progress bar/seek bar -->     <seekbar                android:id="@+id/seek_bar"              android:layout_width="fill_parent"              android:layout_height="wrap_content"              android:layout_marginright="20dp"               android:layout_marginleft="20dp"              android:layout_marginbottom="20dp"              android:layout_above="@id/player_footer_bg"              android:thumb="@drawable/seek_handler"              android:progressdrawable="@drawable/seekbar_progress"              android:paddingleft="6dp"              android:paddingright="6dp"/>      <linearlayout         android:layout_width="fill_parent"         android:layout_height="wrap_content"         android:layout_above="@+id/audioprogressbar"         android:gravity="center" >   </linearlayout>  </relativelayout> 

code manifest.xml:

<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android"     package="com.example.musicplayer"     android:versioncode="1"     android:versionname="1.0" >      <uses-sdk         android:minsdkversion="8"         android:targetsdkversion="19" />      <application         android:allowbackup="true"         android:icon="@drawable/ic_launcher"         android:label="@string/app_name"         android:theme="@style/apptheme" >         <activity             android:name="com.example.musicplayer.mainactivity"             android:label="@string/app_name" >             <intent-filter>                 <action android:name="android.intent.action.main" />                  <category android:name="android.intent.category.launcher" />             </intent-filter>         </activity>     </application> 

logcat:

09-10 16:01:28.250: d/dalvikvm(1200): newinstance failed: p0 i0 [0 a1 09-10 16:01:28.250: d/androidruntime(1200): shutting down vm 09-10 16:01:28.260: w/dalvikvm(1200): threadid=1: thread exiting uncaught exception (group=0xb3b0bb90) 09-10 16:01:28.460: e/androidruntime(1200): fatal exception: main 09-10 16:01:28.460: e/androidruntime(1200): process: com.example.musicplayer, pid: 1200 09-10 16:01:28.460: e/androidruntime(1200): java.lang.runtimeexception: unable instantiate activity componentinfo{com.example.musicplayer/com.example.musicplayer.mainactivity}: java.lang.instantiationexception: can't instantiate class com.example.musicplayer.mainactivity 09-10 16:01:28.460: e/androidruntime(1200):     @ android.app.activitythread.performlaunchactivity(activitythread.java:2102) 09-10 16:01:28.460: e/androidruntime(1200):     @ android.app.activitythread.handlelaunchactivity(activitythread.java:2226) 09-10 16:01:28.460: e/androidruntime(1200):     @ android.app.activitythread.access$700(activitythread.java:135) 09-10 16:01:28.460: e/androidruntime(1200):     @ android.app.activitythread$h.handlemessage(activitythread.java:1397) 09-10 16:01:28.460: e/androidruntime(1200):     @ android.os.handler.dispatchmessage(handler.java:102) 09-10 16:01:28.460: e/androidruntime(1200):     @ android.os.looper.loop(looper.java:137) 09-10 16:01:28.460: e/androidruntime(1200):     @ android.app.activitythread.main(activitythread.java:4998) 09-10 16:01:28.460: e/androidruntime(1200):     @ java.lang.reflect.method.invokenative(native method) 09-10 16:01:28.460: e/androidruntime(1200):     @ java.lang.reflect.method.invoke(method.java:515) 09-10 16:01:28.460: e/androidruntime(1200):     @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:777) 09-10 16:01:28.460: e/androidruntime(1200):     @ com.android.internal.os.zygoteinit.main(zygoteinit.java:593) 09-10 16:01:28.460: e/androidruntime(1200):     @ dalvik.system.nativestart.main(native method) 09-10 16:01:28.460: e/androidruntime(1200): caused by: java.lang.instantiationexception: can't instantiate class com.example.musicplayer.mainactivity 09-10 16:01:28.460: e/androidruntime(1200):     @ java.lang.class.newinstanceimpl(native method) 09-10 16:01:28.460: e/androidruntime(1200):     @ java.lang.class.newinstance(class.java:1208) 09-10 16:01:28.460: e/androidruntime(1200):     @ android.app.instrumentation.newactivity(instrumentation.java:1061) 09-10 16:01:28.460: e/androidruntime(1200):     @ android.app.activitythread.performlaunchactivity(activitythread.java:2093) 09-10 16:01:28.460: e/androidruntime(1200):     ... 11 more 

java.lang.instantiationexception: can't instantiate class com.example.musicplayer.mainactivity 

your mainactivity abstract , abstract classes cannot instantiated. remove abstract keyword class declaration.


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

jsf - How to ajax update an item in the footer of a PrimeFaces dataTable? -

django - CSRF verification failed. Request aborted. CSRF cookie not set -