android - 致命异常: main - Streaming Android

标签 android streaming

我正在尝试运行 Pro Android Media 书中的应用程序来了解流的功能。但是,出现以下错误:

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)

代码:

观看视频

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>

我会等待我的问题的答案。

谢谢大家!

最佳答案

改变

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

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

因为您将 AndroidManifest 中的 Activity 声明为 .Streaming 但在 java 中类名称为 ViewTheVideo

您也可以在 AndroidManifest 中将名称更改为:

 <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>

关于android - 致命异常: main - Streaming Android,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14045845/

相关文章:

android - PagerAdapter 的页面更改回调

iphone - iPhone 上的流式 SAX XML 处理

streaming - 如何使用 Gstreamer 通过 RTMP 进行流式传输?

flash - 当前流式传输视频的最佳方式是什么?

android - 通过代码设置所选项目时如何禁用要调用的onItemSelectedListener

android - 我可以更改 Android 自定义键盘的输出字体吗?

android - 使用超声波确定 2 个移动设备的相对位置

java - 将奖励按钮按下限制为每小时一次

video-streaming - 如何为类似 Twitch 的应用程序构建 WebRTC 媒体服务器

html - 使用 nodejs 将视频流式传输到浏览器