改造两个版本
Retrofit two version
我得到了使用新 Retrofit 2 的模块,以及依赖于 Retrofit 1.9 的 aar 库
所以我的 build.gradle
dependencies
看起来像
compile project(':shop') // Module depend on retrofit2
compile 'com.squareup.retrofit:retrofit:1.9.0'
compile 'com.squareup.okhttp:okhttp:2.4.0'
compile 'com.squareup.okhttp:okhttp-urlconnection:2.4.0'
compile(name: 'dotpay-sdk', ext: 'aar') // Lib depend on retrofit1.9
然而,当我从 lib 调用方法时,我最有可能从 RestAdapter
.
得到 NoClassDefFoundError
是否有使用相同库版本的选项?
如果没有 Retrofit 的新版本,在同一个项目中使用这两个库并不容易,因为它们会导致冲突,因为它们具有相同的包。在最终版本中,Retrofit 和 OkHttp 将附带版本包。您可以在这里阅读更多相关信息:http://jakewharton.com/java-interoperability-policy-for-major-version-updates/
如果您真的需要同时使用这两个版本,那么您可以使用一些替代方案存在问题:https://github.com/square/retrofit/issues/1152
我得到了使用新 Retrofit 2 的模块,以及依赖于 Retrofit 1.9 的 aar 库
所以我的 build.gradle
dependencies
看起来像
compile project(':shop') // Module depend on retrofit2
compile 'com.squareup.retrofit:retrofit:1.9.0'
compile 'com.squareup.okhttp:okhttp:2.4.0'
compile 'com.squareup.okhttp:okhttp-urlconnection:2.4.0'
compile(name: 'dotpay-sdk', ext: 'aar') // Lib depend on retrofit1.9
然而,当我从 lib 调用方法时,我最有可能从 RestAdapter
.
NoClassDefFoundError
是否有使用相同库版本的选项?
如果没有 Retrofit 的新版本,在同一个项目中使用这两个库并不容易,因为它们会导致冲突,因为它们具有相同的包。在最终版本中,Retrofit 和 OkHttp 将附带版本包。您可以在这里阅读更多相关信息:http://jakewharton.com/java-interoperability-policy-for-major-version-updates/
如果您真的需要同时使用这两个版本,那么您可以使用一些替代方案存在问题:https://github.com/square/retrofit/issues/1152