ebay OAuth 2.0 库无法解析方法初始化()
ebay OAuth 2.0 library Cannot Resolve method initialize()
我想为 Android ebay 客户端写点东西。
但我正在努力解决第一个问题。
首先我用 IntelliJ
开始一个新的 Java Android 项目
我想使用这个库ebay-oauth-android-client
如 Git 所述:
Obtaining Library
This library is distributed via maven central repository. To use this
library, include the below as dependency in your project
dependencies {
compile 'com.ebay.auth:ebay-oauth-android-client:1.0.1'
}
我把这个片段放在我的 Gradle.build 中并用实现替换编译,因为编译已被删除。
到目前为止一切顺利。 gradle 导入这个库。
但下一步对我不起作用:
Application Setup
Before performing OAuth, the library should be initialized with details about your application from eBay developer portal. The library uses
Client ID. For details see Getting your OAuth credentials
Redirect Uri. for details see Getting your Redirect_Uri
Url encoded list of scopes. for details see Specifying OAuth scopes
Use these details in ApiSessionConfiguration.initialize() as shown below:
ApiSessionConfiguration.initialize(
apiEnvironment = ApiEnvironment.PRODUCTION,
apiConfiguration = ApiConfiguration(
<Client ID>,
<Redirect Uri>,
<space separated scopes>
)
)
所以我尝试调用 initialze:
my Code with error
但是当我尝试编译器时,编译器告诉我:
cannot find symbol method initialize(<null>)
当我跳转到 Class ApiSessionConfiguration 的声明时写着:
// IntelliJ API Decompiler stub source generated from a class file
// Implementation of methods is not available
package com.ebay.api.client.auth.oauth2.model
public final class ApiSessionConfiguration private constructor() {
public companion object {
private final val instance: com.ebay.api.client.auth.oauth2.model.ApiSessionConfiguration /* compiled code */
public final fun getInstance(): com.ebay.api.client.auth.oauth2.model.ApiSessionConfiguration { /* compiled code */ }
public final fun initialize(apiEnvironment: com.ebay.api.client.auth.oauth2.model.ApiEnvironment, apiConfiguration: com.ebay.api.client.auth.oauth2.model.ApiConfiguration): com.ebay.api.client.auth.oauth2.model.ApiSessionConfiguration { /* compiled code */ }
}
public final var apiConfiguration: com.ebay.api.client.auth.oauth2.model.ApiConfiguration? /* compiled code */
public final var apiEnvironment: com.ebay.api.client.auth.oauth2.model.ApiEnvironment? /* compiled code */
}
我真的不明白我做错了什么。在 Git 上的示例文件中 ApiSessionConfiguration.initalize() 被调用时没有任何错误。
我已经尝试过使缓存无效、清理构建并重新开始。
当我尝试从 Project Structure Librarys New from Maven repo 导入库时,它说:
没有文件被下载...
它不能用单个参数解析 initialize
方法吗?
您是否尝试过使用两个参数的 initialize
方法?
他们的示例应用有 2 个参数:
https://github.com/eBay/ebay-oauth-android-client/blob/master/sample/src/main/java/com/ebay/api/client/auth/MainActivity.kt#L37-L44
更新:
但是要从 java 访问 Kotlin 伴随对象函数,您需要调用 ApiSessionConfiguration.Companion.initialize
方法
我想为 Android ebay 客户端写点东西。
但我正在努力解决第一个问题。 首先我用 IntelliJ
开始一个新的 Java Android 项目我想使用这个库ebay-oauth-android-client
如 Git 所述:
Obtaining Library
This library is distributed via maven central repository. To use this library, include the below as dependency in your project
dependencies {
compile 'com.ebay.auth:ebay-oauth-android-client:1.0.1'
}
我把这个片段放在我的 Gradle.build 中并用实现替换编译,因为编译已被删除。
到目前为止一切顺利。 gradle 导入这个库。
但下一步对我不起作用:
Application Setup Before performing OAuth, the library should be initialized with details about your application from eBay developer portal. The library uses
Client ID. For details see Getting your OAuth credentials Redirect Uri. for details see Getting your Redirect_Uri Url encoded list of scopes. for details see Specifying OAuth scopes Use these details in ApiSessionConfiguration.initialize() as shown below:
ApiSessionConfiguration.initialize(
apiEnvironment = ApiEnvironment.PRODUCTION,
apiConfiguration = ApiConfiguration(
<Client ID>,
<Redirect Uri>,
<space separated scopes>
)
)
所以我尝试调用 initialze:
my Code with error
但是当我尝试编译器时,编译器告诉我:
cannot find symbol method initialize(<null>)
当我跳转到 Class ApiSessionConfiguration 的声明时写着:
// IntelliJ API Decompiler stub source generated from a class file
// Implementation of methods is not available
package com.ebay.api.client.auth.oauth2.model
public final class ApiSessionConfiguration private constructor() {
public companion object {
private final val instance: com.ebay.api.client.auth.oauth2.model.ApiSessionConfiguration /* compiled code */
public final fun getInstance(): com.ebay.api.client.auth.oauth2.model.ApiSessionConfiguration { /* compiled code */ }
public final fun initialize(apiEnvironment: com.ebay.api.client.auth.oauth2.model.ApiEnvironment, apiConfiguration: com.ebay.api.client.auth.oauth2.model.ApiConfiguration): com.ebay.api.client.auth.oauth2.model.ApiSessionConfiguration { /* compiled code */ }
}
public final var apiConfiguration: com.ebay.api.client.auth.oauth2.model.ApiConfiguration? /* compiled code */
public final var apiEnvironment: com.ebay.api.client.auth.oauth2.model.ApiEnvironment? /* compiled code */
}
我真的不明白我做错了什么。在 Git 上的示例文件中 ApiSessionConfiguration.initalize() 被调用时没有任何错误。
我已经尝试过使缓存无效、清理构建并重新开始。 当我尝试从 Project Structure Librarys New from Maven repo 导入库时,它说: 没有文件被下载...
它不能用单个参数解析 initialize
方法吗?
您是否尝试过使用两个参数的 initialize
方法?
他们的示例应用有 2 个参数: https://github.com/eBay/ebay-oauth-android-client/blob/master/sample/src/main/java/com/ebay/api/client/auth/MainActivity.kt#L37-L44
更新:
但是要从 java 访问 Kotlin 伴随对象函数,您需要调用 ApiSessionConfiguration.Companion.initialize
方法