无法评估模块’react-native-maps’:找不到名称为’default’的配置

使用’react-native-maps’构建应用程序时出现问题

这是我的setting.gradle文件

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

android / app / build.gradle文件的依赖项

 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' } 

这是我使用MapsPackage()更新的MainActivity.java文件

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

即将发生的错误:

JS服务器已经运行。 在设备上构建和安装应用程序(cd android && gradlew.bat install Debug …

FAILURE:构建因exception而失败。

  • 出了什么问题:配置项目’:app’时出现问题。

    无法评估模块react-native-maps:找不到名称为“default”的配置。

  • 尝试:使用–stacktrace选项运行以获取堆栈跟踪。 使用–info或–debug选项运行以获取更多日志输出。

建筑失败

总时间:13.479秒无法在设备上安装应用程序,请阅读上述错误以获取详细信息。

我已经提到了给定链接中提到的所有程序https://github.com/lelandrichardson/react-native-maps/blob/master/docs/installation.md

我也看过https://github.com/lelandrichardson/react-native-maps/issues/288但无法解决错误

请帮助提前谢谢

Solutions Collecting From Web of "无法评估模块’react-native-maps’:找不到名称为’default’的配置"

错误发生在build.gradle文件的dependecies中试试这个:

 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' } 

删除行compile project(':react-native-maps')问题得到解决。 此行由rnpm link创建,但是是一个错误。

在MainActivity.java中应该是这样的:

 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 ); } } 

react-native-maps@0.7.1降级到react-native-maps@0.4.2后工作正常

我正在使用react-native@0.29.0

这是我的设置:

Android设备/应用/的build.gradle

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

安卓/ 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 getPackages() { return Arrays.asList( new AirPackage(), // < - Add this line new MainReactPackage(), new ReactNativeI18n(), new VectorIconsPackage() ); } }; @Override public ReactNativeHost getReactNativeHost() { return mReactNativeHost; } } 

AndroidManifest.xml中

     

我遵循以下指示:

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

注意到 android/settings.gradle应该指向react-native-maps/lib/android ,如下所示:

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