java.lang.NoClassDefFoundError:解析失败:Lcom / google / android / youtube / player / YouTubeApiServiceUtil;

时间:2017-08-31 16:49:15

标签: android android-5.0-lollipop android-youtube-api

当在Android 5.0和5.1设备中执行包含youtube播放器代码的片段时,应用程序崩溃。虽然它在Android 6.0及以上版本设备中运行良好。

崩溃的代码:

YouTubeInitializationResult result =
    YouTubeApiServiceUtil.isYouTubeApiServiceAvailable(getActivity());
if (result != YouTubeInitializationResult.SUCCESS) {
    result.getErrorDialog(getActivity(), 0).show();
}

摇篮:

 build.gradle dependencies {
           compile fileTree(include: ['*.jar'], dir: 'libs')
           compile files('libs/YouTubeAndroidPlayerApi.jar') androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2',
       {
exclude group: 'com.android.support', module: 'support-annotations'
           })
           compile project(':ResideMenu')
           compile 'com.android.support:appcompat-v7:25.0.0'
           compile 'com.android.support:support-v4:25.0.0'
           compile 'com.android.support:design:25.0.0'
           compile 'com.android.support:cardview-v7:25.0.0'
           compile 'com.android.support:recyclerview-v7:25.0.0'
           compile 'com.android.support:percent:25.0.0'
           compile 'com.google.android.gms:play-services:10.2.1'
           compile 'org.apache.commons:commons-io:1.3.2'
           compile 'org.apache.commons:commons-lang3:3.4' }

错误日志:

  

java.lang.NoClassDefFoundError:解析失败:       LCOM /谷歌/机器人/的YouTube /播放器/ YouTubeApiServiceUtil;

     

引起:java.lang.ClassNotFoundException:找不到类" com.google.android.youtube.player.YouTubeApiServiceUtil"

1 个答案:

答案 0 :(得分:0)

您可以尝试在gradle中添加依赖项,而不是使用jar文件:

repositories {
    mavenCentral()
}

dependencies {
    compile 'com.google.apis:google-api-services-youtube:v3-rev183-1.22.0'
}