React-native升级记录(2): aapt error: resource android:attr/fontVariationSettings not found

4 篇文章 0 订阅
4 篇文章 0 订阅

        某个Android版本某一天突然build失败了,很突然,相当突然,又没过改代码(这回是真的!!!)。

        有了之前查问题的经验,先去查issue list, 果然:https://github.com/facebook/react-native/issues/25293,里面提到了解决办法,迁移到AndroidX,但是咱还没准备好。继续,终于有一个without:根本原因是gms的某个升级导致的,所以咱可以把这个升级踢出代码。简书上有个同事的分析:https://www.jianshu.com/p/3730043c1fb8

OK,react-native run android 没问题了。可是,可是,可是高兴的太早了release版本还是出现报错了。


尝试了一下升级"react-native-device-info": "^2.1.2",
npm install react-native-device-info@2.1.2

这个时候编译出现了找不到符号。因为引入了28的东东,咋办:


暴力修改:node_modules/react-native-device-info/android/src/main/java/com/learnium/RNDeviceInfo/RNDeviceModule.java

390   @ReactMethod
391   public void isLocationEnabled(Promise p) {
392       boolean locationEnabled = false;
393
394       /*if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
395         LocationManager mLocationManager = (LocationManager) reactContext.getApplicationContext().getSystemService(Context.LOCATION_SERVICE);
396         locationEnabled = mLocationManager.isLocationEnabled();
397       } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {*/
398       if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
399         int locationMode = Settings.Secure.getInt(reactContext.getContentResolver(), Settings.Secure.LOCATION_MODE, Settings.Secure.LOCATION_MODE_OFF);
400         locationEnabled = locationMode != Settings.Secure.LOCATION_MODE_OFF;
401       } else {
402         String locationProviders = Settings.Secure.getString(reactContext.getContentResolver(), Settings.Secure.LOCATION_PROVIDERS_ALLOWED);
403         locationEnabled = !TextUtils.isEmpty(locationProviders);
404       }
405
406       p.resolve(locationEnabled);
407   }

 

在android/build.gradle添加:

subprojects {
        afterEvaluate {
            project ->
                if (project.hasProperty("android")) {
                    android {
                        compileSdkVersion = 27
                        buildToolsVersion = "27.0.3"
                    }
                }
        }
    }

PASS!!!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值