agenthunt / react-native-mailcore

react native bindings for https://github.com/MailCore/mailcore2
27 stars 23 forks source link

How to build for android with com.android.tools.build:gradle:3.0.1 #7

Open angelos3lex opened 6 years ago

angelos3lex commented 6 years ago

Could you please guide me (also update docs) about how we can build react-native-mailcore for android using android tools version com.android.tools.build:gradle:3.0.1? I followed the instructions using both other options but i face following error:

What went wrong: Execution failed for task ':app:transformDexArchiveWithDexMergerForDebug'. com.android.build.api.transform.TransformException: com.android.dex.DexException: Multiple dex files define Lcom/reactlibrary/BuildConfig;

  • react-native version: 0.56.0

PS: Also tried adding multiDexEnabled true to defaultConfig, without any success->same error message occurs(even if i clean and rerun).

angelos3lex commented 6 years ago

Ok, i got it running keeping gradle version 3.0.1, by changing

minSdkVersion 19

to

minSdkVersion 21

and adding

multiDexEnabled true

to defaultConfig in app/build.gradle.. Also, i used the:

packagingOptions{
        pickFirst '**/libgnustl_shared.so'
    }

as mentioned in docs for version tools for gradle version 2.3.3. The problem is, that app crashes when i try to send email using my credentials through gmail smtp. Also, I do not get any logs by the catch method, just crashing. Tested on Android 6.0 API 23 only. Any ideas @agenthunt ?

agenthunt commented 6 years ago

Ok. Great. Does android log cat give more info about crash?

angelos3lex commented 6 years ago

I am not sure how can i see android logcat in my console, i tried with adb logcat *:S ReactNative:V ReactNativeJS:V and only thing shown was :

--------- beginning of crash

angelos3lex commented 6 years ago

@agenthunt ok found a way, this is the error i get:

09-06 10:42:17.021 4867-4867/com.inkotrack E/AndroidRuntime: FATAL EXCEPTION: main Process: com.inkotrack, PID: 4867 java.lang.UnsatisfiedLinkError: dlopen failed: /data/app/com.inkotrack-2/lib/x86/libMailCore.so: has text relocations at java.lang.Runtime.loadLibrary(Runtime.java:372) at java.lang.System.loadLibrary(System.java:1076) at com.libmailcore.MainThreadUtils.(MainThreadUtils.java:19) at com.libmailcore.MainThreadUtils.(MainThreadUtils.java:9) at com.libmailcore.MainThreadUtils.singleton(MainThreadUtils.java:14) at com.libmailcore.NativeObject.(NativeObject.java:42) at com.reactlibrary.RNMailCoreModule$1.run(RNMailCoreModule.java:41) at android.os.Handler.handleCallback(Handler.java:739) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:148) at android.app.ActivityThread.main(ActivityThread.java:5417) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

So this is happening in:

SMTPSession smtpSession = new SMTPSession();

angelos3lex commented 6 years ago

@agenthunt When i run the example app, it works fine, though if i change example app to targetSdkVersion 23 from targetSdkVersion 22, it crashes with same error. In my app, when i downgrade from targetSdkVersion 25 to 22, i face the following error in android logcat:

mcavaliere commented 6 years ago

@agenthunt Ping on this. Happening with a client app (Expo 30, ejected to ExpoKit), so looking for good workarounds.

anagar23 commented 5 years ago

I also got a crash on Android with Gradle 3.0.1 version

logs:

11-14 15:30:59.300 11360-11360/com.elth E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.elth, PID: 11360
    java.lang.UnsatisfiedLinkError: dlopen failed: cannot locate symbol "_ZSt24__throw_out_of_range_fmtPKcz" referenced by "/data/app/com.elth-1/lib/arm/libMailCore.so"...
        at java.lang.Runtime.loadLibrary0(Runtime.java:977)
        at java.lang.System.loadLibrary(System.java:1530)
        at com.libmailcore.MainThreadUtils.<init>(MainThreadUtils.java:19)
        at com.libmailcore.MainThreadUtils.<clinit>(MainThreadUtils.java:9)
        at com.libmailcore.MainThreadUtils.singleton(MainThreadUtils.java:14)
        at com.libmailcore.NativeObject.<clinit>(NativeObject.java:42)
        at com.reactlibrary.RNMailCoreModule$1.run(RNMailCoreModule.java:42)
        at android.os.Handler.handleCallback(Handler.java:751)
        at android.os.Handler.dispatchMessage(Handler.java:95)
        at android.os.Looper.loop(Looper.java:154)
        at android.app.ActivityThread.main(ActivityThread.java:6123)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:757)

Do we have any workaround for this?

angelos3lex commented 5 years ago

@anagar23 that's where i also couldn't find solution and made new bridge here

alexiskattan commented 3 years ago

@angelos3lex thank you for the smtp lib! do you know if there is a react native one for imap also?