Java Question Updating Library

barx

Well-Known Member
Licensed User
Longtime User
Hi

I wish to move lib(s) over to development in Android Studio. I have read through various posts on here giving a couple of conflicting views. Some say to compile with SLC, others show a method that uses .bat and JavaDoc. Does SLC have limits, or can it be used in all instances? which would be the prefered method going forward?

Also, 1 library (NotificationBuilder) required the support-v4 dependancy. I'm under the impression that the support file system has now been changed.
How would I reference it now? When do I use @DependsOn and #AdditionalJar.
Is it a case of one or the other?

Cheers
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
I don't think that Android Studio provides any benefit over Eclipse for libraries development.
SLC will work if the source code is under a folder named src. It doesn't matter how you write the code.

Also, 1 library (NotificationBuilder) required the support-v4 dependancy. I'm under the impression that the support file system has now been changed.
How would I reference it now? When do I use @DependsOn and #AdditionalJar.
You should add:
B4X:
@DependsOn(values={"com.android.support:support-v4"})
Another thing that you need to do (at least with Eclipse) is to reference the jar file. I use B4A to create the jar. See the end of this post: https://www.b4x.com/android/forum/t...add-aar-in-eclipse-project.67741/#post-429216
 

corwin42

Expert
Licensed User
Longtime User
I switched over to Android Studio with (almost) all my libraries. It was a big step and took some time to get everything to work.

Advantages for switching:
- You don't have to create .jar files for support libraries. Switching to a new version of the support library is just a change in the version number.
- Most third party libraries are provided as .aar. You can't use them in Eclipse. Again you have to manually create .jar files to create a wrapper. With AS you simply add the external project to your build.gradle file and you are ready to go.
- It is extremely easy to create libraries which use resources.

Disadvantages:
- Project setup in AS for B4A library development is more complicated. But once setup the workflow is very nice and fast.
- AS can't simply create .jar files from an Android Project. You have to create a "dummy" .jar and include the .aar in the @DependsOn.
- The Build system (gradle) in AS is very complex to use (but very powerful).

The switch to AS is not easy. It took me at least a whole week of learning new things until I got all set up. But I'm glad I did it. Maintaining the AppCompat library in Eclipse was a horror in the last days I used Eclipse. If I remember correctly there was a point I couldn't compile the AppCompat library against the newest support libraries anymore because I got errors and I did not understand what they caused.
 

DonManfred

Expert
Licensed User
Longtime User
You have to create a "dummy" .jar and include the .aar in the @DependsOn.
Can you post the way we need to go to create such an empty jar? I mean; where do i place the @DependsOn? If i add it to the library code which will be inside the AAR then i dont have any classes in the jar?

Or do you mean to add the DependsOn to the java code and when running the SLC to create the XML and the jar. And the DependsOn in the XML for sure.
Do you mean that i need to open the generated jar and remove the classes from the jar which SLC has added? I mean; i need to remove the classes from the jar as AS has added it to the AAR?
 

corwin42

Expert
Licensed User
Longtime User
The .jar is just a completely empty .zip file.
The .aar is created by AS with all the classes and resources.
The .xml is created by AS with the help of a batch script.

I don't use SLC at all. (I can't because it does not support .aar files. I don't have any .jar files for third party libraries anymore)
 

barx

Well-Known Member
Licensed User
Longtime User


I think I am going to try persue your method @corwin42 for various reasons:

  • I already have Android Studio installed and would prefer not to install Eclipse too. My System SSD is only small (120GB) and soon fills up.
  • I want the process of updaing to be as simple as possible and by the sounds of it, your way achieves this.
  • Android Studio is now the supported way for Android, ADT on eclipse is fading.
So I guess I need to learn what gradle is all about. Am I right in assuming it is used to pull in all the libs required for the project?

I tried to use SLC last week before starting this thread and it complained about not having the dependancies. Again, I'm assuming this is because they haven't been imported to the project?

I'm obviously very novice to this so may have to pick your brains at some point.

Thanks so far
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…