cannot evaluate module 'react-native-maps' : Configuration with name 'default' not found

前端 未结 3 1783
[愿得一人]
[愿得一人] 2020-12-31 01:28

A problem occured while building application with \'react-native-maps\'

here is my setting.gradle file

include \':react-native-maps\'
project(\':reac         


        
3条回答
  •  忘掉有多难
    2020-12-31 02:34

    The error is in the dependecies in build.gradle file try with this:

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

    Deleting the line compile project(':react-native-maps') the problem is resolved. This line is created by rnpm link but is a bug.

    In MainActivity.java should be like this:

    package com.yourapp;   //<- put your app name
    import com.facebook.react.ReactActivity;
    import com.airbnb.android.react.maps.MapsPackage; //<- this line is important
    import com.facebook.react.ReactPackage;
    import com.facebook.react.shell.MainReactPackage;
    import java.util.Arrays;
    import java.util.List;
    public class MainActivity extends ReactActivity {
      @Override
      protected String getMainComponentName() {
        return "yourapp"; //<- put your app name
      }
      @Override
      protected boolean getUseDeveloperSupport() {
        return BuildConfig.DEBUG;
      }
      @Override
      protected List getPackages() {
        return Arrays.asList(
        new MainReactPackage(),
        new MapsPackage(this) //here you must be write the param this
        );
      }
    }
    

提交回复
热议问题