问题描述
使用"react-native-maps"构建应用程序时出现问题
A problem occured while building application with 'react-native-maps'
这是我的setting.gradle文件
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')
android/app/build.gradle文件的依赖性
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'
}
这是我用MapsPackage()更新的MainActivity.java文件
Here is my MainActivity.java file updated with MapsPackage()
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
new MapsPackage()
);
}
即将到来的错误
JS服务器已在运行.在设备上构建和安装应用程序(cd android&& gradlew.bat安装调试...
JS server already running.Building and installing the app on the device (cd android && gradlew.bat installDebug...
失败:构建失败,并出现异常.
FAILURE: Build failed with an exception.
-
出了什么问题:配置项目':app'时发生问题.
What went wrong:A problem occurred configuring project ':app'.
尝试:使用--stacktrace选项运行以获取堆栈跟踪.使用--info或--debug运行选项以获取更多日志输出.
Try:Run with --stacktrace option to get the stack trace. Run with --info or --debugoption to get more log output.
建立失败
总时间:13.479秒无法在设备上安装该应用,请阅读上面的错误以获取详细信息.
Total time: 13.479 secsCould not install the app on the device, read the error above for details.
我已参考给定链接 https://中提到的所有过程. github.com/lelandrichardson/react-native-maps/blob/master/docs/installation.md
我也看到了 https://github.com/lelandrichardson/react-native-maps/issues /288 ,但无法解决错误
i have also seen https://github.com/lelandrichardson/react-native-maps/issues/288 but could not resolve the error
请帮助预先感谢
推荐答案
错误在于build.gradle文件中的依赖关系,请尝试以下操作:
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'
}
删除行compile project(':react-native-maps')
,此问题已解决.这行是由rnpm link
创建的,但是是一个错误.
Deleting the line compile project(':react-native-maps')
the problem is resolved. This line is created by rnpm link
but is a bug.
在MainActivity.java中应该是这样的:
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
);
}
}
这篇关于无法评估模块"react-native-maps":找不到名称为"default"的配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!