【问题标题】:react-native-sqlite-storage Undefined is not an object (evaluating 'NativeModules["SQLite"][method]')react-native-sqlite-storage Undefined 不是对象(评估 'NativeModules["SQLite"][method]')
【发布时间】:2018-04-30 18:04:29
【问题描述】:

react-native-sqlite-storage Undefined 不是对象(评估 'NativeModules["SQLite"][method]')

使用 react-native-sqlite-storage 时出现此错误。我正在使用 Expo 来测试我的 react-native 应用程序。

import SQLite from 'react-native-sqlite-storage';
SQLite.DEBUG(true);
SQLite.enablePromise(true);
let db = SQLite.openDatabase(DataAccess.dbName, DataAccess.dbVersion, "Test Database", 200000, DataAccess.openCB, DataAccess.errorCB);

【问题讨论】:

    标签: react-native sqlite storage


    【解决方案1】:

    您可能会在 android/app/src/main/java/com//MainApplication.java 中添加所有内容,如https://github.com/andpor/react-native-sqlite-storage 中所述 如果你不添加:

    import org.pgsqlite.SQLitePluginPackage; // Add import
    
    public class MainApplication extends Application implements ReactApplication { 
    ...
    
        @Override
        protected List<ReactPackage> getPackages() {
            return Arrays.<ReactPackage>asList(
                    new SQLitePluginPackage(),   // register SQLite Plugin here
                    new MainReactPackage()
        );
    }
    

    如果你这样做了,那么再重建一次项目,它应该可以工作。

    【讨论】:

      【解决方案2】:

      尝试不使用expo,这解决了我的问题。

      【讨论】:

        【解决方案3】:

        对于 React Native 版本 > 0.60,以下步骤对我有帮助:

        cd <PATH_TO_PROJECT>/ios
        pod install
        

        【讨论】:

          猜你喜欢
          • 2022-06-28
          • 2016-10-14
          • 2022-01-23
          • 2017-11-05
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2021-12-23
          相关资源
          最近更新 更多