构造函数RxErrorHandlingCallAdapterFactory.RxCallAdapterWrapper(Retrofit,CallAdapter <capture#10-of?=“”>)未定义

时间:2018-01-23 12:04:30

标签: java android

我正在使用带有gradle 3.3的Android Studio 2.3。 (注意:我有意将android studio 3.0.1中的文件迁移到此版本版本,因为我在最新版本上遇到了dragger 2插件和其他错误。)

在构建项目时,我在下面的文件中收到此错误

 package com.firstup.android.presentation.application.rest;

import java.io.IOException;
import java.lang.annotation.Annotation;
import java.lang.reflect.Type;

import retrofit2.Call;
import retrofit2.CallAdapter;
import retrofit2.Response;
import retrofit2.Retrofit;
import retrofit2.adapter.rxjava.HttpException;
import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory;
import rx.Observable;
import rx.functions.Func1;

/**
 * Created by
 * rMozes on 02/03/2017
 */
public class RxErrorHandlingCallAdapterFactory extends CallAdapter.Factory {
    private final RxJavaCallAdapterFactory original;

    private RxErrorHandlingCallAdapterFactory() {
        original = RxJavaCallAdapterFactory.create();
    }

    public static CallAdapter.Factory create() {
        return new RxErrorHandlingCallAdapterFactory();
    }

    @Override
    public CallAdapter<?, ?> get(Type returnType, Annotation[] annotations, Retrofit retrofit) {
        return new RxCallAdapterWrapper(retrofit, original.get(returnType, annotations, retrofit));
    }

    private static class RxCallAdapterWrapper implements CallAdapter<Call, Observable<?>> {
        private final Retrofit retrofit;
        private final CallAdapter<?, ?> wrapped;

        RxCallAdapterWrapper(Retrofit retrofit, CallAdapter<?, ?> wrapped) {
            this.retrofit = retrofit;
            this.wrapped = wrapped;
        }

        @Override
        public Type responseType() {
            return wrapped.responseType();
        }

        @Override
        public Observable<?> adapt(Call call) {
            return ((Observable) wrapped.adapt(call)).onErrorResumeNext(new Func1<Throwable, Observable>() {
                @Override
                public Observable call(Throwable throwable) {
                    return Observable.error(asRetrofitException(throwable));
                }
            });
        }

        private RetrofitException asRetrofitException(Throwable throwable) {
            // We had non-200 http error
            if (throwable instanceof HttpException) {
                HttpException httpException = (HttpException) throwable;
                Response response = httpException.response();
                return RetrofitException.httpError(response.raw().request().url().toString(), response, retrofit);
            }
            // A network error happened
            if (throwable instanceof IOException) {
                return RetrofitException.networkError((IOException) throwable);
            }

            // We don't know what happened. We need to simply convert to an unknown error

            return RetrofitException.unexpectedError(throwable);
        }
    }
}

由于大小限制,仅添加来自stackstrace的错误行

AGPBI: {"kind":"error","text":"The constructor RxErrorHandlingCallAdapterFactory.RxCallAdapterWrapper(Retrofit, CallAdapter\u003ccapture#10-of ?\u003e) is undefined","sources":[{"file":"G:\\TEST\\FirstUP_android-develop\\FirstUP_android-develop\\app\\src\\main\\java\\com\\firstup\\android\\presentation\\application\\rest\\RxErrorHandlingCallAdapterFactory.java","position":{"startLine":32,"startColumn":15}}]}

* What went wrong:
Execution failed for task ':app:transformJackWithJackForDebug'.
> com.android.build.api.transform.TransformException: com.android.builder.core.JackToolchain$ToolchainException: Jack compilation exception

还复制build.gradle文件。任何帮助将不胜感激。

apply plugin: 'com.android.application'

android {

    signingConfigs {
        debug {
            storeFile file('../keystore/debug_keystore.jks')
            storePassword 'firstup'
            keyAlias 'FirstUp'
            keyPassword 'firstup'
        }
        release {
            storeFile file('../keystore/firstup.jks')
            storePassword 'first:up-pass'
            keyAlias 'firstup_alias'
            keyPassword 'first:up-pass'
        }
    }

    compileSdkVersion 27
    buildToolsVersion '26.0.1'
    defaultConfig {
        applicationId "com.firstup.android"
        minSdkVersion 16
        targetSdkVersion 27
        versionCode 10
        versionName "1.0.4"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
//        vectorDrawables.useSupportLibrary = true
        multiDexEnabled true
        jackOptions {
            enabled true
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
        incremental false
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            signingConfig signingConfigs.release
        }
        debug {
            signingConfig signingConfigs.debug
        }
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.android.support:appcompat-v7:27.0.0'
    compile 'com.android.support:support-v4:27.0.0'
    compile 'com.android.support:recyclerview-v7:27.0.0'
    annotationProcessor 'com.android.support:design:27.0.0'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    compile 'com.google.android.gms:play-services-auth:11.4.2'
    compile 'com.google.android.gms:play-services-base:11.4.2'
    //implementation 'com.google.android.gms:play-services-gcm:11.4.2'
    //     ExoPlayer
    compile 'com.google.android.exoplayer:exoplayer:r2.4.4'
    // Mixpanel
    compile 'com.mixpanel.android:mixpanel-android:4.9.8'
    // SwipeLayout
    compile 'com.github.rambler-digital-solutions:swipe-layout-android:1.0.14'
    // ViewPagerIndicator
    compile 'me.relex:circleindicator:1.2.2@aar'
    // ButterKnife
    compile 'com.jakewharton:butterknife:8.1.0'
    annotationProcessor 'com.jakewharton:butterknife-compiler:8.1.0'
    // Dagger 2
    compile 'com.google.dagger:dagger:2.12'
    annotationProcessor 'com.google.dagger:dagger-compiler:2.12'
    //MaterialPicker
    compile 'com.wdullaer:materialdatetimepicker:3.1.2'
    // RxAndroid
    compile 'io.reactivex:rxjava:1.2.0'
    compile 'io.reactivex:rxandroid:1.2.1'
    // Retrofit
    compile 'com.squareup.retrofit2:retrofit:2.3.0'
    compile 'com.squareup.retrofit2:adapter-rxjava:2.0.2'
    compile 'com.squareup.retrofit2:converter-gson:2.3.0'
    compile 'com.squareup.okhttp3:logging-interceptor:3.8.1'
    compile 'com.squareup.retrofit2:converter-simplexml:2.3.0'
    // Gson
    compile 'com.google.code.gson:gson:2.8.0'
    // Facebook
    compile 'com.facebook.android:facebook-android-sdk:4.19.0'
    // Glide
    compile 'com.github.bumptech.glide:glide:4.3.0'
    compile 'com.android.support:customtabs:27.0.0'
    compile 'uk.co.chrisjenx:calligraphy:2.3.0'
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    testCompile 'junit:junit:4.12'
}

0 个答案:

没有答案