morinel / gcmpush

Titanium Module for Android Push
Apache License 2.0
57 stars 35 forks source link

Error when module included #13

Closed mattlanham closed 8 years ago

mattlanham commented 9 years ago

When I include the module in my project I am getting the following error, can you let me know how I should go about resolving this?

[ERROR] :  Failed to run dexer:
[ERROR] :  
[ERROR] :  UNEXPECTED TOP-LEVEL EXCEPTION:
[ERROR] :  java.lang.IllegalArgumentException: already added: Lcom/google/android/gms/gcm/GoogleCloudMessaging$1;
[ERROR] :   at com.android.dx.dex.file.ClassDefsSection.add(ClassDefsSection.java:122)
[ERROR] :   at com.android.dx.dex.file.DexFile.add(DexFile.java:161)
[ERROR] :   at com.android.dx.command.dexer.Main.processClass(Main.java:685)
[ERROR] :   at com.android.dx.command.dexer.Main.processFileBytes(Main.java:634)
[ERROR] :   at com.android.dx.command.dexer.Main.access$600(Main.java:78)
[ERROR] :   at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:572)
[ERROR] :   at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:284)
[ERROR] :   at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:166)
[ERROR] :   at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)
[ERROR] :   at com.android.dx.command.dexer.Main.processOne(Main.java:596)
[ERROR] :   at com.android.dx.command.dexer.Main.processAllFiles(Main.java:498)
[ERROR] :   at com.android.dx.command.dexer.Main.runMonoDex(Main.java:264)
[ERROR] :   at com.android.dx.command.dexer.Main.run(Main.java:230)
[ERROR] :   at com.android.dx.command.dexer.Main.main(Main.java:199)
[ERROR] :   at com.android.dx.command.Main.main(Main.java:103)
[ERROR] :  1 error; aborting
TRACE  | titanium exited with exit code 1
ERROR  | Error: ti run exited with error code 1
    at ChildProcess.<anonymous> (/Users/matthewlanham/.appcelerator/install/5.0.4/package/node_modules/appc-cli-titanium/plugins/run.js:92:66)
    at ChildProcess.emit (events.js:98:17)
    at Process.ChildProcess._handle.onexit (child_process.js:809:12)
TRACE  | Sending exit signal to titanium process:  67493
m1ga commented 9 years ago

do you include other modules? It is a problem with the google services (jars inside the lib folder)

mattlanham commented 9 years ago

I have just tested a brand new, clean default alloy project with 5.0.2.GA SDK and it doesn't work, so I assume this must be an issue with this module, or it's compatibility with the new SDK?

morinel commented 9 years ago

Which Android version are you targeting? Please post the relevant parts of your tiapp.xml.

mattlanham commented 9 years ago

Turns out it was to do with the inclusion of google play services within this module, how would you get around this, seems a little crazy for it to clash on this? https://github.com/Sitata/titanium-google-analytics

m1ga commented 9 years ago

There are multiple bugs in jira about including multiple modules that bring their own version of the play-services (it gets tricky when you use maps and a different version). But you can use a stripped version of the play services, that only include the stuff you need. That mimizes the collisions.

E.g. Ti.GA has a pull request with a stripped version (https://github.com/benbahrenburg/Ti.GA/pull/6). It smaller too.

I guess you could use something like https://gist.github.com/dextorer/a32cad7819b7f272239b to just use the gcm stuff inside the services

morinel commented 9 years ago

Yes, please open a ticket for the other module to strip their version of the shipped Google Play Services jar. I've limited the version used in gcmpush already.

OTOH, it would be nice if there was a workaround for this provided by Appcelerator