react native 无法使用support v4包api

    xiaoxiao2022-07-02  144

    版本:

     "react": "16.8.6",  "react-native": "0.59.8",

    这个ActivityCompat是属于v4包下的api,但是RN项目却无法调用,使用多种办法依然无法解决,包括在对应项目的gradle添加依赖

    implementation 'com.android.support:support-v4:28.0.0'

    依赖无效,不知道怎么回事~~最终把jar包下载过来,添加lib的依赖才解决了问题

    androidstudio添加依赖后会在这个目录缓存对应资源文件

    C:\Users\xxx\.gradle\caches\transforms-1\files-1.1\support-compat-28.0.0.aar\b45efbe48115f5396321f36453b90e70

    只需要在上图所示的jars目录里面把jar包添加至libs目录下,然后添加依赖即可

    虽然api能调用了,但是会产生新的错误

    > Android resource linking failed error: resource style/Theme.AppCompat.Light.NoActionBar (aka com.companyloans:style/Theme.AppCompat.Light.NoActionBar) not found. error: resource style/Theme.AppCompat.Light.Dialog (aka com.companyloans:style/Theme.AppCompat.Light.Dialog) not found. error: resource style/TextAppearance.Compat.Notification.Info (aka com.companyloans:style/TextAppearance.Compat.Notification.Info) not found. error: resource style/TextAppearance.Compat.Notification (aka com.companyloans:style/TextAppearance.Compat.Notification) not found. error: resource style/TextAppearance.Compat.Notification.Time (aka com.companyloans:style/TextAppearance.Compat.Notification.Time) not found. error: resource style/TextAppearance.Compat.Notification.Title (aka com.companyloans:style/TextAppearance.Compat.Notification.Title) not found. C:\Users\PJ-3\.gradle\caches\transforms-1\files-1.1\coordinatorlayout-28.0.0.aar\8a4a6226525cb71f1d4262e87ff047b3\res\values\values.xml: AAPT: error: style attribute 'attr/windowActionBar (aka com.companyloans:attr/windowAct ionBar)' not found. error: failed linking references.

    就是找不到资源,添加如下依赖解决这个错误

    implementation 'androidx.appcompat:appcompat:1.0.0-alpha1'

     

    最新回复(0)