Watson Conversation自动生成Android应用程序 - '未知模式角色' X''

时间:2017-09-04 02:23:39

标签: android json ibm-cloud watson-conversation

我使用IBM Watson Mobile App中自动生成的示例,但是当我尝试运行它时,它在以下代码部分显示错误。我在SO周围发现了类似的错误,但我认为这是另一个不同的错误。

public ServiceCall<MessageResponse> message(String workspaceId, MessageRequest request) {
Validator.isTrue((workspaceId != null) && !workspaceId.isEmpty(), "'workspaceId' cannot be null or empty");

RequestBuilder builder = RequestBuilder.post(String.format(PATH_MESSAGE, workspaceId));
builder.query(VERSION_PARAM, versionDate);
if (request != null) {
  //the error shows here
  builder.bodyJson(GsonSingleton.getGson().toJsonTree(request).getAsJsonObject());
} else {
  builder.bodyJson(new JsonObject());
}
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(MessageResponse.class));
}

以下是我的build.gradle文件:

apply plugin:'base'
apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.2"

    defaultConfig {
        applicationId "com.ibm.watson_conversation"
        minSdkVersion 19
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        manifestPlaceholders = ['appIdRedirectScheme': android.defaultConfig.applicationId]
        vectorDrawables.useSupportLibrary = true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    lintOptions {
        warning 'InvalidPackage'
        abortOnError false
    }
}

dependencies {
    compile ('com.ibm.mobilefirstplatform.clientsdk.android:core:[2.0.0,3.0.0)')
    compile 'com.ibm.watson.developer_cloud:conversation:3.8.0'
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:25.1.0'
    compile 'com.android.support:design:25.1.0'
}

1 个答案:

答案 0 :(得分:1)

问题已在3.9.0中修复。

您只需将依赖关系版本更新为3.9.1

compile 'com.ibm.watson.developer_cloud:conversation:3.9.1'