The title is a little misleading but I honestly don't know how to word it in any other way. This is my project structure:
I want to use the highlighted (fasteranimationscontainer-master) in my current app that I'm working on. I imported it by putting the jar file in my library folder then adding it to my library through Android Studio. But I try to create an object of that imported library, it doesn't show up/import.
I'm still learning how to use android studio so any help would be much appreciated!
1. Library with only the Source Code
To include a library with only the source code (like FasterAnimationsContainer) to your project, you only need to import it as a module from File -> New-> Import Module in Android Studio:
There should be a dialog for the project folder, enter the path where your library reside.
Then you need to add the module to your app build.gradle as a dependency:
android {
...
dependencies {
...
compile project(':fasteranimationscontainer')
...
}
}
Now you can use it in your project.
2. Library from Maven or JCenter
To add dependencies to your project where the library has uploaded to maven or jcenter, you need to modify your app build.gradle file and add extra lines configuring the packages you require. For example, for certain Google or Android, dependencies look like:
android {
...
dependencies {
// Google Play Services
compile 'com.google.android.gms:play-services:6.5.+'
// Support Libraries
compile 'com.android.support:support-v4:22.2.1'
}
}
Try to always read the library README first.
Suggestion:
If you still learning using Android Studio, you can read Using Android Studio. Then read Getting Started with Gradle, because Android Studio is tightly related with Gradle.
Related
I'm trying to build an AR project in Unity and use it as a library in my native android app.
I used this article as a guideline:
https://medium.com/#davidbeloosesky/embedded-unity-within-android-app-7061f4f473a
I successfully imported the project to Android Studio, but the settings.gradle file is missing.
Although I can run the project from the studio, when I convert it to a library and use its aar file in my native android app - I fail to build the project.
Has anyone succeeded doing it?
I followed the guideline and it worked out. I put the .aar file below the native app libs file. In app build.gradle, under dependencies add:
implementation(name:"AndroidPluginDemo",ext:"aar")
and under android add
repositories {
flatDir {
dirs 'libs' //this way we can find the .aar file in libs folder
}
}
Just to add on to the above answers asking about the camera not working, the problem for me was the one of the classes in the unity app wasn't being found when i imported that library into my android app.
When you're converting the application to a library project, take note in the build.gradle of the dependencies.
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation(name: 'vlsdk', ext:'aar')
}
In my case I had to find the 'vlsdk.aar' file that was being referenced, and import that as a new module (as is done in step 6 of the tutorial) into my native android app. Hope this helps.
I know this is very old and i hope you have found a solution. but to anyone else facing this issue.
Add the ".aar" libraries found in the libs folder of unity's exported project to the build.gradle file as dependencies(they also need to be physically present in the native projects libs folder).
In my case when i built the .aar library from the exported project it did not add the dependencies(unity exported project also has dependencies found in the libs folder). I only excluded the "unity-classes.jar" file as my unity code is already in the ".aar" that i created.
Check the following link
https://medium.com/#randive.rishiraj/7-steps-to-integrate-google-arcore-unity-project-to-a-native-android-app-d85793ba0b37
Hope this helps.
To implement Unity features inside native apps we need to change Unity Project as a library, and then integrate inside our native application.
From version 2019.3.a2 Unity introduced a new feature Unity as a library in native apps both Android and Ios.
Steps:
1. Export Unity Project as an Library (Android)
2. Add Unity Library Module inside Native Android Project
3.Show Unity View inside Android Activity
Previously, the exported Unity project will have only one gradle module and one manifest file.
But now the Structure has been changed to two gradle modules.
1. launcher
2.unityLibrary
Both launcher and unityLibrary module will have its own build.gradle and manifest files.
unityLibrary - module will have Unity runtime and project data, it can be easily integrated into any other gradle project. It will help
to integrate Unity inside our native android project.
launcher - module will have all icons and the application name.
But we want use only unityLibrary module as an library inside our native android project.
This blog helps to implement unity view in your native android app.
https://navinkumar0118.medium.com/show-unity-view-inside-native-android-app-8035b9b6895a
I have a legacy eclipse Android project. The classic old way without gradle.
Suppose I found a library I want to integrate with, for example 'commons-codec', than quoting from gradle manual https://docs.gradle.org/current/userguide/organizing_build_logic.html#sec:external_dependencies, I need to paste the below in my gradle file:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath group: 'commons-codec', name: 'commons-codec', version: '1.2'
}
}
Now my eclipse project does not use gradle.
The Question: Is there a way to get the binary lib & integrate with it in eclipse (something similar to download the library's jar and add it)? I know this question is bizarre since I need the jar to be in the repository, but I want to be sure I'm not overlooking anything.
Many Thanks!
If you're just using a jar, you can include it in the libs folder of the Eclipse project. But that's code only. If there's resources in the library, you'd need to build an Android Library project out of it and include that in your project. Which I'm not sure how you'd do without code.
If you are having .jar file the simply right click on your project then
Properties-->Java Build Path-->Libraries-->Add Jar/ Add External Jar--> Apply
And if you are having library in your workspace then
Properties-->Android-->Add-->locate your library-->Apply
I am using Android Studio 1.2
I create a private library I want to use that one in another application.
To use it I create an AAR files, but this AAR don't work. I have in my library a dependency to an AAR file.
The AAR files do not the dependencies?
If I use the jar and I includ ans create all the dependencies the project works fine.
NOTE :
I know how to importe the AAR file. The problem is to use an AAR in the AAR..
Thanks.
If I'm understanding your question correctly, there are 3 projects involved:
Library Project 2 --> Library Project 1 --> Application Project
You are editing "Library Project 1" and have added to it's app/build.grade a dependency on the Library Project 2's aar. Something like this: compile 'com.arasthel:gnavdrawer-library:1.1.5'
I am not sure where you are running into an issue, but I'll attempt an answer anyway. If I'm completely off-base, can you please elaborate on how the AAR dependency is not working? Any error messages?, a class/resource not found, etc.
I think it's unlikely you are unable to use a class from Library Project 2 inside Library Project 1, because I just tried this myself and it seems to be working just fine. It's worth noting that the Library Project 1 aar file will NOT include classes or resources from Library Project 2. Library Project 2 will be noted as a dependency in Library Project 1's pom if published using gradle's maven plugin to publish Library Project 1.
My guess is that you are having a problem in the Application Project? Perhaps the class from Library Project 2 is not found in the Application Project?
If that is correct, then there are two possible solutions:
Enable transitive dependencies on the aar dependency in the Application project's app/build.gradle: Instead of compile 'com.example:myLibrary:versionX', make it compile('com.example:myLibrary:versionX'){transitive=true}. I just verified this causes gradle to read Library Project 1's pom and automatically add dependencies found there into the Application Project.
If you would like to use transitive dependencies, your Library Project will need to be generating a pom and publishing it along with the aar. See https://stackoverflow.com/a/30085677/431296 for some additional information on how I have this working.
Manually add the dependency on Library Project 2 to the Application Project - so that your Application has a dependency line for both Libraries. Depending on your specific situation this may or may not be a workable solution.
Add following code to you project build.gradle file, and you should put you AAR file to the libs folder.
repositories {
mavenCentral()
flatDir {
dirs 'libs'
}
}
And finally add compile info to your dependencies:
dependencies {
compile(name:'AARFileName', ext:'aar')
}
I'm new at GitHub. I found a library that I want to use in my Android project (Glide), but I don't know how.
After downloading the source code I'm stuck with a zip folder that I don't know how to import it into my project. I'm working with Android Studio.
Any help?
Thanks.
Unzip the downloaded project. Open YOUR project in Android studio. Click File -> Import module. Add this module as a dependency to your project. You should be good to go.
[EDIT]
BUT, since Glide has gradle/maven support, I can just simply modify your project's build.gradle file and add the following lines to the dependencies group:
compile 'com.github.bumptech.glide:glide:3.3.+'
compile 'com.android.support:support-v4:19.0.0' // You might need to increase the version numbers if the libraries have never versions
I have to create an application that makes extensive use of charts.
Reading the web I chose achartengine that seems to have everything I need.
I downloaded the jar file, I plugged in the libs folder, I selected "add to library" and I lunch the gradlew clean.
Result in the sources where I do the import of org.achartengine.xxxx I always returned the error that fails to resolve symbols .
Do you have suggestions?
Thank you
Andrea
I am able to use this library in my Android Studio project, this topic explains how to add AChartEngine repo to your project.
What I did:
Added following to project-wide build.gradle (one from the project root):
allprojects {
repositories {
...
maven {
url "https://repository-achartengine.forge.cloudbees.com/snapshot/"
}
}
}
For every module that uses the library, add this to its build.gradle (you may put this to the top-level build.gradle if it should be included in all modules):
dependencies {
...
compile group: 'org.achartengine', name: 'achartengine', version: '1.2.0'
}
Now I can use the library in the project, I see the classes in code assist popups and build runs as succeeds.
It seems like the new version (1.2.0) is not available for download anymore in the http://www.achartengine.org/ site. and that's why the gradle/maven method doesn't work (or the snapshot file was removed).
I succeeded using and adding it to my project by downloading the jar file from here:
https://github.com/ddanny/achartengine/files/460139/achartengine-1.2.0.zip