Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

here is my setting.gradle file

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

dependencies of android/app/build.gradle file

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
    compile 'com.airbnb.android:react-native-maps:0.6.0'
}

Here is my MainActivity.java file updated with MapsPackage()

protected List<ReactPackage> getPackages() {
        return Arrays.<ReactPackage>asList(
            new MainReactPackage(),
            new MapsPackage()
        );
    }

error which is coming:

JS server already running. Building and installing the app on the device (cd android && gradlew.bat install Debug...

FAILURE: Build failed with an exception.

  • What went wrong: A problem occurred configuring project ':app'.

    Cannot evaluate module react-native-maps : Configuration with name 'default' n ot found.

  • Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 13.479 secs Could not install the app on the device, read the error above for details.

i have referred all the procedure mention in the given link https://github.com/lelandrichardson/react-native-maps/blob/master/docs/installation.md

i have also seen https://github.com/lelandrichardson/react-native-maps/issues/288 but could not resolve the error

please help Thanks in advance

like image 801
atif Avatar asked Jun 29 '16 09:06

atif


1 Answers

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
    );
  }
}
like image 176
Carlos Quiroga Avatar answered Nov 14 '22 23:11

Carlos Quiroga