2

I'm trying to run an application from the book Pro Android Media to understand the functioning of streams. However, the following error is happening:

12-26 16:32:31.464: E/AndroidRuntime(508): FATAL EXCEPTION: main
12-26 16:32:31.464: E/AndroidRuntime(508): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.streaming/com.example.streaming.Streaming}: java.lang.ClassNotFoundException: com.example.streaming.Streaming in loader dalvik.system.PathClassLoader[/data/app/com.example.streaming-2.apk]
12-26 16:32:31.464: E/AndroidRuntime(508):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2585)
12-26 16:32:31.464: E/AndroidRuntime(508):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
12-26 16:32:31.464: E/AndroidRuntime(508):  at android.app.ActivityThread.access$2300(ActivityThread.java:125)
12-26 16:32:31.464: E/AndroidRuntime(508):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
12-26 16:32:31.464: E/AndroidRuntime(508):  at android.os.Handler.dispatchMessage(Handler.java:99)
12-26 16:32:31.464: E/AndroidRuntime(508):  at android.os.Looper.loop(Looper.java:123)
12-26 16:32:31.464: E/AndroidRuntime(508):  at android.app.ActivityThread.main(ActivityThread.java:4627)
12-26 16:32:31.464: E/AndroidRuntime(508):  at java.lang.reflect.Method.invokeNative(Native Method)
12-26 16:32:31.464: E/AndroidRuntime(508):  at java.lang.reflect.Method.invoke(Method.java:521)
12-26 16:32:31.464: E/AndroidRuntime(508):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
12-26 16:32:31.464: E/AndroidRuntime(508):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
12-26 16:32:31.464: E/AndroidRuntime(508):  at dalvik.system.NativeStart.main(Native Method)
12-26 16:32:31.464: E/AndroidRuntime(508): Caused by: java.lang.ClassNotFoundException: com.example.streaming.Streaming in loader dalvik.system.PathClassLoader[/data/app/com.example.streaming-2.apk]
12-26 16:32:31.464: E/AndroidRuntime(508):  at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
12-26 16:32:31.464: E/AndroidRuntime(508):  at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
12-26 16:32:31.464: E/AndroidRuntime(508):  at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
12-26 16:32:31.464: E/AndroidRuntime(508):  at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
12-26 16:32:31.464: E/AndroidRuntime(508):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2577)
12-26 16:32:31.464: E/AndroidRuntime(508):  ... 11 more
12-26 16:51:14.974: D/AndroidRuntime(1433): Shutting down VM
12-26 16:51:15.054: W/dalvikvm(1433): threadid=1: thread exiting with uncaught exception (group=0x4001d800)

The codes:

ViewTheVideo

package com.example.streaming;

import com.example.streaming.R;
import android.app.Activity;
import android.net.Uri;
import android.os.Bundle;
import android.widget.MediaController;
import android.widget.VideoView;

public class ViewTheVideo extends Activity {
    VideoView vv;
    @Override
    public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);
        vv = (VideoView) this.findViewById(R.id.VideoView);
Uri videoUri = Uri.parse("rtsp://v2.cache2.c.youtube.com/CjgLENy73wIaLwm3JbT_� 9HqWohMYESARFEIJbXYtZ29vZ2xlSARSB3Jlc3VsdHNg _vSmsbeSyd5JDA==/0/0/0/video.3gp");
        vv.setMediaController(new MediaController(this));
        vv.setVideoURI(videoUri);
        vv.start();
} 

}

Main.xml

            <?xml version="1.0" encoding="utf-8"?>
            <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
                android:orientation="vertical"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                >
            <VideoView android:layout_width="wrap_content"
                       android:layout_height="wrap_content"
                       android:id="@+id/VideoView">    
            </VideoView>
            </LinearLayout>

AndroidManifest.xml

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.streaming"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="8" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >

        <activity android:name = ".Streaming"
              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>
</manifest>

I will waiting to the answer to my question.

Thanks guys!

1 Answer 1

3

Change

public class ViewTheVideo extends Activity {
//....your code here

to

public class Streaming extends Activity {
//....your code here

because you are declaring Activity in AndroidManifest as .Streaming but in java Class name is ViewTheVideo

OR

you can also just change name in AndroidManifest as :

 <activity android:name = ".ViewTheVideo"
              android:label = "@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name = "android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>
3
  • Thanks man!!!!!! I have other question. I tried to play the video mp4 but it don`t played on the emulator. I need to decrease the size of the video so that it plays on android? Dec 26, 2012 at 20:36
  • @user1930634 : mp4 easy play in androidmaybe emulator creating problem. if you have any device then just check it on real device Dec 26, 2012 at 20:38
  • @prosper K i can give more one help ? :) Dec 26, 2012 at 21:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.