@react-native-community/async-storage在Android上的手動link問題


PS C:\Users\linjin\Desktop\RN_APP> react-native link @react-native-community/async-storage
error Something went wrong while linking. Error: Expected "/* Begin ", "/* End ", "\"", or [A-Za-z0-9_.] but "<" found.
Please file an issue here: https://github.com/react-native-community/react-native-cli/issues
error Expected "/* Begin ", "/* End ", "\"", or [A-Za-z0-9_.] but "<" found.

 

解決方案

1.在項目結構android/settings.gradle中添加如下代碼:
rootProject.name = 'MyApp'

include ':app'

+ include ':@react-native-community_async-storage'
+ project(':@react-native-community_async-storage').projectDir = new File(rootProject.projectDir, '../node_modules/@react-native-community/async-storage/android')

 

2.在項目結構android/app/build.gradle添加如下dependencies:
dependencies {
  ...
+ implementation project(':@react-native-community_async-storage')
}

 

3.在MainApplication.java添加如下代碼:
package com.myapp;

+ import com.reactnativecommunity.asyncstorage.AsyncStoragePackage;

...

@Override
protected List<ReactPackage> getPackages() {
    return Arrays.<ReactPackage>asList(
        new MainReactPackage(),
+       new AsyncStoragePackage()    
    );
}


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM