gpt4 book ai didi

android - 没有找到类 "com.google.android.youtube.api.jar.client.RemoteEmbeddedPlayer"

转载 作者:行者123 更新时间:2023-11-30 01:41:29 27 4
gpt4 key购买 nike

enter image description here我正在尝试在我的应用程序中播放 Youtube 视频,但失败并在屏幕上显示错误“初始化 YouTube 播放器时发生错误”

我已经使用 SHA-1 key 生成 API key ,我认为它已成功生成,但不确定是否因此出现错误,请帮助我解决。

Activity 代码-:

public class MainActivity extends YouTubeBaseActivity implements YouTubePlayer.OnInitializedListener {

public static final String API_KEY = "my API KEY";

public static final String VIDEO_ID = "1M2gC86Q_9o";

// public static final String VIDEO_ID = "https://www.youtube.com/watch?v=1M2gC86Q_9o";

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);

FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
.setAction("Action", null).show();
}
});

/** Initializing YouTube player view **/
YouTubePlayerView youTubePlayerView = (YouTubePlayerView) findViewById(R.id.youtube_player);
youTubePlayerView.initialize(API_KEY, this);
}

@Override
public void onInitializationFailure(Provider provider, YouTubeInitializationResult result) {
Toast.makeText(this, "Failured to Initialize!", Toast.LENGTH_LONG).show();
}

@Override
public void onInitializationSuccess(Provider provider, YouTubePlayer player, boolean wasRestored) {
/** add listeners to YouTubePlayer instance **/
player.setPlayerStateChangeListener(playerStateChangeListener);
player.setPlaybackEventListener(playbackEventListener);

/** Start buffering **/
if (!wasRestored) {
player.cueVideo(VIDEO_ID);
}
}

private PlaybackEventListener playbackEventListener = new PlaybackEventListener() {

@Override
public void onBuffering(boolean arg0) {
}

@Override
public void onPaused() {
}

@Override
public void onPlaying() {
}

@Override
public void onSeekTo(int arg0) {
}

@Override
public void onStopped() {
}

};

private PlayerStateChangeListener playerStateChangeListener = new PlayerStateChangeListener() {

@Override
public void onAdStarted() {
}

@Override
public void onError(ErrorReason arg0) {
}

@Override
public void onLoaded(String arg0) {
}

@Override
public void onLoading() {
}

@Override
public void onVideoEnded() {
}

@Override
public void onVideoStarted() {
}
};

@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();

//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}

return super.onOptionsItemSelected(item);
}

public void setSupportActionBar(Toolbar supportActionBar) {
//this.supportActionBar = supportActionBar;
}
}

错误标题是-:

com.google.android.youtube.player.internal.w$a: Unable to find dynamic class com.google.android.youtube.api.jar.client.RemoteEmbeddedPlayer
at com.google.android.youtube.player.internal.w.a(Unknown Source)....



Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.youtube.api.jar.client.RemoteEmbeddedPlayer" on path: DexPathList[[zip file "/system/app/YouTube_l1_64/YouTube_l1_64.apk"],nativeLibraryDirectories=[/system/app/YouTube_l1_64/lib/arm, /vendor/lib64, /system/lib64]]



Suppressed: java.io.IOException: Zip archive '/system/app/YouTube_l1_64/YouTube_l1_64.apk' doesn't contain classes.dex (error msg: Entry not found)

Buil.Gradle(模块:应用程序)

apply plugin: 'com.android.application'

android {
compileSdkVersion 23
buildToolsVersion "23.0.2"

defaultConfig {
applicationId "com.example.administrator.youtube"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile files('libs/YouTubeAndroidPlayerApi.jar')
}

最佳答案

你的 gradle uri google-api-services-youtube 是错误的,为此更换你的 gradle 依赖:

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile 'com.google.apis:google-api-services-youtube:v3-rev157-1.21.0'
}

我找到了 here .然后我只是替换为最新版本 v3-rev157-1.21.0

它会起作用:

enter image description here

关于android - 没有找到类 "com.google.android.youtube.api.jar.client.RemoteEmbeddedPlayer",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34450734/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com