更新weibo sdk(去掉so以适配Android 15的16K Page Size的版本)记录

1、修改模块的gradle

复制代码
implementation 'io.github.sinaweibosdk:core:13.6.1@aar'

改为

复制代码
implementation 'io.github.sinaweibosdk:core:13.10.4@aar'

同步、运行报错:

复制代码
Didn't find class "androidx.core.content.FileProvider"

解决:据此提示判断weibo sdk使用了androidx;我的工程很懒,一般只更新业务代码,但既然要用weibo sdk,所以也必须把那些import android.support.改为使用androidx了

2、引入androidx

复制代码
implementation 'androidx.core:core:1.13.1'

同步、运行报错:

复制代码
... contains AndroidX dependencies, but the `android.useAndroidX` property is not enabled ...

解决:就是说还要显式声明一下用androidx, 在gradle.properties增加2行

复制代码
android.useAndroidX=true
android.enableJetifier=true

同步、运行报错:

复制代码
Invoke-customs are only supported starting with Android O (--min-api 26)

解决:意即 minSdkVersion 至少26,所以要修改各模块build.gradle里的minSdkVersion

同步、运行报错:

复制代码
A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction

解决:Build - clean 再重新运行,报错:

复制代码
... is currently compiled against android-30.

      Recommended action: Update this project to use a newer compileSdk
      of at least 34, for example 34.

解决:修改各模块build.gradle里的compileSdkVersion的值,至少34

同步、运行报错:

复制代码
... No static method metafactory ...

解决:在模块build.gradle的android {} 里增加

复制代码
compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

同步、运行报错:

复制代码
Didn't find class "android.support.v4.content.FileProvider"

解决:这个是manifest里有

复制代码
android:name="android.support.v4.content.FileProvider"

需要改为

复制代码
android:name="androidx.core.content.FileProvider"

之后就没什么错了。

3、补充

3-1、中途可能还有一些错懒得记录了,一般是java中import 语句例如

复制代码
import android.support.v4.content.ContextCompat;

要转换为

复制代码
import androidx.core.content.ContextCompat;

这只是举例,有很多句,有自动转换的菜单;我是手工改的。

3-2、有个webview的语句报错:

setAppCacheEnabled(BOOL),没这个方法了...

暂时注释掉,以后有空解决。

3-3、xml里写死的android.support控件要找一下改掉

例如

复制代码
<android.support.v4.view.ViewPager ...

改为

复制代码
<androidx.viewpager.widget.ViewPager ...

3-4、gradle里旧support语句替换

复制代码
implementation 'com.android.support:support-v4:26.+'
implementation 'com.android.support:appcompat-v7:28.0.0'

替换为

复制代码
implementation 'androidx.core:core:1.13.1'
implementation 'androidx.appcompat:appcompat:1.7.0'
implementation(platform("org.jetbrains.kotlin:kotlin-bom:1.8.0"))

第3句若不加会报错

相关推荐
赏金术士7 小时前
Kotlin 习题集 · 高级篇
android·开发语言·kotlin
问心无愧05139 小时前
ctf show web 入门42
android·前端·android studio
没什么本事10 小时前
关于C# panel 添加lable问题 -- 明确X和Y 位置错误
android·java·c#
REDcker13 小时前
Android HWASan 详解:硬件标记原理、Clang 启用与排障实践
android·linux·debug·编译·clang·asan·hwasan
2501_9159090614 小时前
全面解析前端开发中常用的浏览器调试工具及其使用场景
android·ios·小程序·https·uni-app·iphone·webview
angerdream14 小时前
Android手把手编写儿童手机远程监控App之SQLite详解2
android
-SOLO-14 小时前
Python 爬取小红书 文章标题和内容 仅供学习
android·python·学习
ooseabiscuit14 小时前
Laravel5
android·php·laravel
科技道人15 小时前
Android 禁止使用ipv6 测试
android·禁用ipv6
AlexMaybeBot15 小时前
巧用 OpenClaw 为 Android 开发电脑瘦身
android·github·ai编程