corymsmith / react-native-icons

Quick and easy icons in React Native
MIT License
1.14k stars 141 forks source link

Build failure on Android when adding project as compile target #150

Closed jlugner closed 8 years ago

jlugner commented 8 years ago

I'm getting a build error when adding react-native-icons as a compile target in my build.gradle file. I'm using react-native 0.14.2 The error:

:app:compileDebugJavaWithJavac
.../MainActivity.java:78: error: method onResume in class ReactInstanceManager cannot be applied to given types;
            mReactInstanceManager.onResume(this);
                                 ^
  required: Activity,DefaultHardwareBackBtnHandler
  found: MainActivity
  reason: actual and formal argument lists differ in length
1 error
:app:compileDebugJavaWithJavac FAILED
jonolock91 commented 8 years ago

I just had this error and fixed it by doing npm install again on my node packages, but I'm not sure what the cause of mine was (but I was using this icons module).

corymsmith commented 8 years ago

You may want to update React Native to 0.16.0 as well

Thanks, Cory Smith On Wed, Dec 9, 2015 at 7:14 AM, corymsmith/react-native-icons reply@reply.github.com wrote: I just had this error and fixed it by doing npm install again on my node packages, but I'm not sure what the cause of mine was (but I was using this icons module).

— Reply to this email directly or view it on GitHub [https://github.com/corymsmith/react-native-icons/issues/150#issuecomment-163249602] .[https://github.com/notifications/beacon/AAAck2x1vx1YHuOCvEDFrzSgq1jCaKt_ks5pOC7NgaJpZM4Gx4PF.gif]

jlugner commented 8 years ago

Reinstalling modules did not help unfortunately. Upgrading to 0.16.0 seems to be quite a hassle seeing as I'm quite far into development on this application? Should it work with earlier versions, or is it limited to 0.16.0?

corymsmith commented 8 years ago

Can you share a gist of your build.grade file?

Thanks, Cory Smith On Thu, Dec 10, 2015 at 2:53 AM, corymsmith/react-native-icons reply@reply.github.com wrote: Reinstalling modules did not help unfortunately. Upgrading to 0.16.0 seems to be quite a hassle seeing as I'm quite far into development on this application? Should it work with earlier versions, or is it limited to 0.16.0?

— Reply to this email directly or view it on GitHub [https://github.com/corymsmith/react-native-icons/issues/150#issuecomment-163560068] .[https://github.com/notifications/beacon/AAAck3XwU3xv6rwEV1ecf-6ZUDV8MiCvks5pOUMIgaJpZM4Gx4PF.gif]

jlugner commented 8 years ago

I can get a bit further in compiling if I change

mReactInstanceManager.onResume(this); 

to

mReactInstanceManager.onResume(this, this);   

However, the later version crashes with following exception:

:app:transformClassesWithDexForDebug

UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Lcom/facebook/infer/annotation/Assertions;
    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

Gist of my android/app/build.gradle: https://gist.github.com/Pungsnigel/7ebb1447920e3d366e54

corymsmith commented 8 years ago

I see the issue, your RN JS is out of sync with the RN Java library. You'll have to change: compile " com.facebook.react:react-native:0.14.+ " To: compile " com.facebook.react:react-native:0.16.+ "

Then make sure you restart the packager.

jlugner commented 8 years ago

Getting same error, regardless of which of above versions of MainActivity.java I use. Since I'm using react-native 0.14.2, should I really use compile " com.facebook.react:react-native:0.16.+ "?

corymsmith commented 8 years ago

I meant upgrade to RN 0.16.0 and ensure to update your .gradle file as well. The fact that you're MainActivity requires this with 2 parameters indicates that its pulling in newer Java code thats out of sync with the JS code.

mReactInstanceManager.onResume(this, this);

This was changed in this commit: https://github.com/facebook/react-native/commit/3dca8cf9fdd864b1359fc7276bf98cb154c3e360

jlugner commented 8 years ago

I'm only required to use two parameters to if I add compile project(':react-native-icons') to my build.gradle. Otherwise, it works just fine with one. I'll try to upgrade RN and see if that works better.

corymsmith commented 8 years ago

You can also try version 0.6.1 which uses React Native 14 if you don't want to upgrade, should work but no guarantees.

jlugner commented 8 years ago

By upgrading to RN 0.16, and enabling multidex(did not work without it, guide here: http://developer.android.com/tools/building/multidex.html), it seems to be working. Don't really know why I had to enable multidex, but I'll have to research it. Thanks for your help!

corymsmith commented 8 years ago

Multidex is required if you're app includes over 65,000 methods (including from included libs). I have it on multiple apps as well.

Thanks,

Cory Smith http://ca.linkedin.com/in/corysmith/ http:/twitter.com/smixx http://twitter.com/smixx

On Thu, Dec 10, 2015 at 8:52 AM, Jesper Persson notifications@github.com wrote:

By upgrading to RN 0.16, and enabling multidex(did not work without it, guide here: http://developer.android.com/tools/building/multidex.html), it seems to be working. Don't really know why I had to enable multidex, but I'll have to research it. Thanks for your help!

— Reply to this email directly or view it on GitHub https://github.com/corymsmith/react-native-icons/issues/150#issuecomment-163667664 .

jlugner commented 8 years ago

Great. Thanks for your answers. Closing, as everything seems to work now.

GantMan commented 8 years ago

Thanks guys! I went from 0.14 to 0.17 and this issue helped me get things working.

For others - Things to worry about.