Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build process failed - :app:dexDebug FAILED #378

Closed
Dudyboy opened this issue Jul 11, 2016 · 22 comments
Closed

Build process failed - :app:dexDebug FAILED #378

Dudyboy opened this issue Jul 11, 2016 · 22 comments

Comments

@Dudyboy
Copy link

Dudyboy commented Jul 11, 2016

I init new react-native project and I wanted to include react-native-maps, but it shows me this error.

:app:dexDebug
Unknown source file : UNEXPECTED TOP-LEVEL EXCEPTION:
Unknown source file : com.android.dex.DexException: Multiple dex files define Landroid/support/v7/appcompat/R$anim;
Unknown source file :   at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:596)
Unknown source file :   at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:554)
Unknown source file :   at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:535)
Unknown source file :   at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)
Unknown source file :   at com.android.dx.merge.DexMerger.merge(DexMerger.java:189)
Unknown source file :   at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:502)
Unknown source file :   at com.android.dx.command.dexer.Main.runMonoDex(Main.java:334)
Unknown source file :   at com.android.dx.command.dexer.Main.run(Main.java:277)
Unknown source file :   at com.android.dx.command.dexer.Main.main(Main.java:245)
Unknown source file :   at com.android.dx.command.Main.main(Main.java:106)

:app:dexDebug FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:dexDebug'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/usr/lib/jvm/java-8-oracle/bin/java'' finished with non-zero exit value 2

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

BUILD FAILED

I had to add /lib at the end in projectDir in android/settings.gradle

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

I do not know, what am I doing wrong. I am sure, that problem is in somewhere in react-native-maps module, because it was the last, what I installed from npm and then I wanted to build and it shows me error.

Dependencies:

"apsl-react-native-button": "^2.5.0",
    "axios": "^0.12.0",
    "buffer": "^4.7.0",
    "install": "^0.8.1",
    "lodash": "^4.13.1",
    "npm": "^3.10.5",
    "react": "15.2.1",
    "react-dom": "^15.2.1",
    "react-motion": "^0.4.4",
    "react-native": "0.29.0",
    "react-native-animatable": "^0.6.1",
    "react-native-button": "^1.6.0",
    "react-native-camera": "github:lwansbrough/react-native-camera",
    "react-native-carousel": "^0.8.0",
    "react-native-dismiss-keyboard": "^1.0.0",
    "react-native-drawer": "^2.2.6",
    "react-native-fit-image": "^1.3.2",
    "react-native-gifted-spinner": "0.0.5",
    "react-native-keyboard-spacer": "^0.3.0",
    "react-native-maps": "^0.7.1",
    "react-native-orientation": "^1.17.0",
    "react-native-responsive-image": "^1.3.0",
    "react-native-router-flux": "^3.31.0",
    "react-native-simple-store": "^1.0.1",
    "react-native-spring-carousel": "^0.3.4",
    "react-native-vector-icons": "^2.0.3",
    "react-redux": "^4.4.5",
    "redux": "^3.5.2",
    "redux-form": "^5.3.1",
    "redux-promise": "^0.5.3",
    "redux-thunk": "^2.1.0"

Thanks for help.

@agumack
Copy link

agumack commented Jul 11, 2016

i have same problem :(

@texas697
Copy link

not sure why but if you go into android and do a ./gradlew clean it solves the issue

@sayedatif
Copy link

can you comment your app/build.gradle file? so i can help you . Is your simulator or physical device connected while building app?

@agumack
Copy link

agumack commented Jul 12, 2016

yep. i solved by: cd android/ && ./gradlew clean && cd .. && react-native run-android

@magrinj
Copy link

magrinj commented Jul 12, 2016

Not working for me, same error... :/

@Dudyboy
Copy link
Author

Dudyboy commented Jul 13, 2016

I try to reproduce my work. Maybe something will help you identify, what am I doing wrong. (not just me like I see). I build on real device Samsung J5 Android 5.1.1.

react-native init test2
cd test2
react-native run-android
adb reverse tcp:8081 tcp:8081
react-native start

Everything works well, but this is clean RN0.29. Then

npm install --save react-native-maps
sudo rnpm link react-native-maps

Then I add Google Maps key to AndroidManifest.xml. Point 4 in installation instructions. Then

react-native run-android

First false:

$ react-native run-android
Starting JS server...
Building and installing the app on the device (cd android && ./gradlew installDebug...

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' not found.

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

BUILD FAILED

This false was fixed like I wrote in first comment with add /lib at the end in projectDir in android/settings.gradle. Then

:app:dexDebug
Unknown source file : UNEXPECTED TOP-LEVEL EXCEPTION:
Unknown source file : com.android.dex.DexException: Multiple dex files define Landroid/support/v7/appcompat/R$anim;
Unknown source file :   at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:596)
Unknown source file :   at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:554)
Unknown source file :   at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:535)
Unknown source file :   at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)
Unknown source file :   at com.android.dx.merge.DexMerger.merge(DexMerger.java:189)
Unknown source file :   at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:502)
Unknown source file :   at com.android.dx.command.dexer.Main.runMonoDex(Main.java:334)
Unknown source file :   at com.android.dx.command.dexer.Main.run(Main.java:277)
Unknown source file :   at com.android.dx.command.dexer.Main.main(Main.java:245)
Unknown source file :   at com.android.dx.command.Main.main(Main.java:106)

:app:dexDebug FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:dexDebug'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/usr/lib/jvm/java-8-oracle/bin/java'' finished with non-zero exit value 2

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

BUILD FAILED

I fixed this with texas697 idea, so thumbs up for him.

$ ./gradlew clean
:app:clean
:react-native-maps:clean

BUILD SUCCESSFUL

Total time: 1.47 secs

Then

react-native run-android
adb reverse tcp:8081 tcp:8081
react-native start

Build process success, but shows blank view and false in console.

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

import React, { Component } from 'react';
import {
  AppRegistry,
  StyleSheet,
  Text,
  View,
    Dimensions
} from 'react-native';
import MapView from 'react-native-maps/components/MapView';

let { width, height } = Dimensions.get('window');

const ASPECT_RATIO = width / height;
const LATITUDE = 37.78825;
const LONGITUDE = -122.4324;
const LATITUDE_DELTA = 0.0922;
const LONGITUDE_DELTA = LATITUDE_DELTA * ASPECT_RATIO;

class test2 extends Component {
  render() {
    return (
      <View style={styles.container}>
          <MapView
              ref="map"
              style={styles.map}
              initialRegion={{
                  latitude: LATITUDE,
                  longitude: LONGITUDE,
                  latitudeDelta: LATITUDE_DELTA,
                  longitudeDelta: LONGITUDE_DELTA
              }}
          />
      </View>
    );
  }
}

const styles = StyleSheet.create({
    container: {
        position: 'absolute',
        top: 0,
        left: 0,
        right: 0,
        bottom: 0,
        justifyContent: 'flex-start',
        alignItems: 'center'
    },
    map: {
        position: 'absolute',
        top: 0,
        left: 0,
        right: 0,
        bottom: 0
    }
});

AppRegistry.registerComponent('test2', () => test2);

I think somebody wrote about this issue, but not for Android, but IOS. I did not test it on IOS.

false

Thanks for help.

@Dudyboy
Copy link
Author

Dudyboy commented Jul 14, 2016

My last console error in previous comment was fixed by https://github.com/lelandrichardson/react-native-maps/issues/375

Thank you very much everybody.

@ninjz
Copy link

ninjz commented Sep 29, 2016

well what i did to get past this was react-native unlink react-native-maps && react-native link react-native-maps guess when i linked withn rnpm previously it didn't do it properly..?

@minhchu
Copy link

minhchu commented Oct 31, 2016

texas's solution works for me

@ghost
Copy link

ghost commented Nov 12, 2016

texas's thanks works fine

@ujwal-setlur
Copy link

Yes, this worked for me too.

cd android
./gradlew clean

cd ..
react-native run-android

Any idea why this is?

@dinithminura
Copy link

./gradlew clean not worked for me 😞 but,
I remove :react-native-maps from build.gradle and add
...
dependencies {
...
compile 'com.airbnb.android:react-native-maps:0.7.1'
}
This one work for me 🎉 , Thanks for the solution @yozi-developer on #288

@FauzyAbdan
Copy link

./gradlew clean works for me

@jiteshrai
Copy link

Yes, Its working cd android/ && ./gradlew clean && cd .. && react-native run-android
I have solved my problem by above command.

@ozzyknox
Copy link

Resolved my problem too. Thanks for the help.

@sibelius
Copy link

try this on build.gradle

compile (project(':react-native-maps')) {
        exclude group: "com.google.android.gms"
    }

@kidmysoul
Copy link

all above donot work for me. I solved this when i noticed that i used "com.google.android.gms:play-services-*******" at several places(airbnb use it like :play-services-maps***** ) and they have multipile version. I changed the version to the same one and my app build worked

@alvelig
Copy link
Contributor

alvelig commented Dec 12, 2017

I recently made a fresh example build.
https://github.com/alvelig/react-native-maps-example.
Try to check it out or build through the README.MD. If it does not help, let me know.

@alvelig alvelig closed this as completed Dec 12, 2017
@jabranLmhani
Copy link

I guess the solution is to unlink react-native-maps ( react-native unlink react-native-maps)

@NithinKulal
Copy link

compile (project(':react-native-maps')) {
        exclude group: "com.google.android.gms"
    }

I'm new to react native, Where should I add this..?

@Darkensses
Copy link

I'm using react-native-maps and my issue was Execution failed for task ':app:mergeDexDebug'.
I solved by editing the app/build.gradle:

android {
    defaultConfig {
        // ...
        multiDexEnabled true
    }
    // ...
}

@AhmedHamedTN
Copy link

open your app in android studio .. let it sychronize gradle and update
npm start
npx react-native run android
voilà, this worked for me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests