sumup / sumup-android-sdk

Sample App for the SumUp Android SDK
Other
105 stars 28 forks source link

Remove or update Dagger #12

Closed ndmt closed 7 years ago

ndmt commented 8 years ago

Hello,

I have an issue with the SDK when I try to run Proguard.

Error:Execution failed for task ':app:transformClassesAndResourcesWithProguardForProdRelease'. > java.io.IOException: Can't write [/*****/app/build/intermediates/transforms/proguard/prod/release/jars/3/1f/main.jar] (Can't read [/*****/.gradle/caches/modules-2/files-2.1/com.squareup.dagger/dagger/1.2.2/e8f912ee19ad84958510883ea191135276b091f8/dagger-1.2.2.jar(;;;;;;**.class)] (Duplicate zip entry [dagger/a.class == dagger-1.2.2.jar:dagger/Lazy.class]))

I'm using dagger 2.+ and I think the dagger package doesn't like to be provided by an other dependency (dagger 1) when proguard is running.

Any solutions ?

Thanks.

konradfeketesumup commented 8 years ago

Hi, I apologise for the lateness of my reply on this channel. As stated by my colleague before in a private message, there is no workaround for this issue at the moment as both classes are in the respective core packages. Moving to Dagger 2 is on our roadmap however for now there is no scheduled release date. At the moment we only support Dagger 1. Best regards

xghita commented 7 years ago

Hello!! I have the same problem, it looks like sumup android sdk is incompatible with dagger 2.+. Do you know when it will have support for dagger2 ?

gk5885 commented 7 years ago

edit: looks like the build is not quite what I thought, but the gist of the answer is still the same

@konradfeketesumup, the workaround is to repackage Dagger within your SDK with something like the Maven shade plugin or JarJar. That will ensure that you're not pinning your users to a particular version chosen by your implementation.

ultrah commented 7 years ago

@gk5885 thank you for the suggestion, I gave this a try using JarJar, but I seem to be missing something. Maybe you can help me out?

My first try was to simply move everything in both dagger and dagger-compiler to a different package and manually edit META-INF/services/javax.annotation.processing.Processor to point to the correct sumup.dagger.internal.codegen.* package

rule dagger.** sumup.dagger.@1

This breaks injection though, the InjectAdapters are simply not generated. Any clue why or how to debug?

My seccond attempt was to only move the Annotations:

rule dagger.Lazy sumup.dagger.Lazy
rule dagger.MembersInjector sumup.dagger.MembersInjector
rule dagger.Module sumup.dagger.Module
rule dagger.Provides sumup.dagger.Provides
rule dagger.Provides$Type sumup.dagger.Provides$Type
rule dagger.internal sumup.dagger.internal
rule dagger.producers sumup.dagger.producers

This works and enables compatibility with Dagger 2 in the host app, but breaks compatibility with Dagger 1 as the rest of the files obviously are duplicate now.

Any hints on how to proceed?

gk5885 commented 7 years ago

I think it sounds like things are getting invoked in the wrong order. I would think that you'd want to invoke jarjar after the annotation processor runs, not before.

ultrah commented 7 years ago

Thanks, I'll try in this direction. I assume this is for the first of the two attempts that I made here?

Also I would assume that this is a common problem when using Dagger in a library... do you know of anyone else who has solved this issue and how?

vfoixcable commented 7 years ago

From upcoming sdk version 2.4.0, the sdk wont rely on any dagger version anymore

wusadurski commented 7 years ago

@vfoixcable @konradfeketesumup When are you planning to release sdk version 2.4.0?

vfoixcable commented 7 years ago

version 2.4.0 will be released end of week 37 / beginning of week 38!

vfoixcable commented 7 years ago

released: https://github.com/sumup/sumup-android-sdk/releases/tag/v2.4.0