Git Product home page Git Product logo

Comments (44)

notlose avatar notlose commented on June 20, 2024 414

i found the way to solve this problem.
just remove both 'build' folder in /android and /android/app
and build again with 'react-native run-android'

from react-native-gcm-android.

oney avatar oney commented on June 20, 2024 46

Try running ./gradlew app:dependencies in android directory in terminal

from react-native-gcm-android.

lynndylanhurley avatar lynndylanhurley commented on June 20, 2024 39

I just had to set multiDexEnabled = true. I don't really understand the implications, but people seem to discourage it. But it hasn't caused me any problems.

from react-native-gcm-android.

normanbanzon avatar normanbanzon commented on June 20, 2024 22

remove android folder run

react-native upgrade
then

react-native run-android

from react-native-gcm-android.

ravi-pandit14 avatar ravi-pandit14 commented on June 20, 2024 9

In app/build.gradle
add

defaultConfig{
...
multiDexEnabled true            //add this 
}

from react-native-gcm-android.

projetoarduino avatar projetoarduino commented on June 20, 2024 8

Work to me
react-native init projectwebrtc
cd projectwebrtc
npm i -s react-native-webrtc
react-native link react-native-webrtc

and in android/app/build.gradle add inside android section:

compileOptions {
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
}

from react-native-gcm-android.

froliveira94 avatar froliveira94 commented on June 20, 2024 7

If your minSdkVersion is lower then 21 you need to add multiDexEnabled = true on app/build.gradle

reference: https://developer.android.com/studio/build/multidex

from react-native-gcm-android.

Darkensses avatar Darkensses commented on June 20, 2024 7

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
    }
    // ...
}

from react-native-gcm-android.

MaheshNandam avatar MaheshNandam commented on June 20, 2024 3

Below lines works for me,

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

from react-native-gcm-android.

pushpanathank avatar pushpanathank commented on June 20, 2024 3

Refer this

android {
defaultConfig {
...
minSdkVersion 21
targetSdkVersion 26
multiDexEnabled true <---- Add this
}
...
}

https://stackoverflow.com/questions/46774530/execution-failed-for-task-apptransformclasseswithdexfordebug-in-react-native/46775061

from react-native-gcm-android.

hasnainalimj avatar hasnainalimj commented on June 20, 2024 3

I got the same error after using react-native-firebase SDK but after adding multiDexEnabled true inside android/app/build.gradle it's work for me Thanks @lynndylanhurley

from react-native-gcm-android.

1c7 avatar 1c7 commented on June 20, 2024 2

@notlose Solution work for me! ( I am using React Native 0.51 )
after remove both /android/build and /android/app/build
and re-run

cd android && ./gradlew assembleRelease

Success!

image

from react-native-gcm-android.

RassaLibre avatar RassaLibre commented on June 20, 2024 2

Had the same issue and the solution that worked for me was to add this to my build.gradle:

dexOptions { jumboMode true }

I also added dex.force.jumbo=true to my gradle.properties just to be sure. Seems like that did the magic.

from react-native-gcm-android.

julio-arcila avatar julio-arcila commented on June 20, 2024 2

In my case gradle was not in the environment variables. Check in terminal for the command gradle. If not recognized first you have to find the folder of gradle in configuration> settings> build of the android studio. The bin is added to the environment variables. Check again the gradle word in terminal later it runs ./gradlew in unix like systems from the terminal or .\ gradlew in the powershell of windows

from react-native-gcm-android.

nbastoWM avatar nbastoWM commented on June 20, 2024 1

Neither solution worked for me. I even removed the folder node_modules and did npm install again.

The full error:

UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Lcom/google/android/gms/internal/zzlv;
    at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:596)
    at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:554)
    at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:535)
    at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)
    at com.android.dx.merge.DexMerger.merge(DexMerger.java:189)
    at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:502)
    at com.android.dx.command.dexer.Main.runMonoDex(Main.java:334)
    at com.android.dx.command.dexer.Main.run(Main.java:277)
    at com.android.dx.command.dexer.Main.main(Main.java:245)
    at com.android.dx.command.Main.main(Main.java:106)


:app:transformClassesWithDexForDebug FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:transformClassesWithDexForDebug'.
> com.android.build.transform.api.TransformException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/bin/java'' finished with non-zero exit value 2

from react-native-gcm-android.

Noitidart avatar Noitidart commented on June 20, 2024 1

i found the way to solve this problem.
just remove both 'build' folder in /android and /android/app
and build again with 'react-native run-android'

@notlose thanks you! I struggled with this issue for two hours! This fixed it!

from react-native-gcm-android.

AliShhady avatar AliShhady commented on June 20, 2024 1

Error:Execution failed for task ':app:transformClassesWithDexBuilderForDebug'.

com.android.build.api.transform.TransformException: java.lang.IllegalStateException: Dex archives: setting .DEX extension only for .CLASS files
this error in my app
please help my

from react-native-gcm-android.

saeedjamshidi avatar saeedjamshidi commented on June 20, 2024 1

there's no need to remove "build" folders manually, just run "gradlew clean" command in android folder.

from react-native-gcm-android.

MaheshNandam avatar MaheshNandam commented on June 20, 2024 1

@sturmenta , it's in android/app/build.gradle

from react-native-gcm-android.

pke avatar pke commented on June 20, 2024 1

Thanks @Darkensses this worked. I wonder why the tooling does not enable this by default. But I guess it would prevent the app from running on very old Android devices?
With this setting it runs on my baseline Android 5 device without problems.

from react-native-gcm-android.

wdevon99 avatar wdevon99 commented on June 20, 2024 1

I just had to set multiDexEnabled = true. I don't really understand the implications, but people seem to discourage it. But it hasn't caused me any problems.

Thanks alot this worked! <3

from react-native-gcm-android.

notlose avatar notlose commented on June 20, 2024

i got the same error

from react-native-gcm-android.

notlose avatar notlose commented on June 20, 2024

rn 0.18.0

from react-native-gcm-android.

oney avatar oney commented on June 20, 2024

Good!

from react-native-gcm-android.

oney avatar oney commented on June 20, 2024

@nbastoWM
Can you share your project android/build.gradle and android/app/build.gradle

from react-native-gcm-android.

nbastoWM avatar nbastoWM commented on June 20, 2024

android/build.gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.3.1'
        classpath 'com.google.gms:google-services:1.4.0-beta3' // <- Add this line

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        mavenLocal()
        jcenter()
    }
}

android/app/build.gradle

apply plugin: "com.android.application"
apply plugin: 'com.google.gms.google-services'           // <- Add this line

apply from: "react.gradle"

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.1"

    defaultConfig {
        applicationId "com.wmmycityapp"
        minSdkVersion 16
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
        ndk {
            abiFilters "armeabi-v7a", "x86"
        }
    }
    buildTypes {
        release {
            minifyEnabled false  // Set this to true to enable Proguard
            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
        }
    }
}

dependencies {
    compile project(':react-native-google-analytics-bridge')
    compile fileTree(dir: "libs", include: ["*.jar"])
    compile "com.android.support:appcompat-v7:23.0.1"
    compile "com.facebook.react:react-native:0.17.+"
    compile project(':reactnativemapboxgl')
    compile project(':react-native-image-picker')
    compile project(':react-native-icons')
    compile project(':RNDeviceInfo')
    compile project(':react-native-contacts')
    compile project(':reactdate')

    compile "com.google.android.gms:play-services-gcm:8.1.0" // <- Add this line
    compile project(':RNGcmAndroid')                         // <- Add this line
    compile project(':react-native-system-notification')     // <- Add this line
}

from react-native-gcm-android.

nbastoWM avatar nbastoWM commented on June 20, 2024

I got it running by changing to:

compile "com.google.android.gms:play-services-gcm:8.3.0"

and

classpath 'com.google.gms:google-services:1.5.0-beta3'

from react-native-gcm-android.

oney avatar oney commented on June 20, 2024

Good! This solution will help many people that encounter this issue.

from react-native-gcm-android.

vikassy avatar vikassy commented on June 20, 2024

Yup ! I had faced the same issue, @nbastoWM solution worked pretty well. Can I update the Readme, if there is no compatible problem with play-services-gcm:8.3.0 and google-services:1.5.0-beta3 ?

from react-native-gcm-android.

oney avatar oney commented on June 20, 2024

@vikassy Please do it, thanks.

from react-native-gcm-android.

lynndylanhurley avatar lynndylanhurley commented on June 20, 2024

@nbastoWM - I made those changes, but I'm still only able to build the app with multiDexEnabled = true. I tried deleting both of my build folders and updating those two packages, but nothing seems to work except multiDexEnabled = true. Is there anything else that you may have done to get past this issue that you're leaving out?

from react-native-gcm-android.

pewh avatar pewh commented on June 20, 2024

@lynndylanhurley I'm not sure but you may try to delete android/app/src/main/assets/index.android.bundle. Let me know if it doesn't work.

from react-native-gcm-android.

dcflow avatar dcflow commented on June 20, 2024

I'm having the same issue. @lynndylanhurley Did you find any solutions?
@oney I tried to run the project without compile "com.google.android.gms:play-services-gcm:8.3.0" and classpath 'com.google.gms:google-services:1.5.0-beta3' but I still get the same error.
Do you think this has to do with the GCM libraries or with your code?

from react-native-gcm-android.

sarmad1995 avatar sarmad1995 commented on June 20, 2024

Try adding this in your android/app/build.gradle

configurations.all {
    resolutionStrategy.eachDependency { DependencyResolveDetails details ->
        if (details.getRequested().getGroup() == 'com.google.android.gms') {
            details.useVersion('9.8.0')
        }
    }
}

from react-native-gcm-android.

tb56zily avatar tb56zily commented on June 20, 2024

If java 8 or above is used then the problem is the libraries we use are incompatible with java 8. So to solve this add these two lines to build.gradle of your app and all sub modules if any. (Android studio clearly show how to do this in error message)

targetCompatibility = '1.7'
sourceCompatibility = '1.7'

from react-native-gcm-android.

sturmenta avatar sturmenta commented on June 20, 2024

@MaheshNandam In what file did you add those lines?

from react-native-gcm-android.

haizo-code avatar haizo-code commented on June 20, 2024

This worked for me after 4 hours of trying, by adding this to the module dependencies :

dependencies {
    configurations {
        all*.exclude group: 'com.android.support', module: 'support-v13'
    }
....
}

I hope this helps ๐Ÿ‘

from react-native-gcm-android.

rvilardo avatar rvilardo commented on June 20, 2024

If you are running on Terminal, check if the java version you are using is 1.8.
$ java -version
depending on gradle version you might have issues with java 1.8+
So, install the 1.8 version and change the JAVA_PATH to:
export JAVA_HOME="$(/usr/libexec/java_home -v 1.8)"
Make sure it's on your PATH as well

from react-native-gcm-android.

Vladus7 avatar Vladus7 commented on June 20, 2024

Please tell me where I need to enter the command 'react-native run-android' ?

from react-native-gcm-android.

GeronimoKTT avatar GeronimoKTT commented on June 20, 2024

i found the way to solve this problem.
just remove both 'build' folder in /android and /android/app
and build again with 'react-native run-android'

Very good!

from react-native-gcm-android.

prakashsaran avatar prakashsaran commented on June 20, 2024

If your minSdkVersion is lower then 21 you need to add multiDexEnabled = true on app/build.gradle

reference: https://developer.android.com/studio/build/multidex

help full for me

from react-native-gcm-android.

gvsakhil avatar gvsakhil commented on June 20, 2024

Deleting build folders didnot solve my issue

I need to delete some hidden folders too. Change settings to view hidden folders ( cmd +shift + . in mac)

Delete build, .gradlew, .idea, files with .iml in android folder
Delete build folder in android/app

Now go back and run react-native run-android

Good luck :)

from react-native-gcm-android.

ManalLiaquat avatar ManalLiaquat commented on June 20, 2024

Hey everyone! I am getting this error when generating release apk, in debug works fine

> Task :app:mergeDexRelease FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:mergeDexRelease'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
   > java.lang.OutOfMemoryError (no error message)

from react-native-gcm-android.

pranshuchittora avatar pranshuchittora commented on June 20, 2024

Just delete android/.gradle and 'android/app/build'.

Reasons for the issue.

  • Renaming the app folder.
  • Moving the project directory.
  • File System rewired

from react-native-gcm-android.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.