I am switching from Eclipse to Android Studio. I have couple of 3rd party libraries that I have added features or modified a little bit. Since the libraries in Eclipse are also projects and we can access the code, I had no problem.
In Android Studio compile tag in dependencies is great but in my case I cannot use it unfortunately.
I fork the project and made necessary changes and add the project as a module in Android Studio. Since the library project already has settings.gradle and example and library modules, there is a mess in my project and it does not compile at all.
Has anybody experienced such a problem? What to do and what is the correct way to forked libraries?
What we've done in my project is create gradle scripts for our dependencies that don't have them, and modify the gradle scripts for dependencies that do have them. Gradle does not play very well with modular dependencies, unfortunately: Each sub-project must know its place in the larger overall project. Since you've already forked the github project, modifying it further shouldn't be a problem.
Related
Whenever I install Gradle third-party dependencies, my android studio project doesn't recognize the library classes. For example, I've tried installing a library called fuzzydateformatter. Android studio doesn't recognize the classes from that library. I've also tried installing other third-party libraries but the same thing happens. Only google and androidx libraries seem to work fine.
// Time Formatter
implementation 'si.virag:fuzzydateformatter:1.1.0'
PS: I'm new to android and I use kotlin
That library has not been updated in six years. It is only published on JCenter, which has threatened shutdown a few times. As a result, JCenter is not included as a repository in modern Android Studio projects.
The best solution would be to use another library, one that is actively being maintained.
If you insist on using this library, your choices are:
Use the source code of the library directly, copying it out of GitHub into your project, or
Adding jcenter() as a repository, in the same spot(s) in your project where you have google() and mavenCentral() (e.g., repositories closures in your project-level build.gradle file)
I have two, separate Android projects. One is a regular Android application and the other one is a libgdx project.
My goal is to be able to compile the libgdx project as an Android library into aar file, so I could use it in the regular, non libgdx, Android application (I'm going to start the libgdx game's activity from the regular Android project).
The libgdx project consists of several modules (I'm using only the android and the desktop modules), so in my libgdx project I can find 3 modules: android, desktop and core (where basically the whole game's code is resides). When compiling and running the game on Android, the android module kicks in, but it uses the core module as a dependency.
When trying to change the libgdx project into an Android library project and compiling it into aar, it seems like it lacks the needed dependencies (like the core module, in addition to some other dependencies).
How can I create an aar file from the libgdx project which has all the needed dependencies?
So eventually I managed to find a solution for my problem.
Lets start with the fact that my first impression was misleading, and the problem I had was not a libgdx specific problem, but a gradle "problem".
In short, the reason behind that is that the aar/jar files don't contain the transitive dependencies and don't have a pom file which describes the dependencies used by the library.
To overcome this behaviour you need somehow to specify the dependencies in your project. You can choose between 2 approaches:
first approach:
You can use a central repository, such as JCenter, and publish the project as library. In this case, gradle will be able to download the dependencies using the pom file which contains the dependencies list.
Second approach:
You need to manually copy all your dependencies to the libs folder. You can do this relatively easy by writing a small gradle task:
task copyCompileDependenciesToLibs(type: Copy) {
def libsPath = project.projectDir.toString() + "/libs"
from configurations.compile
into libsPath
}
This snippet will copy all your dependencies to the libs folder, and once you compile your library project the dependencies will be included.
I'm building some Android apps using Android Studio. Adding dependencies/libraries is really easy by going to file -> project structure -> app -> Dependencies.
But this got me thinking, what exactly is the different between dependencies and libraries and how do they compare? (what's better)
Library is a dependency. Dependency means things that your app depends on. Dependency can be a module, library or a file.
I'm trying to implement a Facebook Like Button in an app and I just found a good library: Facebook Like Button by shamanland.
Now the problem is that I'm using Eclipse and I can't figure out how to import this project correctly in order to use it in the app.
Can anyone help?
Thanks!
That project uses the gradle build system, but eclipse uses the ant system.
Google is leaving ant and migrating to the new gradle system which is used with their new Android Studio IDE. Most of the new libraries also are migrating to gradle due to easy dependency management.
This is a good time to migrate your project to Android Studio.
Download it and when you import your project, it will automatically convert it to gradle.
Then you can easily add gradle libraries to your project's build.gradle, and it will take care of downloading and maintaining them.
For this particular library, you have to add the following to your build.gradle:
repositories {
mavenCentral()
}
dependencies {
compile 'com.shamanland:facebook-like-button:0.1.6'
}
You can also download the Gradle plugin for Eclipse, but it may not be fully compatible with ADT. It's better to use the Android Studio and avoid the headache.
More Info Here
You may download compiled aar file from the Maven Cental.
Just import this aar into your Eclipse project as standalone library.
We are standardizing our infrastructure for Android development and we are trying to incorporate dependency management to our Android library projects. My current track is using the maven android plugin with m2e-android. We have uploaded the Android artifacts to our Artifactory repository with the Android SDK Deployer. We also have an internal framework with a few libraries we can import into our projects and for most part it works fine.
The issue we are facing now is that apklib dependencies containing resource files are hard to set up. The maven plugin can correctly configure the classpath but if the apklib has resource files that needs to be referenced by the parent Android project, Eclipse is unable to find them unless you checkout the Library Project and link it to the parent project through ADT.
After reading m2e-android discussion on issue https://github.com/rgladwell/m2e-android/issues/8, https://stackoverflow.com/questions/6269816/creating-closed-source-android-libraries#answer-6270768 and APKLIB does not get installed in Maven Repo, I'm not convinced maven is the way to go until ADT properly support closed source apk libraries.
I'd like to know how are you handling these kind of dependencies on your Android projects. What strategies are there other than using Maven?
For reference, here's what we have tried so far.
No dependency management. All required jars are stored into the lib folder and pushed to the source control repo. Library projects are set up as subfolders and pushed to the source control repo for each project they are used in. Eclipse project settings are also pushed. Project built with standard ADT Ant script.
Jar dependencies into libs folder and library dependencies as git submodules. Project built with standard ADT Ant script.
Dependency management with maven, including library projects with apklib packaging. Issue with resource files in apklibs.
You can have an insight on how Facebook Android developers address their dependencies issues in this video: How Facebook Built Facebook for Android.
They use Buck for that. Buck is a build system for Android that encourages the creation of small, reusable modules consisting of code and resources. Buck is in github
This might not be the best solution for you but maybe for someone else.
With the advent of Android Studio and Gradle, we are no longer facing issues with project dependencies; Android or otherwise.
Gradle supports Maven dependencies in jar or apklib formats. Popular libraries have been exported to the apklib (aar) format and made available through Maven.