React Native Maps library

I have problems with installing react native maps library, when I type:

npm install react-native-maps --save

error shows:

react-native-maps error

dependencies:

"react": "15.3.2",  
"react-native": "0.36.0"

As Rishabh says, you should upgrade to the latest versions of react, react-native and react-native-maps.

Depending on how complex your project is, I often find the easiest way to upgrade is to create a brand new, clean project:

react-native init MyProjectName

and then install react-native maps (and another other dependencies)

npm install --save react-native-maps
react-native link

and then copy across all your Javascript source code into the new project.


看来我在build.gradle和settings.gradle中遇到了一些问题,纠正了这些部分,现在正在工作


You can upgrade it to following dependency

"react": "15.4.1",
"react-native": "^0.39.0"

To upgrade react native to newest version you can follow offical doc. I have used "Alternative" section mention in React native blog.

After upgrade your react native follow below steps:

  • Install react native map using following command npm install react-native-maps --save (for reference)
  • Use command react-native link to link react-native-maps resource with project
  • After linking to project make sure it's linked properly by checking at following files
  • Go to android/app/build.gradle and check following entry is there or not

    dependencies {
    compile project(':react-native-maps') compile fileTree(dir: "libs", include: ["*.jar"]) compile "com.android.support:appcompat-v7:23.0.1" compile "com.facebook.react:react-native:+" // From node_modules }

  • in android/settings.gradle react-native-maps project should be included

    include ':react-native-maps'
    project(':react-native-maps').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-maps/android')
    
  • In android/app/src/main/java/com//MainApplication.java react-native-maps package should be registered.

    import com.airbnb.android.react.maps.MapsPackage;
     ...
    @Override
    protected List<ReactPackage> getPackages() {
        return Arrays.<ReactPackage>asList(
                new MainReactPackage(),
                new MapsPackage()
        );
    }
    
  • go to android/app/src/main/AndroidManifest.xml add following under application tag.

  • Let me know if you still get error. Please share the important code as well.

    链接地址: http://www.djcxy.com/p/93884.html

    上一篇: 如何在使用SBT编译之前着色?

    下一篇: 反应本地地图库