React-native升級記錄(2): aapt error: resource android:attr/fontVariationSettings not found

        某個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 [email protected]

這個時候編譯出現了找不到符號。因爲引入了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!!!

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章