Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/202.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 未找到android类异常_Java_Android_Eclipse - Fatal编程技术网

Java 未找到android类异常

Java 未找到android类异常,java,android,eclipse,Java,Android,Eclipse,错误:= java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.youtubeplayer/com.example.youtubeplayer.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "com.example.youtubeplayer.MainActivity" on path: /da

错误:=

java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.youtubeplayer/com.example.youtubeplayer.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "com.example.youtubeplayer.MainActivity" on path: /data/app/com.example.youtubeplayer-1.apk
我已经找到了这种错误,它说我应该去
project>properties>order
导出并检查那里的Android私有库选项。但当我看的时候,那东西已经检查过了。我试着再次清理和重建,但没有成功。事件清单文件正常。 我在libs文件夹中添加了
YoutubeAndroidPlayerApi.jar
。我只是复制并粘贴了它。还有一件事,我正在使用Eclipse

MainActivity.java

package com.example.youtubeplayer;

import android.content.Intent;
import android.os.Bundle;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Toast;

import com.google.android.youtube.player.YouTubeBaseActivity;  
import com.google.android.youtube.player.YouTubeInitializationResult;
import com.google.android.youtube.player.YouTubePlayer;
import com.google.android.youtube.player.YouTubePlayer.PlayerStyle; 
import com.google.android.youtube.player.YouTubePlayerView;

public class MainActivity extends YouTubeBaseActivity implements
    YouTubePlayer.OnInitializedListener {

private static final int RECOVERY_DIALOG_REQUEST = 1;

// YouTube player view
private YouTubePlayerView youTubeView;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);

    setContentView(R.layout.activity_main);

    youTubeView = (YouTubePlayerView) findViewById(R.id.youtube_view);

    // Initializing video player with developer key
    youTubeView.initialize(Config.DEVELOPER_KEY, this);

}

@Override
public void onInitializationFailure(YouTubePlayer.Provider provider,
        YouTubeInitializationResult errorReason) {
    if (errorReason.isUserRecoverableError()) {
        errorReason.getErrorDialog(this, RECOVERY_DIALOG_REQUEST).show();
    } else {
        String errorMessage = String.format(
                getString(R.string.error_player), errorReason.toString());
        Toast.makeText(this, errorMessage, Toast.LENGTH_LONG).show();
    }
}

@Override
public void onInitializationSuccess(YouTubePlayer.Provider provider,
        YouTubePlayer player, boolean wasRestored) {
    if (!wasRestored) {

        // loadVideo() will auto play video
        // Use cueVideo() method, if you don't want to play it automatically
        player.loadVideo(Config.YOUTUBE_VIDEO_CODE);

        // Hiding player controls
        player.setPlayerStyle(PlayerStyle.CHROMELESS);
    }
}

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == RECOVERY_DIALOG_REQUEST) {
        // Retry initialization if user performed a recovery action
        getYouTubePlayerProvider().initialize(Config.DEVELOPER_KEY, this);
    }
}

private YouTubePlayer.Provider getYouTubePlayerProvider() {
    return (YouTubePlayerView) findViewById(R.id.youtube_view);
}

}
Manifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
 package="com.example.youtubeplayer"
 android:versionCode="1"
 android:versionName="1.0" >

 <uses-permission android:name="android.permission.INTERNET"/>

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

 <application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <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>
</application>

</manifest>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <ImageView
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_centerInParent="true"
        android:scaleType="centerCrop"
        android:src="@drawable/snake_bg" />

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:layout_marginLeft="30dp"
        android:layout_marginRight="30dp"
        android:orientation="vertical" >

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:background="@drawable/rouned_corner_shadow"
            android:gravity="center_horizontal"
            android:orientation="vertical" >

            <com.google.android.youtube.player.YouTubePlayerView
                android:id="@+id/youtube_view"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginBottom="30dp" />

            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="70dp"
                android:layout_marginBottom="20dp"
                android:scaleType="fitCenter"
                android:src="@drawable/nat_geo_logo" />

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginBottom="10dp"
                android:text="@string/title_logo"
                android:textColor="@color/title"
                android:textSize="20dp"
                android:textStyle="bold" />

            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="40dp"
                android:layout_marginBottom="30dp"
                android:scaleType="fitCenter"
                android:src="@drawable/wild" />
        </LinearLayout>

        <Button
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="40dp"
            android:background="@drawable/rouned_corner_shadow"
            android:text="@string/btn_skip_intro" />
    </LinearLayout>

</RelativeLayout>

android_main.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
 package="com.example.youtubeplayer"
 android:versionCode="1"
 android:versionName="1.0" >

 <uses-permission android:name="android.permission.INTERNET"/>

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

 <application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <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>
</application>

</manifest>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <ImageView
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_centerInParent="true"
        android:scaleType="centerCrop"
        android:src="@drawable/snake_bg" />

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:layout_marginLeft="30dp"
        android:layout_marginRight="30dp"
        android:orientation="vertical" >

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:background="@drawable/rouned_corner_shadow"
            android:gravity="center_horizontal"
            android:orientation="vertical" >

            <com.google.android.youtube.player.YouTubePlayerView
                android:id="@+id/youtube_view"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginBottom="30dp" />

            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="70dp"
                android:layout_marginBottom="20dp"
                android:scaleType="fitCenter"
                android:src="@drawable/nat_geo_logo" />

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginBottom="10dp"
                android:text="@string/title_logo"
                android:textColor="@color/title"
                android:textSize="20dp"
                android:textStyle="bold" />

            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="40dp"
                android:layout_marginBottom="30dp"
                android:scaleType="fitCenter"
                android:src="@drawable/wild" />
        </LinearLayout>

        <Button
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="40dp"
            android:background="@drawable/rouned_corner_shadow"
            android:text="@string/btn_skip_intro" />
    </LinearLayout>

</RelativeLayout>


use
android:name=“com.example.youtubeplayer.MainActivity”
Q:您是否为youtubeplayer Librarray添加了构建路径。?如果是,则粘贴xml文件。@IntelliJAmiya。之前是com.example.youtubeplayer.main活动。我只是把它改了一下,看看能不能用。但这并没有什么不同。清理、重建并重新启动project@IntelliJAmiya我已经这么做过很多次了。使用
android:name=“com.example.youtubeplayer.MainActivity”
Q:您是否为youtubeplayer Librarray添加了构建路径。?如果是,则粘贴xml文件。@IntelliJAmiya。之前是com.example.youtubeplayer.main活动。我只是把它改了一下,看看能不能用。但这并没有什么不同。清理、重建并重新启动project@IntelliJAmiya我已经做过很多次了。