找不到YouTubePlayerSupportFragment类

时间:2017-09-28 05:53:13

标签: android youtube-api

我有以下Activity

public class YouTubeActivity extends FragmentActivity {
        public static final String TOKEN = "xxxxxxxx";

        public static final String VIDEO_ID_ARG = "video_id_arg";

        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);

            setContentView(R.layout.activity_you_tube);
            ButterKnife.bind(this);
            String url = getIntent().getStringExtra(VIDEO_ID_ARG);

            YouTubePlayerSupportFragment youtubeFragment = YouTubePlayerSupportFragment.newInstance();

            YouTubePlayer.OnInitializedListener onInitializedListener = new YouTubePlayer.OnInitializedListener() {
                @Override
                public void onInitializationSuccess(YouTubePlayer.Provider provider, YouTubePlayer youTubePlayer, boolean wasRestored) {
                    if (!wasRestored) {
                        youTubePlayer.addFullscreenControlFlag(1);
                        youTubePlayer.loadVideo(url);
                        youTubePlayer.play();
                    }
                }

                @Override
                public void onInitializationFailure(YouTubePlayer.Provider provider, YouTubeInitializationResult youTubeInitializationResult) {
                    Timber.d("");
                }
            };

            youtubeFragment.initialize(TOKEN, onInitializedListener);
            getSupportFragmentManager().beginTransaction().add(R.id.youtube_fragment, youtubeFragment).commit();
        }
    }

我已经在libs文件夹中复制了YouTubeAndroidPlayerApi.jar我发现 compile files('libs/YouTubeAndroidPlayerApi.jar') 的库。

在build.gradle文件中我有

NoClassDefFoundError

问题是我在致电时持续YouTubePlayerSupportFragment.newInstance()

YouTubeBaseActivity

我已尝试过在其他问题中提出的其他解决方案,但没有成功。使用Fragment导致Lollipop崩溃。 我还试图定义自己YouTubePlayerSupportFragment来自java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/youtube/player/YouTubePlayerSupportFragment; at org.d.ui.activity.YouTubeActivity.onCreate(YouTubeActivity.java:29) at android.app.Activity.performCreate(Activity.java:6288) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2642) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2754) at android.app.ActivityThread.access$900(ActivityThread.java:177) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1448) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:145) at android.app.ActivityThread.main(ActivityThread.java:5938) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1400) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1195) Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.youtube.player.YouTubePlayerSupportFragment" on path: DexPathList[[zip file "/data/app/org.whatifitoldyou-1/base.apk", zip file "/data/app/org.whatifitoldyou-1/split_lib_dependencies_apk.apk", zip file "/data/app/org.whatifitoldyou-1/split_lib_slice_0_apk.apk", zip file "/data/app/org.whatifitoldyou-1/split_lib_slice_1_apk.apk", zip file "/data/app/org.whatifitoldyou-1/split_lib_slice_2_apk.apk", zip file "/data/app/org.whatifitoldyou-1/split_lib_slice_3_apk.apk", zip file "/data/app/org.whatifitoldyou-1/split_lib_slice_4_apk.apk", zip file "/data/app/org.whatifitoldyou-1/split_lib_slice_5_apk.apk", zip file "/data/app/org.whatifitoldyou-1/split_lib_slice_6_apk.apk", zip file "/data/app/org.whatifitoldyou-1/split_lib_slice_7_apk.apk", zip file "/data/app/org.whatifitoldyou-1/split_lib_slice_8_apk.apk", zip file "/data/app/org.whatifitoldyou-1/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/org.whatifitoldyou-1/lib/arm, /vendor/lib, /system/lib]] at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56) at java.lang.ClassLoader.loadClass(ClassLoader.java:511) at java.lang.ClassLoader.loadClass(ClassLoader.java:469) at org.whatifitoldyou.ui.activity.YouTubeActivity.onCreate(YouTubeActivity.java:29)  at android.app.Activity.performCreate(Activity.java:6288)  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119)  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2642)  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2754)  at android.app.ActivityThread.access$900(ActivityThread.java:177)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1448)  at android.os.Handler.dispatchMessage(Handler.java:102)  at android.os.Looper.loop(Looper.java:145)  at android.app.ActivityThread.main(ActivityThread.java:5938)  at java.lang.reflect.Method.invoke(Native Method)  at java.lang.reflect.Method.invoke(Method.java:372)  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1400)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1195)  Suppressed: java.lang.ClassNotFoundException: com.google.android.youtube.player.YouTubePlayerSupportFragment at java.lang.Class.classForName(Native Method) at java.lang.BootClassLoader.findClass(ClassLoader.java:781) at java.lang.BootClassLoader.loadClass(ClassLoader.java:841) at java.lang.ClassLoader.loadClass(ClassLoader.java:504) ... 15 more Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available

buildscript {
    repositories {
        maven { url 'https://maven.fabric.io/public' }
        mavenCentral()
    }
    dependencies {
        classpath 'me.tatarka:gradle-retrolambda:3.3.1'
        classpath 'io.fabric.tools:gradle:1.22.2'
    }
}

plugins {
    id "me.tatarka.retrolambda" version "3.3.1"
}

repositories {
    // Required because retrolambda is on maven central
    mavenCentral()
    maven { url 'https://maven.fabric.io/public' }
    maven { url 'https://maven.google.com' }
}

apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
apply plugin: 'realm-android'

android {
    compileSdkVersion 25
    buildToolsVersion '25.0.3'
    compileOptions.incremental = false

    compileOptions {
        targetCompatibility JavaVersion.VERSION_1_8
        sourceCompatibility JavaVersion.VERSION_1_8
    }

    defaultConfig {
        javaCompileOptions {
            annotationProcessorOptions {
                arguments = ['autovaluegson.defaultCollectionsToEmpty': 'true']
            }
        }

        multiDexEnabled true
        applicationId "app.id"
        minSdkVersion 17
        targetSdkVersion 25
        versionCode 1

        versionName "0.1"
        vectorDrawables.useSupportLibrary = true
        jackOptions {
            enabled false
        }
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

        dexOptions {
            preDexLibraries = false
            javaMaxHeapSize "4g"
        }
    }

    compileOptions {
        incremental true
    }

    buildTypes {
        release {
            debuggable false
            minifyEnabled true
            zipAlignEnabled true
            renderscriptDebuggable false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            signingConfig signingConfigs.release
            javaCompileOptions.annotationProcessorOptions.arguments['butterknife.debuggable'] = 'false'
        }
        debug {
            debuggable true
            signingConfig signingConfigs.debug
            minifyEnabled false
            versionNameSuffix "_dev"
        }
    }
}

def jsr250_api = '1.0'
def multidex = '1.0.1'
def supportVersion = '25.3.1'
def lifecycle_runtime = '1.0.0-alpha1'
def daggerVer = '2.11'
def rxbinding = '2.0.0'
def RxBus2 = '0.1'
def retrofit2 = '2.2.0'
def okhttp3 = '3.4.1'
def facebook = '4.23.0'
def firebase = '11.0.0'
def firebaseuiauth = '2.0.0'
def butter_knife = '8.4.0'
def leak_canary = '1.4'
def autovalue = '1.4'
def autovalueparcel = '0.2.5'
def autovaluegson = '0.4.5'
def auto_value_with = '1.0.0'
def drop_in = '3.0.6'
def PersistentCookieJar = 'v1.0.1'
def joda_time = '2.5'
def timber = '4.3.1'
def glide = '3.7.0'
def clans_fab = '1.6.4'
def circleindicator = '1.2.2@aar'
def justified_text_view = '1.0'
def appintro = '4.1.0'
def crashlytics = '2.6.8@aar'
def aboutlib = '5.9.6@aar'
def hamcrestVersion = '1.3'
def espresso_core = '2.2.2'
def mockito_core = '1.10.19'
def junit = '4.12'

dependencies {
    annotationProcessor "com.google.dagger:dagger-android-processor:$daggerVer"
    compile "com.google.dagger:dagger:$daggerVer"
    compile "com.google.dagger:dagger-android-support:$daggerVer"
    annotationProcessor "com.google.dagger:dagger-compiler:$daggerVer"

    compile fileTree(dir: 'libs', include: ['*.jar'])

    compile "com.android.support:multidex:$multidex"

    compile "com.android.support:appcompat-v7:$supportVersion"
    compile "com.android.support:design:$supportVersion"
    compile "com.android.support:cardview-v7:$supportVersion"
    compile "com.android.support:recyclerview-v7:$supportVersion"
    compile "com.android.support:gridlayout-v7:$supportVersion"
    compile "com.android.support:support-annotations:$supportVersion"
    compile "com.android.support:preference-v7:$supportVersion"
    compile "com.android.support:support-v4:$supportVersion"
    compile "com.android.support:support-vector-drawable:$supportVersion"
    compile "com.android.support:palette-v7:$supportVersion"

    compile "com.google.firebase:firebase-auth:$firebase"
    compile "com.google.firebase:firebase-config:$firebase"
    compile "com.google.firebase:firebase-database:$firebase"
    compile "com.firebaseui:firebase-ui-auth:$firebaseuiauth"

    compile "com.jakewharton.rxbinding2:rxbinding:$rxbinding"
    compile "com.jakewharton.rxbinding2:rxbinding-support-v4:$rxbinding"
    compile "com.jakewharton.rxbinding2:rxbinding-appcompat-v7:$rxbinding"
    compile "com.jakewharton.rxbinding2:rxbinding-design:$rxbinding"
    compile "com.jakewharton.rxbinding2:rxbinding-recyclerview-v7:$rxbinding"
    compile "com.jakewharton.rxbinding2:rxbinding-leanback-v17:$rxbinding"

    compile "joda-time:joda-time:$joda_time"
    compile "com.jakewharton.timber:timber:$timber"
    compile "com.github.bumptech.glide:glide:$glide"
    compile "com.github.clans:fab:$clans_fab"

    compile "com.uncopt:android.justified:$justified_text_view"

    compile "me.relex:circleindicator:$circleindicator"
    compile "com.github.paolorotolo:appintro:$appintro"

    //architecture
    compile "android.arch.lifecycle:runtime:$lifecycle_runtime"
    compile "android.arch.lifecycle:extensions:$lifecycle_runtime"
    annotationProcessor "android.arch.lifecycle:compiler:$lifecycle_runtime"

    compile "com.squareup.retrofit2:retrofit:$retrofit2"
    compile "com.squareup.retrofit2:adapter-rxjava2:$retrofit2"
    compile "com.squareup.retrofit2:converter-gson:$retrofit2"
    compile "com.squareup.retrofit2:converter-scalars:$retrofit2"
    compile "com.squareup.okhttp3:okhttp:$okhttp3"
    compile "com.squareup.okhttp3:okhttp-urlconnection:$okhttp3"
    compile "com.squareup.okhttp3:logging-interceptor:$okhttp3"
    compile "com.github.franmontiel:PersistentCookieJar:$PersistentCookieJar"

    compile "com.github.MFlisar:RxBus2:$RxBus2"

    //necessary for the contrast transformation

    annotationProcessor "com.jakewharton:butterknife-compiler:$butter_knife"
    compile "com.jakewharton:butterknife:$butter_knife"

    debugCompile "com.squareup.leakcanary:leakcanary-android:$leak_canary"
    releaseCompile "com.squareup.leakcanary:leakcanary-android-no-op:$leak_canary"
    testCompile "com.squareup.leakcanary:leakcanary-android-no-op:$leak_canary"

    compile "com.facebook.android:facebook-android-sdk:$facebook"

    annotationProcessor "com.google.auto.value:auto-value:$autovalue"
    annotationProcessor "com.gabrielittner.auto.value:auto-value-with:$auto_value_with"
    annotationProcessor "com.ryanharter.auto.value:auto-value-parcel:$autovalueparcel"
    compile "com.ryanharter.auto.value:auto-value-parcel-adapter:$autovalueparcel"

    provided "com.ryanharter.auto.value:auto-value-gson:$autovaluegson"

    provided "javax.annotation:jsr250-api:$jsr250_api"

    compile "com.braintreepayments.api:drop-in:$drop_in"

    compile("com.crashlytics.sdk.android:crashlytics:$crashlytics") {
        transitive = true;
    }

    compile("com.mikepenz:aboutlibraries:$aboutlib") {
        transitive = true
    }
    //other dependencies for testing
    testCompile "org.hamcrest:hamcrest-core:$hamcrestVersion"
    testCompile "org.hamcrest:hamcrest-library:$hamcrestVersion"
    testCompile "org.hamcrest:hamcrest-integration:$hamcrestVersion"
    androidTestCompile("com.android.support.test.espresso:espresso-core:$espresso_core", {
        exclude group: 'com.android.support', module: 'support-annotations'
    })

    testCompile "org.mockito:mockito-core:$mockito_core"
    testCompile "junit:junit:$junit"
    compile 'com.f2prateek.rx.preferences2:rx-preferences:2.0.0-RC2'
    compile 'jp.wasabeef:glide-transformations:2.0.2'
    compile 'jp.co.cyberagent.android.gpuimage:gpuimage-library:1.4.1'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
}

apply plugin: 'com.google.gms.google-services'

android.packagingOptions {
    exclude 'LICENSE.txt'
    exclude 'META-INF/LICENSE.txt'
    exclude 'META-INF/NOTICE.txt'
    exclude 'META-INF/rxjava.properties'

}

configurations.all {
    resolutionStrategy.force 'com.google.code.findbugs:jsr305:1.3.9'
    resolutionStrategy.eachDependency { DependencyResolveDetails details ->
        def requested = details.requested
        if (requested.group == 'com.android.support') {
            if (!requested.name.startsWith("multidex")) {
                details.useVersion "$supportVersion"
            }
        }
    }
}

ADDED

from("file:" + censusDirectory + "?recursive=true").idempotentConsumer(new SimpleExpression("file:name"), idempotentRepository)
      .process(new JobProcessor(organizationService, jobService, Job.JobType.CENSUS))
      .unmarshal(censusExcelDataFormat)
      .split(body(),  new ListAggregationStrategy()).parallelProcessing()
      .to(ExchangePattern.InOut, "hazelcast:seda:process-employee-import").end()
      .process(new JobCompletionProcessor(jobService))
.end();

from("hazelcast:seda:process-employee-import")
      .idempotentConsumer(simple("${body.entityId}"), idempotentRepository)
      .bean(employeeImporterJob, "importOrUpdate");

0 个答案:

没有答案