更新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句若不加会报错

相关推荐
雮尘1 天前
手把手带你玩转Android gRPC:一篇搞定原理、配置与客户端开发
android·前端·grpc
ktl1 天前
Android 编译加速/优化 80%:一个文件搞定,零侵入零配置
android
alexhilton2 天前
使用FunctionGemma进行设备端函数调用
android·kotlin·android jetpack
冬奇Lab2 天前
InputManagerService:输入事件分发与ANR机制
android·源码阅读
张小潇2 天前
AOSP15 Input专题InputManager源码分析
android·操作系统
RdoZam2 天前
Android-封装基类Activity\Fragment,从0到1记录
android·kotlin
奥陌陌2 天前
android 打印函数调用堆栈
android
用户985120035832 天前
Compose Navigation 3 深度解析(二):基础用法
android·android jetpack
恋猫de小郭2 天前
Android 官方正式官宣 AI 支持 AppFunctions ,Android 官方 MCP 和系统级 OpenClaw 雏形
android·前端·flutter
黄林晴2 天前
Android 17 Beta 2,隐私这把锁又拧紧了
android