Java Commercetools Sphereio SphereClient为空

Java Commercetools Sphereio SphereClient为空,java,android,commercetools,sphere.io,Java,Android,Commercetools,Sphere.io,我正在尝试运行一个简单的示例来获取android中的产品详细信息,我使用java示例作为指南。 我得到一个错误: io.sphere.client.SphereClientException: null: null 我的身材。格雷德尔: 安卓{ 编译DK22版 buildToolsVersion“22.0.1” packagingOptions { exclude 'META-INF/DEPENDENCIES' exclude 'META-INF/NOTICE' ex

我正在尝试运行一个简单的示例来获取android中的产品详细信息,我使用java示例作为指南。

我得到一个错误:

io.sphere.client.SphereClientException: null: null
我的身材。格雷德尔:

安卓{ 编译DK22版 buildToolsVersion“22.0.1”

packagingOptions {
    exclude 'META-INF/DEPENDENCIES'
    exclude 'META-INF/NOTICE'
    exclude 'META-INF/LICENSE'
    exclude 'META-INF/LICENSE.txt'
    exclude 'META-INF/NOTICE.txt'
    exclude 'META-INF/ASL2.0'
}

defaultConfig {
    applicationId "com.spheretest"
    minSdkVersion 15
    targetSdkVersion 22
    versionCode 1
    versionName "1.0"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
} 依赖关系{ 编译文件树(包括:['*.jar'],目录:“libs”) 编译'com.android.support:appcompat-v7:22.2.1' 编译“io.sphere:SphereJava客户端:0.60.0” }

是否有任何android示例可供我测试运行,以实现与Sphere的基本连接

Stacktrace:

    09-10 12:39:27.193  24611-24673/com.spheretest I/System.out﹕ 12:39:27.193 [Sphere-ClientCredentials-refresh-1] DEBUG sphere - [oauth] Refreshing access token.
09-10 12:39:27.195  24611-24611/com.spheretest I/System.out﹕ 12:39:27.194 [main] DEBUG sphere - [cache] Refreshing category tree.
09-10 12:39:27.206  24611-24611/com.spheretest I/System.out﹕ SphereClient== io.sphere.client.shop.SphereClient@76338d
09-10 12:39:27.897  24611-24673/com.spheretest I/System.out﹕ 12:39:27.896 [Sphere-ClientCredentials-refresh-1] DEBUG c.n.h.c.p.n.NettyAsyncHttpProvider -
09-10 12:39:27.897  24611-24673/com.spheretest I/System.out﹕ Non cached request
09-10 12:39:27.897  24611-24673/com.spheretest I/System.out﹕ DefaultHttpRequest(chunked: false)
09-10 12:39:27.897  24611-24673/com.spheretest I/System.out﹕ POST /oauth/token?grant_type=client_credentials&scope=manage_project%3Aorderjoy-85 HTTP/1.1
09-10 12:39:27.897  24611-24673/com.spheretest I/System.out﹕ Host: auth-v0.sphere.io
09-10 12:39:27.897  24611-24673/com.spheretest I/System.out﹕ Content-Type: application/x-www-form-urlencoded
09-10 12:39:27.897  24611-24673/com.spheretest I/System.out﹕ Connection: keep-alive
09-10 12:39:27.897  24611-24673/com.spheretest I/System.out﹕ Accept: */*
09-10 12:39:27.897  24611-24673/com.spheretest I/System.out﹕ User-Agent: NING/1.0
09-10 12:39:27.897  24611-24673/com.spheretest I/System.out﹕ [ 09-10 12:39:27.897 24611:24673 I/System.out ]
    using Channel
09-10 12:39:27.897  24611-24673/com.spheretest I/System.out﹕ [id: 0xb6a042f6, /192.168.1.3:38555]
09-10 12:39:27.897  24611-24673/com.spheretest I/System.out﹕ [ 09-10 12:39:27.901   774: 3054 I/AccountManagerService ]
    getTypesVisibleToCaller: isPermitted? true
09-10 12:39:29.370  24611-24662/com.spheretest I/System.out﹕ 12:39:29.369 [New I/O worker #1] DEBUG c.n.h.c.p.n.NettyAsyncHttpProvider -
09-10 12:39:29.370  24611-24662/com.spheretest I/System.out﹕ [ 09-10 12:39:29.370 24611:24662 I/System.out ]
    Request DefaultHttpRequest(chunked: false)
09-10 12:39:29.370  24611-24662/com.spheretest I/System.out﹕ POST /oauth/token?grant_type=client_credentials&scope=manage_project%3Aorderjoy-85 HTTP/1.1
09-10 12:39:29.370  24611-24662/com.spheretest I/System.out﹕ Host: auth-v0.sphere.io
09-10 12:39:29.370  24611-24662/com.spheretest I/System.out﹕ Content-Type: application/x-www-form-urlencoded
09-10 12:39:29.370  24611-24662/com.spheretest I/System.out﹕ Connection: keep-alive
09-10 12:39:29.370  24611-24662/com.spheretest I/System.out﹕ Accept: */*
09-10 12:39:29.370  24611-24662/com.spheretest I/System.out﹕ User-Agent: NING/1.0
09-10 12:39:29.370  24611-24662/com.spheretest I/System.out﹕ [ 09-10 12:39:29.370 24611:24662 I/System.out ]
    Response DefaultHttpResponse(chunked: true)
09-10 12:39:29.370  24611-24662/com.spheretest I/System.out﹕ HTTP/1.1 401 Unauthorized
09-10 12:39:29.370  24611-24662/com.spheretest I/System.out﹕ Server: nginx
09-10 12:39:29.370  24611-24662/com.spheretest I/System.out﹕ Date: Thu, 10 Sep 2015 07:09:30 GMT
09-10 12:39:29.370  24611-24662/com.spheretest I/System.out﹕ Content-Type: application/json; charset=utf-8
09-10 12:39:29.370  24611-24662/com.spheretest I/System.out﹕ Transfer-Encoding: chunked
09-10 12:39:29.370  24611-24662/com.spheretest I/System.out﹕ Connection: keep-alive
09-10 12:39:29.370  24611-24662/com.spheretest I/System.out﹕ WWW-Authenticate: Bearer realm="sphere", error="invalid_client", error_description="Please provide valid client credentials using HTTP Basic Authentication."
09-10 12:39:29.370  24611-24662/com.spheretest I/System.out﹕ Pragma: no-cache
09-10 12:39:29.370  24611-24662/com.spheretest I/System.out﹕ Cache-Control: no-store
09-10 12:39:29.370  24611-24662/com.spheretest I/System.out﹕ X-Correlation-ID: nginx-e04c33e0-0354-45fd-87eb-69a755c84a81
09-10 12:39:29.370  24611-24662/com.spheretest I/System.out﹕ X-Served-By: app12.sphere.prod.commercetools.de
09-10 12:39:29.370  24611-24662/com.spheretest I/System.out﹕ X-Served-Config: sphere-auth-ws-1.0
09-10 12:39:29.370  24611-24662/com.spheretest I/System.out﹕ [ 09-10 12:39:29.378 24611:24662 I/System.out ]
    12:39:29.378 [New I/O worker #1] DEBUG c.n.h.c.p.n.NettyAsyncHttpProvider - Sending authentication to https://auth-v0.sphere.io/oauth/token?grant_type=client_credentials&scope=manage_project%3Aorderjoy-85
09-10 12:39:29.383  24611-24662/com.spheretest I/System.out﹕ 12:39:29.383 [New I/O worker #1] DEBUG c.n.h.c.p.n.NettyAsyncHttpProvider -
09-10 12:39:29.383  24611-24662/com.spheretest I/System.out﹕ Non cached request
09-10 12:39:29.383  24611-24662/com.spheretest I/System.out﹕ DefaultHttpRequest(chunked: false)
09-10 12:39:29.383  24611-24662/com.spheretest I/System.out﹕ POST /oauth/token?grant_type=client_credentials&scope=manage_project%3Aorderjoy-85 HTTP/1.1
09-10 12:39:29.383  24611-24662/com.spheretest I/System.out﹕ Host: auth-v0.sphere.io
09-10 12:39:29.383  24611-24662/com.spheretest I/System.out﹕ Content-Type: application/x-www-form-urlencoded
09-10 12:39:29.383  24611-24662/com.spheretest I/System.out﹕ Authorization: Basic SlI0STlQWTZmTU5HbG9JVWVsLWN6UEFPOkN1U2F4NmRCdHhfN0ZmWXNULUg2VUJvXzB6OXpEVGdR
09-10 12:39:29.383  24611-24662/com.spheretest I/System.out﹕ Connection: keep-alive
09-10 12:39:29.383  24611-24662/com.spheretest I/System.out﹕ Accept: */*
09-10 12:39:29.383  24611-24662/com.spheretest I/System.out﹕ User-Agent: NING/1.0
09-10 12:39:29.383  24611-24662/com.spheretest I/System.out﹕ [ 09-10 12:39:29.383 24611:24662 I/System.out ]
    using Channel
09-10 12:39:29.383  24611-24662/com.spheretest I/System.out﹕ [id: 0x04c9853c, /192.168.1.3:38556]
09-10 12:39:29.383  24611-24662/com.spheretest I/System.out﹕ [ 09-10 12:39:29.479 24856:24868 W/com.worklight.common.Logger ]
    com.worklight.common.Logger.setContext(Context) must be called to fully enable debug log capture.  Currently, the 'capture' flag is set but the 'context' field is not.  This warning will only be printed once.
09-10 12:39:30.824  24611-24663/com.spheretest I/System.out﹕ 12:39:30.823 [New I/O worker #2] DEBUG c.n.h.c.p.n.NettyAsyncHttpProvider -
09-10 12:39:30.824  24611-24663/com.spheretest I/System.out﹕ [ 09-10 12:39:30.824 24611:24663 I/System.out ]
    Request DefaultHttpRequest(chunked: false)
09-10 12:39:30.824  24611-24663/com.spheretest I/System.out﹕ POST /oauth/token?grant_type=client_credentials&scope=manage_project%3Aorderjoy-85 HTTP/1.1
09-10 12:39:30.824  24611-24663/com.spheretest I/System.out﹕ Host: auth-v0.sphere.io
09-10 12:39:30.824  24611-24663/com.spheretest I/System.out﹕ Content-Type: application/x-www-form-urlencoded
09-10 12:39:30.824  24611-24663/com.spheretest I/System.out﹕ Authorization: Basic SlI0STlQWTZmTU5HbG9JVWVsLWN6UEFPOkN1U2F4NmRCdHhfN0ZmWXNULUg2VUJvXzB6OXpEVGdR
09-10 12:39:30.824  24611-24663/com.spheretest I/System.out﹕ Connection: keep-alive
09-10 12:39:30.824  24611-24663/com.spheretest I/System.out﹕ Accept: */*
09-10 12:39:30.824  24611-24663/com.spheretest I/System.out﹕ User-Agent: NING/1.0
09-10 12:39:30.824  24611-24663/com.spheretest I/System.out﹕ [ 09-10 12:39:30.824 24611:24663 I/System.out ]
    Response DefaultHttpResponse(chunked: true)

commercetools平台有一个SDK,可用于所有JVM语言(“SPHERE JVM SDK”),需要Java 8语言功能,因此无法在Android上使用,因为Android不是JVM

您正在尝试的“旧”SDK(不幸的是,它仍然在Java Hello World示例中使用)在技术上与Android兼容,但我不建议使用它,因为它不再维护()

因此,到目前为止,Android客户端是使用Android内置HTTP客户端等直接针对HTTP API构建的。
实际答案:你可以在谷歌玻璃演示应用程序(GitHub,麻省理工学院许可证)中找到一个正常工作的Android示例: .

一个警告:SphereAPI的可用OAuth授权范围目前还不足以构建一个完全本地的应用程序,包括直接针对commercetools(SPHERE)API进行签出。你必须考虑要么不做结账(即WebVIEW),要么(最好)运行一个最小的服务器端API SIMM,它为公共应用程序白内容,做OAuthand知道秘密。
对于上面的Google Glass演示代码这样的原型/概念验证,这并不是一个问题。

与此同时,我们致力于更好地支持移动设备。 例如,我们为Android创建了Hello World,您可以将其用作移动应用程序的起点:


在不久的将来,我们将继续扩展对移动平台的支持。

您好,您能附上堆栈跟踪吗?thanks@sebbulonstacktrace补充道,客户端id和secret都是正确的,我可以肯定的是,有谷歌眼镜的样本并不奇怪,但仍然没有关注基本的android。正如您所说:SphereAPI目前还不足以构建一个完全本地的应用程序。大多数商店目前都把重点放在移动设备上。开发人员仍在努力以本地方式在移动设备上实现Sphere。Sphere未来的开发重点是什么?这有点不一致,这是正确的。但commerceools已将其列入路线图。您已经在反馈门户()中创建了一个建议,可以在那里跟踪进度(此处不属于主题)。欢迎提供指向潜在解决方案的链接,但请务必提供,以便您的其他用户了解它是什么以及为什么存在。始终引用重要链接中最相关的部分,以防无法访问目标站点或永久脱机。考虑到仅仅是一个指向外部站点的链接是一个可能的原因。
    09-10 12:39:27.193  24611-24673/com.spheretest I/System.out﹕ 12:39:27.193 [Sphere-ClientCredentials-refresh-1] DEBUG sphere - [oauth] Refreshing access token.
09-10 12:39:27.195  24611-24611/com.spheretest I/System.out﹕ 12:39:27.194 [main] DEBUG sphere - [cache] Refreshing category tree.
09-10 12:39:27.206  24611-24611/com.spheretest I/System.out﹕ SphereClient== io.sphere.client.shop.SphereClient@76338d
09-10 12:39:27.897  24611-24673/com.spheretest I/System.out﹕ 12:39:27.896 [Sphere-ClientCredentials-refresh-1] DEBUG c.n.h.c.p.n.NettyAsyncHttpProvider -
09-10 12:39:27.897  24611-24673/com.spheretest I/System.out﹕ Non cached request
09-10 12:39:27.897  24611-24673/com.spheretest I/System.out﹕ DefaultHttpRequest(chunked: false)
09-10 12:39:27.897  24611-24673/com.spheretest I/System.out﹕ POST /oauth/token?grant_type=client_credentials&scope=manage_project%3Aorderjoy-85 HTTP/1.1
09-10 12:39:27.897  24611-24673/com.spheretest I/System.out﹕ Host: auth-v0.sphere.io
09-10 12:39:27.897  24611-24673/com.spheretest I/System.out﹕ Content-Type: application/x-www-form-urlencoded
09-10 12:39:27.897  24611-24673/com.spheretest I/System.out﹕ Connection: keep-alive
09-10 12:39:27.897  24611-24673/com.spheretest I/System.out﹕ Accept: */*
09-10 12:39:27.897  24611-24673/com.spheretest I/System.out﹕ User-Agent: NING/1.0
09-10 12:39:27.897  24611-24673/com.spheretest I/System.out﹕ [ 09-10 12:39:27.897 24611:24673 I/System.out ]
    using Channel
09-10 12:39:27.897  24611-24673/com.spheretest I/System.out﹕ [id: 0xb6a042f6, /192.168.1.3:38555]
09-10 12:39:27.897  24611-24673/com.spheretest I/System.out﹕ [ 09-10 12:39:27.901   774: 3054 I/AccountManagerService ]
    getTypesVisibleToCaller: isPermitted? true
09-10 12:39:29.370  24611-24662/com.spheretest I/System.out﹕ 12:39:29.369 [New I/O worker #1] DEBUG c.n.h.c.p.n.NettyAsyncHttpProvider -
09-10 12:39:29.370  24611-24662/com.spheretest I/System.out﹕ [ 09-10 12:39:29.370 24611:24662 I/System.out ]
    Request DefaultHttpRequest(chunked: false)
09-10 12:39:29.370  24611-24662/com.spheretest I/System.out﹕ POST /oauth/token?grant_type=client_credentials&scope=manage_project%3Aorderjoy-85 HTTP/1.1
09-10 12:39:29.370  24611-24662/com.spheretest I/System.out﹕ Host: auth-v0.sphere.io
09-10 12:39:29.370  24611-24662/com.spheretest I/System.out﹕ Content-Type: application/x-www-form-urlencoded
09-10 12:39:29.370  24611-24662/com.spheretest I/System.out﹕ Connection: keep-alive
09-10 12:39:29.370  24611-24662/com.spheretest I/System.out﹕ Accept: */*
09-10 12:39:29.370  24611-24662/com.spheretest I/System.out﹕ User-Agent: NING/1.0
09-10 12:39:29.370  24611-24662/com.spheretest I/System.out﹕ [ 09-10 12:39:29.370 24611:24662 I/System.out ]
    Response DefaultHttpResponse(chunked: true)
09-10 12:39:29.370  24611-24662/com.spheretest I/System.out﹕ HTTP/1.1 401 Unauthorized
09-10 12:39:29.370  24611-24662/com.spheretest I/System.out﹕ Server: nginx
09-10 12:39:29.370  24611-24662/com.spheretest I/System.out﹕ Date: Thu, 10 Sep 2015 07:09:30 GMT
09-10 12:39:29.370  24611-24662/com.spheretest I/System.out﹕ Content-Type: application/json; charset=utf-8
09-10 12:39:29.370  24611-24662/com.spheretest I/System.out﹕ Transfer-Encoding: chunked
09-10 12:39:29.370  24611-24662/com.spheretest I/System.out﹕ Connection: keep-alive
09-10 12:39:29.370  24611-24662/com.spheretest I/System.out﹕ WWW-Authenticate: Bearer realm="sphere", error="invalid_client", error_description="Please provide valid client credentials using HTTP Basic Authentication."
09-10 12:39:29.370  24611-24662/com.spheretest I/System.out﹕ Pragma: no-cache
09-10 12:39:29.370  24611-24662/com.spheretest I/System.out﹕ Cache-Control: no-store
09-10 12:39:29.370  24611-24662/com.spheretest I/System.out﹕ X-Correlation-ID: nginx-e04c33e0-0354-45fd-87eb-69a755c84a81
09-10 12:39:29.370  24611-24662/com.spheretest I/System.out﹕ X-Served-By: app12.sphere.prod.commercetools.de
09-10 12:39:29.370  24611-24662/com.spheretest I/System.out﹕ X-Served-Config: sphere-auth-ws-1.0
09-10 12:39:29.370  24611-24662/com.spheretest I/System.out﹕ [ 09-10 12:39:29.378 24611:24662 I/System.out ]
    12:39:29.378 [New I/O worker #1] DEBUG c.n.h.c.p.n.NettyAsyncHttpProvider - Sending authentication to https://auth-v0.sphere.io/oauth/token?grant_type=client_credentials&scope=manage_project%3Aorderjoy-85
09-10 12:39:29.383  24611-24662/com.spheretest I/System.out﹕ 12:39:29.383 [New I/O worker #1] DEBUG c.n.h.c.p.n.NettyAsyncHttpProvider -
09-10 12:39:29.383  24611-24662/com.spheretest I/System.out﹕ Non cached request
09-10 12:39:29.383  24611-24662/com.spheretest I/System.out﹕ DefaultHttpRequest(chunked: false)
09-10 12:39:29.383  24611-24662/com.spheretest I/System.out﹕ POST /oauth/token?grant_type=client_credentials&scope=manage_project%3Aorderjoy-85 HTTP/1.1
09-10 12:39:29.383  24611-24662/com.spheretest I/System.out﹕ Host: auth-v0.sphere.io
09-10 12:39:29.383  24611-24662/com.spheretest I/System.out﹕ Content-Type: application/x-www-form-urlencoded
09-10 12:39:29.383  24611-24662/com.spheretest I/System.out﹕ Authorization: Basic SlI0STlQWTZmTU5HbG9JVWVsLWN6UEFPOkN1U2F4NmRCdHhfN0ZmWXNULUg2VUJvXzB6OXpEVGdR
09-10 12:39:29.383  24611-24662/com.spheretest I/System.out﹕ Connection: keep-alive
09-10 12:39:29.383  24611-24662/com.spheretest I/System.out﹕ Accept: */*
09-10 12:39:29.383  24611-24662/com.spheretest I/System.out﹕ User-Agent: NING/1.0
09-10 12:39:29.383  24611-24662/com.spheretest I/System.out﹕ [ 09-10 12:39:29.383 24611:24662 I/System.out ]
    using Channel
09-10 12:39:29.383  24611-24662/com.spheretest I/System.out﹕ [id: 0x04c9853c, /192.168.1.3:38556]
09-10 12:39:29.383  24611-24662/com.spheretest I/System.out﹕ [ 09-10 12:39:29.479 24856:24868 W/com.worklight.common.Logger ]
    com.worklight.common.Logger.setContext(Context) must be called to fully enable debug log capture.  Currently, the 'capture' flag is set but the 'context' field is not.  This warning will only be printed once.
09-10 12:39:30.824  24611-24663/com.spheretest I/System.out﹕ 12:39:30.823 [New I/O worker #2] DEBUG c.n.h.c.p.n.NettyAsyncHttpProvider -
09-10 12:39:30.824  24611-24663/com.spheretest I/System.out﹕ [ 09-10 12:39:30.824 24611:24663 I/System.out ]
    Request DefaultHttpRequest(chunked: false)
09-10 12:39:30.824  24611-24663/com.spheretest I/System.out﹕ POST /oauth/token?grant_type=client_credentials&scope=manage_project%3Aorderjoy-85 HTTP/1.1
09-10 12:39:30.824  24611-24663/com.spheretest I/System.out﹕ Host: auth-v0.sphere.io
09-10 12:39:30.824  24611-24663/com.spheretest I/System.out﹕ Content-Type: application/x-www-form-urlencoded
09-10 12:39:30.824  24611-24663/com.spheretest I/System.out﹕ Authorization: Basic SlI0STlQWTZmTU5HbG9JVWVsLWN6UEFPOkN1U2F4NmRCdHhfN0ZmWXNULUg2VUJvXzB6OXpEVGdR
09-10 12:39:30.824  24611-24663/com.spheretest I/System.out﹕ Connection: keep-alive
09-10 12:39:30.824  24611-24663/com.spheretest I/System.out﹕ Accept: */*
09-10 12:39:30.824  24611-24663/com.spheretest I/System.out﹕ User-Agent: NING/1.0
09-10 12:39:30.824  24611-24663/com.spheretest I/System.out﹕ [ 09-10 12:39:30.824 24611:24663 I/System.out ]
    Response DefaultHttpResponse(chunked: true)