0

I've been trying to use @CommonsWare's answer over here to make an Android project (in Eclipse ADT) which I can share without giving all my code to people I share it with (the code has proprietary stuff to connect to our servers and we don't want to make it easy for people to connect to our servers without this component).

My project is currently a simple control (a button) which when pressed will do some stuff, including playing a tone and sending information to our server (there's an interface for the user to provide the information).

As a normal included library project it works well, and I can put most of the logic in a separate JAR I made without any resources in yet another project. But ideally I would like to have the entire code (the button onClick method etc) also wrapped up away from prying eyes and only leave the actual resources open (since I understand that is unavoidable)

I may have misunderstood what Mark wrote in his answer but what I did was build the project, then select "Export", select "Java|JAR File", then select inside the working project the bin directory and the classes underneath that I want to export (also some JARs under "libs"). The classes I chose from "bin" seem to be there in the JAR but packed inside a second JAR like so:

JAR
 |
META-INF
libs
bin----
       |
     R.txt
     jarlist.cache
     myprojectname.jar
     AndroidManifest.xml

(The classes referring to the button are inside "myprojectname.jar") When I import he project (using the main outsde JAR and no source code as suggested in the solution) my main project does not recognize the button type.

Anyone know what I am doing wrong?

Unfortunately I cannot work with an AAR as I have to be compatible with Eclipse users for now.

Community
  • 1
  • 1
Kibi
  • 1,860
  • 1
  • 29
  • 39
  • "Unfortunately I cannot work with an AAR as I have to be compatible with Eclipse users for now" -- I'd get rid of the resources. Lacking that, I'd create an AAR, then [convert the AAR into an Eclipse-compatible Android library project](http://commonsware.com/blog/2014/07/03/consuming-aars-eclipse.html) and hope it holds up. – CommonsWare Feb 23 '15 at 22:39
  • Thank you @CommonsWare - do you want to put that as an answer (the bit referencing your dearr post) and I will accept it? Taking out the resources is not possible right now. – Kibi Feb 23 '15 at 23:17

1 Answers1

1

Nowadays, I would focus on the AAR as the unit of reuse. Your challenge then is getting Eclipse users to be able to consume the AAR. For that, there are three possibilities that I know of:

  1. If they are using the Maven for Android Eclipse plugin, my understanding is that it can work with AAR files, though I have not tried this.

  2. Andmore (the long-term Eclipse-for-Android successor) will hopefully support AARs natively.

  3. You can convert an AAR into a regular Android library project, as an AAR is mostly just a ZIP archive. This Stack Overflow answer provides the recipe (at least, one that worked in 2014), and this blog post of mine outlines a deaar Ruby script that automates the conversion. Note that I have not played with this since last summer, and while I am not aware of any AAR format changes that would break the recipe or script, as the saying goes, YMMV.

Community
  • 1
  • 1
CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491