小编Oli*_*pol的帖子

Android Retrofit 无法解析符号 AuthenticationInterceptor

我正在创建一个简单的改造,但出现此错误:

无法解析符号 AuthenticationInterceptor

这里:

public static <S> S createService(
        Class<S> serviceClass, final String authToken) {
    if (!TextUtils.isEmpty(authToken)) {
        AuthenticationInterceptor interceptor =
                new AuthenticationInterceptor(authToken);

        if (!httpClient.interceptors().contains(interceptor)) {
            httpClient.addInterceptor(interceptor);

            builder.client(httpClient.build());
            retrofit = builder.build();
        }
    }

    return retrofit.create(serviceClass);
}
Run Code Online (Sandbox Code Playgroud)

我的构建 gradle 看起来像这样:

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:25.3.1'
    compile 'com.keiferstone:nonet:2.0.4'
    compile 'com.github.GrenderG:Toasty:1.2.5'
    compile 'com.lmntrx.livin.library.droidawesome:droid-awesome:1.1.9'
    testCompile 'junit:junit:4.12'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    compile 'me.pushy:sdk:1.0.28'
    compile 'com.squareup.retrofit2:retrofit:2.3.0'
    compile 'com.google.code.gson:gson:2.6.2'
    compile 'com.squareup.retrofit2:converter-gson:2.0.2'
}
Run Code Online (Sandbox Code Playgroud)

java android gradle retrofit

2
推荐指数
1
解决办法
4262
查看次数

Laravel 检查路由是 api 还是 web

如何检查中间件是web还是auth。\n以下返回所有路由,但我想在api和web之间划分。

\n\n
$routes = app()->routes->getRoutes();\nforeach($routes as $routeKey => $routeValue)\n{\n    dd($routeValue);\n}\n
Run Code Online (Sandbox Code Playgroud)\n\n

返回这个:

\n\n
Route {#109 \xe2\x96\xbc\n  +uri: "oauth/authorize"\n  +methods: array:2 [\xe2\x96\xb6]\n  +action: array:6 [\xe2\x96\xbc\n    "middleware" => array:2 [\xe2\x96\xbc\n      0 => "web"\n      1 => "auth"\n    ]\n    "uses" => "\\Laravel\\Passport\\Http\\Controllers\\AuthorizationController@authorize"\n    "controller" => "\\Laravel\\Passport\\Http\\Controllers\\AuthorizationController@authorize"\n    "namespace" => "\\Laravel\\Passport\\Http\\Controllers"\n    "prefix" => "oauth"\n    "where" => []\n  ]\n  +controller: null\n  +defaults: []\n  +wheres: []\n  +parameters: null\n  +parameterNames: null\n  +computedMiddleware: null\n  +compiled: CompiledRoute {#203 \xe2\x96\xb6}\n  #router: Router {#21 \xe2\x96\xb6}\n  #container: Application {#3 \xe2\x96\xb6}\n}\n
Run Code Online (Sandbox Code Playgroud)\n

php routes laravel laravel-5.4

2
推荐指数
1
解决办法
9096
查看次数

检索项目的父项时出错:找不到与给定名称匹配的资源

如果我完成了gradle,我会收到此错误:

错误:(3)检索项目的父项时出错:找不到与给定名称"android:TextAppearance.Material.Widget.Button.Borderless.Colored"匹配的资源.错误:(4)检索项目的父项时出错:找不到与给定名称"android:TextAppearance.Material.Widget.Button.Colored"匹配的资源.错误:(3)检索项目的父项时出错:找不到与给定名称"android:TextAppearance.Material.Widget.Button.Borderless.Colored"匹配的资源.错误:(4)检索项目的父项时出错:找不到与给定名称"android:TextAppearance.Material.Widget.Button.Colored"匹配的资源.

它向我展示了这些XML代码:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="Base.TextAppearance.AppCompat.Widget.Button.Borderless.Colored" parent="android:TextAppearance.Material.Widget.Button.Borderless.Colored"/>
    <style name="Base.TextAppearance.AppCompat.Widget.Button.Colored" parent="android:TextAppearance.Material.Widget.Button.Colored"/>
    <style name="TextAppearance.AppCompat.Notification.Info.Media"/>
    <style name="TextAppearance.AppCompat.Notification.Media"/>
    <style name="TextAppearance.AppCompat.Notification.Time.Media"/>
    <style name="TextAppearance.AppCompat.Notification.Title.Media"/>
</resources>
Run Code Online (Sandbox Code Playgroud)

这就是build.gradle文件的样子:

apply plugin: 'com.android.application'
apply plugin: 'com.neenbedankt.android-apt'

android {
    compileSdkVersion 23
    buildToolsVersion '25.0.0'

    defaultConfig {
        applicationId "com.test.test"
        minSdkVersion 19
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    configurations {
        all*.exclude group: 'org.bytedeco', module: 'javacpp-presets'
    }

    packagingOptions {
        exclude 'META-INF/maven/org.bytedeco.javacpp-presets/ffmpeg/pom.properties'
        exclude 'META-INF/maven/org.bytedeco.javacpp-presets/ffmpeg/pom.xml'
    }
}

dependencies {
    compile fileTree(dir: 'libs', …
Run Code Online (Sandbox Code Playgroud)

android gradle

1
推荐指数
1
解决办法
2404
查看次数

无法解析符号GsonConverterFactory

如果尝试使用GsonConvertFactory,则会收到此错误消息:

无法解析符号 GsonConverterFactory

我正在这样使用它:

    return new Retrofit.Builder()
            .baseUrl(BASE_URL)
            .client(client)
            //.addConverterFactory(MoshiConverterFactory.create())
            .addConverterFactory(GsonConverterFactory.create(gson))
            .build();
Run Code Online (Sandbox Code Playgroud)

这是我的gradle文件(模块:app):

dependencies {
    ...
    releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.1'
    compile 'com.google.code.gson:gson:2.7'
}
Run Code Online (Sandbox Code Playgroud)

android gradle

1
推荐指数
1
解决办法
3321
查看次数

JavaScript 通过 JSON.stringify(data) 循环

我想遍历我的数据并做一些事情。

下列的

var stuff = JSON.stringify(data)
Run Code Online (Sandbox Code Playgroud)

返回我这样的东西:

{"0":"data:image/png;base64,testi,"2":"data:image/png;base64, testi2, ....
Run Code Online (Sandbox Code Playgroud)

我需要循环遍历,但我所做的方法不起作用。

        for (var i = 0; i < stuff.length; i++) {
            $('#img-thumb-id'+i).attr('src', data[i]);
        }
Run Code Online (Sandbox Code Playgroud)

编辑

我正在使用JSON.stringify 是因为console.log(data)刚刚返回了我无法使用的对象对象。

javascript json

-1
推荐指数
1
解决办法
6461
查看次数

标签 统计

android ×3

gradle ×3

java ×1

javascript ×1

json ×1

laravel ×1

laravel-5.4 ×1

php ×1

retrofit ×1

routes ×1