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

Unable to Build #2

Closed
ryanmcdermott opened this issue Nov 20, 2015 · 9 comments
Closed

Unable to Build #2

ryanmcdermott opened this issue Nov 20, 2015 · 9 comments

Comments

@ryanmcdermott
Copy link

I've been seeing this error:

UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Landroid/support/annotation/AnimRes;

Have you encountered this? The solutions on StackOverflow haven't seem to resolve it. http://stackoverflow.com/questions/26342444/multiple-dex-files-define-landroid-support-annotation-animres

@oney
Copy link
Owner

oney commented Nov 20, 2015

In android/app/build.gradle

android {
   ...
    dexOptions {
        javaMaxHeapSize "4g"
    }
    defaultConfig {
        ...
        multiDexEnabled true
    }

Please try adding these lines, may resolve the problem.

@oney
Copy link
Owner

oney commented Nov 20, 2015

Other lines in my android/app/build.gradle

dependencies {
    compile fileTree(dir: "libs", include: ["*.jar"])
    compile "com.android.support:appcompat-v7:23.0.1"
    compile "com.facebook.react:react-native:0.14.+"
   ...

@ryanmcdermott
Copy link
Author

Thanks that worked! Throw that in the README

@oney
Copy link
Owner

oney commented Nov 20, 2015

Good! Will do.

@oney oney closed this as completed Nov 20, 2015
@ghost
Copy link

ghost commented Nov 27, 2015

As multiDexEnable true is not recommended solution, maybe it would be better if changed the dependency from whole compile 'com.google.android.gms:play-services:8.1.0' to just the subset compile 'com.google.android.gms:play-services-gcm:8.1.0'. In my settings, it builds when you additionally add compile 'com.android.support:mediarouter-v7:23.0.+' to build.gradle of this project.

@nabati
Copy link

nabati commented Jan 6, 2016

Let me just add an additional piece here; I had the same issue as above and despite a lot of tinkering, I still got the same error.

What worked for me was to delete the android/app/build folder after changing any of my *.gradle files.

@jawadrehman
Copy link

if any of you has this issue, then do this
cd android
./gradlew clean

@lynndylanhurley
Copy link

@Herby - what is the issue with using multiDexEnable true? That is the only way I can get my app to build with this package.

@jiw0220
Copy link

jiw0220 commented Jul 24, 2016

https://facebook.github.io/react-native/docs/android-building-from-source.html
--> 4. Making 3rd-party modules use your fork

If you use 3rd-party React Native modules, you need to override their dependencies so that they don't bundle the pre-compiled library. Otherwise you'll get an error while compiling - Error: more than one library with package name 'com.facebook.react'.

Modify your android/app/build.gradle and replace compile project(':react-native-custom-module') with:

compile(project(':react-native-custom-module')) {
exclude group: 'com.facebook.react', module: 'react-native'
}

After run command

cd android

./gradlew clean

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

6 participants