0

I'm a Chinese developer, forgive my poor English expression please.

How to create an Android runnable jar file(an SDK)?

I'm developing an SDK, and need to make it runnable in other projects. But the layout/Xml files are not accessible when referenced in other projects, as the ids are changing in R file. so I abort the xml and create all the views with code. Besides I put the resources(e.g. the Images) under assets file in order to read them. That's my current way to deal with adk development problems but not perfect.

Could anyone give me some valuable advice, clue or the steps to create sdk if you know?

I'm still using ECLIPSE now.

Tony
  • 1
  • 1

2 Answers2

0

If you're using Android Studio:

  1. Select : File -> New -> New Module -> Android Library
  2. Create another project, and add this to the gradle file : compile project(':mylibrary')
  3. Gradle sync
  4. Run your sample project (not necessary)
  5. You'll see inside myLibrary project in path : build -> outputs -> aar -> myLibrary.arr file which is your sdk (used to be jar, now it's aar file in Android Studio)
Dus
  • 4,052
  • 5
  • 30
  • 49
  • But I want to seal the jar. Most third-party SDKs are obfuscated. Libraries are open-source. (Our sdk is related to payment, so I should take safety into consideration) – Tony Mar 30 '16 at 09:49
  • You haven't mentioned anything about obfouscation... I don't know how to do so in eclipse. Though, it's quite easy to obfuscate the code in Android Studio using minifyEnabled = true and proguard / maven definitions – Dus Mar 30 '16 at 14:11
  • Thank you ! After finishing the current project, I'll try AS. – Tony Mar 31 '16 at 02:24
0

You are looking to create an android library which can be used in other android projects. Checkout the tutsplus tutorial for it. It shows you how to handle different XML resources. Use ProGuard to obfuscate your android/java code. This answer describes how you can obfuscate android library project.

Community
  • 1
  • 1
Sourabh86
  • 744
  • 10
  • 18
  • But I want to seal the jar. Most third-party SDKs are obfuscated. Libraries are open-source. (Our sdk is related to payment, so I should take safety in to consideration) – Tony Mar 30 '16 at 09:48
  • Thank you very much! I'll try. This is really a good community because of people like you! – Tony Mar 31 '16 at 02:29