无法找到显式的android.widget.VideoView

时间:2014-10-28 08:11:43

标签: android android-videoview assets

我有这样的错误,为什么?

Unable to find explicit activity class {com.erjp.widget.VideoView} have you declared this activitiy in your androidManifest.xml?

我已在"VideoActivity"中声明了我的班级名称androidManifest.xml,但为什么会出现这样的错误? 有人可以帮忙吗?

<activity
    android:name="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>
<activity
    android:name="VideoActivity"
    android:label="@string/app_name"
    android:screenOrientation="landscape">
</activity>

这是我的班级代码: 包com.erjp;

import android.app.Activity;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import android.widget.MediaController;
import android.widget.VideoView;

public class VideoActivity extends Activity{
    private final String TAG = VideoActivity.class.getCanonicalName();
    private VideoView videoPlayer;
    private MediaController mediaControler;
    private String pathvideo;

    public void onCreate(Bundle savedInstanceState){
        Log.v(TAG, "onCreate");
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_video);

        videoPlayer = (VideoView) findViewById(R.id.videoPlayer);
        mediaControler = new MediaController(VideoActivity.this);

        pathvideo = MainActivity.DATA_PATH.toString() +"/video/videocpr";
        videoPlayer.setMediaController(mediaControler);
        videoPlayer.setVideoURI(Uri.parse(pathvideo));
        videoPlayer.requestFocus();
        videoPlayer.start();
    }
}

这是LogCat:

10-28 07:48:14.620: E/AndroidRuntime(1999): FATAL EXCEPTION: main
10-28 07:48:14.620: E/AndroidRuntime(1999): android.content.ActivityNotFoundException: Unable to find explicit activity class {com.erjp/android.widget.VideoView}; have you declared this activity in your AndroidManifest.xml?
10-28 07:48:14.620: E/AndroidRuntime(1999):     at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1618)
10-28 07:48:14.620: E/AndroidRuntime(1999):     at android.app.Instrumentation.execStartActivity(Instrumentation.java:1417)
10-28 07:48:14.620: E/AndroidRuntime(1999):     at android.app.Activity.startActivityForResult(Activity.java:3370)
10-28 07:48:14.620: E/AndroidRuntime(1999):     at android.app.Activity.startActivityForResult(Activity.java:3331)
10-28 07:48:14.620: E/AndroidRuntime(1999):     at android.app.Activity.startActivity(Activity.java:3566)
10-28 07:48:14.620: E/AndroidRuntime(1999):     at android.app.Activity.startActivity(Activity.java:3534)
10-28 07:48:14.620: E/AndroidRuntime(1999):     at com.erjp.MainActivity$ClickVideo.onClick(MainActivity.java:77)
10-28 07:48:14.620: E/AndroidRuntime(1999):     at android.view.View.performClick(View.java:4204)
10-28 07:48:14.620: E/AndroidRuntime(1999):     at android.view.View$PerformClick.run(View.java:17355)
10-28 07:48:14.620: E/AndroidRuntime(1999):     at android.os.Handler.handleCallback(Handler.java:725)
10-28 07:48:14.620: E/AndroidRuntime(1999):     at android.os.Handler.dispatchMessage(Handler.java:92)
10-28 07:48:14.620: E/AndroidRuntime(1999):     at android.os.Looper.loop(Looper.java:137)
10-28 07:48:14.620: E/AndroidRuntime(1999):     at android.app.ActivityThread.main(ActivityThread.java:5041)
10-28 07:48:14.620: E/AndroidRuntime(1999):     at java.lang.reflect.Method.invokeNative(Native Method)
10-28 07:48:14.620: E/AndroidRuntime(1999):     at java.lang.reflect.Method.invoke(Method.java:511)
10-28 07:48:14.620: E/AndroidRuntime(1999):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
10-28 07:48:14.620: E/AndroidRuntime(1999):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
10-28 07:48:14.620: E/AndroidRuntime(1999):     at dalvik.system.NativeStart.main(Native Method)

1 个答案:

答案 0 :(得分:0)

您的应用由于缺少com.erjp.widged.VideoView而崩溃,VideoActivity布局中很可能会引用该应用。{1}}因为正确的拼写是widget而不是widged,所以它不是一种类型,所以很可能你的包是正确的,但参考不是。