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
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
);
}
}
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>
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')
来源:https://stackoverflow.com/questions/38095524/cannot-evaluate-module-react-native-maps-configuration-with-name-default-n