React-native-mapbox-gl: react-native run-android BUILD FAILED

Created on 17 Nov 2018  路  6Comments  路  Source: nitaliano/react-native-mapbox-gl

Hi, I'm new to React Native and am trying to get Mapbox setup. I followed these directions and got Android Studio to sync and build successfully:
https://github.com/mapbox/react-native-mapbox-gl/blob/master/android/install.md

I also have an Android Emulator working just fine.

But when I open the command prompt, cd into the project folder and then run react-native run-android, the build fails:

Starting JS server...
Building and installing the app on the device (cd android && gradlew.bat installDebug)...
Starting a Gradle Daemon, 1 incompatible and 1 stopped Daemons could not be reused, use --status for details

Configure project :app
WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html

Configure project :mapbox-react-native-mapbox-gl
WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html
WARNING: Configuration 'provided' is obsolete and has been replaced with 'compileOnly'.
It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html
WARNING: The specified Android SDK Build Tools version (26.0.1) is ignored, as it is below the minimum supported version (27.0.3) for Android Gradle Plugin 3.1.4.
Android SDK Build Tools 27.0.3 will be used.
To suppress this warning, remove "buildToolsVersion '26.0.1'" from your build.gradle file, as each version of the Android Gradle Plugin now has a default version of the build tools.

FAILURE: Build failed with an exception.

  • What went wrong:
    Failed to capture snapshot of output files for task ':app:transformClassesWithDexBuilderForDebug' property 'streamOutputFolder' during up-to-date check.

    Could not read path 'C:\Users\jason\Documents\ReactProject\MapsProjectandroid\app\buildintermediates\transforms\dexBuilder\debug\50android\arch\lifecycle\livedata\core'.

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

  • Get more help at https://help.gradle.org

BUILD FAILED in 31s
35 actionable tasks: 3 executed, 32 up-to-date
Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:

https://facebook.github.io/react-native/docs/getting-started.html

Any idea what I'm doing wrong?

Most helpful comment

Problem solved! This REALLY should be mentioned in the installation instructions guys... someone helped me determine that app buid.gradle dependencies should be set up THIS WAY:

implementation project(':mapbox-react-native-mapbox-gl') {
    implementation ('com.squareup.okhttp3:okhttp:3.6.0') {
        force = true
    }
}

This solved my runtime problem and now Mapbox works great!

All 6 comments

I was able to get my app to build and install on my phone and AVD emulator in Android Studio, but the app immediately closes/crashes after it shows a blank white screen for less than a second. Again, this is using the Mapbox react native sample code. An empty react native project without Mapbox runs just fine. So it's a problem must be with the mapbox configuration. I have gone through the mapbox component installation instructions for Android 5 times today. What is causing the app to mysteriously encounter a runtime error and crash, immediately closing the app? There is no stack trace or troubleshooting information...

null | 聽
-- | --
Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'. | 聽
The specified Android SDK Build Tools version (27.0.3) is ignored, as it is below the minimum supported version (28.0.2) for Android Gradle Plugin 3.2.0. | 聽
Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'. | 聽
Configuration 'provided' is obsolete and has been replaced with 'compileOnly'. | 聽
The specified Android SDK Build Tools version (26.0.1) is ignored, as it is below the minimum supported version (28.0.2) for Android Gradle Plugin 3.2.0. | 聽

Not sure if any of these compiler warnings help? It is compiling successfully. But crashing on runtime...

Hi, have you got an access token and set it with:

Mapbox.setAccessToken('');
?

Yes. This is my code:

/**
 * Sample React Native App
 * https://github.com/facebook/react-native
 *
 * @format
 * @flow
 */

import React, {Component} from 'react';
import {StyleSheet, Text, View} from 'react-native';
import Mapbox from '@mapbox/react-native-mapbox-gl';

Mapbox.setAccessToken('pk.eyJ1IjoibG9zdGxhb3dhaSIsImEiOiJjam9rdWhkcGIwN3RrM3ZteHJ6cjNiaWtuIn0.zZ7VBsZQJkY8_D24ZH8ZAQ');


export default class App extends Component<{}> {
  render() {
    return (
      <View style={styles.container}>
        <Mapbox.MapView
            styleURL={Mapbox.StyleURL.Street}
            zoomLevel={15}
            centerCoordinate={[11.256, 43.770]}
            style={styles.container}>
        </Mapbox.MapView>
      </View>
    );
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
  },
});

Problem solved! This REALLY should be mentioned in the installation instructions guys... someone helped me determine that app buid.gradle dependencies should be set up THIS WAY:

implementation project(':mapbox-react-native-mapbox-gl') {
    implementation ('com.squareup.okhttp3:okhttp:3.6.0') {
        force = true
    }
}

This solved my runtime problem and now Mapbox works great!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lernerbot picture lernerbot  路  3Comments

kristfal picture kristfal  路  3Comments

glennverschooren picture glennverschooren  路  4Comments

Amalp picture Amalp  路  3Comments

lucasbento picture lucasbento  路  3Comments