Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

版本说明和依赖冲突的解决方案 #56

Open
whataa opened this issue May 16, 2019 · 4 comments
Open

版本说明和依赖冲突的解决方案 #56

whataa opened this issue May 16, 2019 · 4 comments

Comments

@whataa
Copy link
Owner

whataa commented May 16, 2019

版本说明

androidx是Android官方推出的用于取代 android-support 的依赖库,相对support包,除了包名不同,其余完全一致。目前有些项目已经迁移到了x,但是也有部分项目由于历史原因无法适配,因此为防止引入Pandora导致重复依赖,提供了以下两种版本:

  • AndroidX
implementation 'com.github.whataa:pandora:androidx_v${RELEASE}'
  • Support
implementation 'com.github.whataa:pandora:v${RELEASE}'

具体区别就是版本号前面是否包含 androix_ 前缀。对于 no-op,由于没有引入对于的依赖库,因此不用区分。

依赖问题

1. support冲突

Pandora使用的findViewById 方法为 非强转类型 版本,需要compile-sdk至少为 26,所以对应的support-lib也需要至少为26.1.0

同时为了保持和官方版本同步,Pandora目前的compileSDK为 28,support版本为28.0.0,support包包含以下三种:

appcompat-v7
recyclerview-v7
design

部分项目可能与此配置不一致导致 gradle sync 失败,又由于一些原因无法修改自身的配置,因此你可以按以下来修改对Pandora的依赖方式:

compileSdkVersion 26

implementation ("com.github.whataa:pandora:v2.0.3") {
    exclude group: 'com.android.support'
}
implementation "com.android.support:appcompat-v7:26.1.0"
implementation "com.android.support:recyclerview-v7:26.1.0"
implementation "com.android.support:design:26.1.0"

当然如果你引入了其它依赖库也间接依赖了不同版本的support包,你也需要自行 exclude 进行排除防止冲突。

2. OKHttp依赖更新说明

Pandora依赖的OKHttp版本为 3.14.0,如果和项目产生依赖冲突,你可以按照以上方案进行重新指定版本:

implementation ("com.github.whataa:pandora:v2.1.0") {
    exclude group: 'com.squareup.okhttp3'
}
@whataa whataa pinned this issue May 16, 2019
@whataa whataa changed the title 提示:版本说明和依赖冲突的解决方案 版本说明和依赖冲突的解决方案 May 16, 2019
@ggggxiaolong
Copy link
Contributor

项目更新了OkHttp 4.0.1 exclude group: 'com.squareup.okhttp3'后还是报错

java.lang.NoSuchMethodError: No static method get(Lokhttp3/Response;)Lokhttp3/internal/http/StatusLine; in class Lokhttp3/internal/http/StatusLine; or its super classes (declaration of 'okhttp3.internal.http.StatusLine' appears in /data/app/com.tapplock.en.pad.debug-2/base.apk:classes3.dex)
at tech.linjiang.pandora.network.okhttp3.internal.huc.OkHttpURLConnection.getHeaderFields(OkHttpURLConnection.java:227)
at tech.linjiang.pandora.network.okhttp3.internal.huc.DelegatingHttpsURLConnection.getHeaderFields(DelegatingHttpsURLConnection.java:184)
at tech.linjiang.pandora.network.okhttp3.internal.huc.OkHttpsURLConnection.getHeaderFields(OkHttpsURLConnection.java:27)
at hh.a(:com.google.android.gms.dynamite_mapsdynamite@17455050@17.4.55 (040406-248795830):27)
at gx.b(:com.google.android.gms.dynamite_mapsdynamite@17455050@17.4.55 (040406-248795830):2)
at gy.a(:com.google.android.gms.dynamite_mapsdynamite@17455050@17.4.55 (040406-248795830):3)
at ha.a(:com.google.android.gms.dynamite_mapsdynamite@17455050@17.4.55 (040406-248795830):14)
at com.google.maps.api.android.lib6.drd.ak.a(:com.google.android.gms.dynamite_mapsdynamite@17455050@17.4.55 (040406-248795830):6)
at gc.a(:com.google.android.gms.dynamite_mapsdynamite@17455050@17.4.55 (040406-248795830):22)
at gc.run(:com.google.android.gms.dynamite_mapsdynamite@17455050@17.4.55 (040406-248795830):8)

@whataa
Copy link
Owner Author

whataa commented Jul 21, 2019

我看了下,OKHttp4.x开始已经用kotlin重写了,上面涉及到的方法调用方式已经改变,需要改下Pandora代码,所以无法简单的通过exclude来解决。但是考虑到不同项目依赖的OKHttp版本不一样,从兼容性方面来说,我还没找到一个好的解决方案

@ggggxiaolong
Copy link
Contributor

可以增加一个新的分支吗?pull request

@LikeDege
Copy link

我看了下,OKHttp4.x开始已经用kotlin重写了,上面涉及到的方法调用方式已经改变,需要改下Pandora代码,所以无法简单的通过exclude来解决。但是考虑到不同项目依赖的OKHttp版本不一样,从兼容性方面来说,我还没找到一个好的解决方案

@whataa 请问怎么解决

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants