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

前端 未结 3 1711
[愿得一人]
[愿得一人] 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:14

    Working fine after downgrading from react-native-maps@0.7.1 to react-native-maps@0.4.2

    I am using react-native@0.29.0

    Here is my settings:

    android/app/build.gradle

    dependencies {
        compile project(':react-native-maps')
    }
    

    android/settings.gradle

    include ':react-native-maps'
    project(':react-native-maps').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-maps/android')
    

    MainApplication.java

    package com.package;
    
    import android.app.Application;
    import android.util.Log;
    
    import com.facebook.react.ReactApplication;
    import com.facebook.react.ReactInstanceManager;
    import com.facebook.react.ReactNativeHost;
    import com.facebook.react.ReactPackage;
    import com.facebook.react.shell.MainReactPackage;
    
    import java.util.Arrays;
    import java.util.List;
    
    import com.AirMaps.AirPackage; // <- Add this line
    import com.i18n.reactnativei18n.ReactNativeI18n;
    import com.oblador.vectoricons.VectorIconsPackage;
    
    public class MainApplication extends Application implements ReactApplication {
    
      private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
        @Override
        protected boolean getUseDeveloperSupport() {
          return BuildConfig.DEBUG;
        }
    
        @Override
        protected List<ReactPackage> getPackages() {
          return Arrays.<ReactPackage>asList(
              new AirPackage(), // <- Add this line
              new MainReactPackage(),
              new ReactNativeI18n(),
              new VectorIconsPackage()
          );
        }
      };
    
      @Override
      public ReactNativeHost getReactNativeHost() {
          return mReactNativeHost;
      }
    }
    

    AndroidManifest.xml

    <application
          android:name=".MainApplication"
          android:allowBackup="true"
          android:label="@string/app_name"
          android:icon="@mipmap/ic_launcher"
          android:theme="@style/AppTheme">
          <!--reference your google_map_id-->
          <meta-data
            android:name="com.google.android.geo.API_KEY"
            android:value="@string/google_map_id"/>
        </application>
    
    0 讨论(0)
  • 2020-12-31 02:28

    I was following instructions from:

    https://github.com/airbnb/react-native-maps/blob/master/docs/installation.md

    I noted that android/settings.gradle should point to react-native-maps/lib/android as below:

    include ':react-native-maps'
    project(':react-native-maps').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-maps/lib/android')
    
    0 讨论(0)
  • 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<ReactPackage> getPackages() {
        return Arrays.<ReactPackage>asList(
        new MainReactPackage(),
        new MapsPackage(this) //here you must be write the param this
        );
      }
    }
    
    0 讨论(0)
提交回复
热议问题