I am using Android Studio.
I have created a library project.and I have successfully included this library in another prstoject.I have followed the below steps to include that library in my project.
a.I have added that library folder in my project root folder.
b.In settings.gradle file include ':library'
c.In build.gradle file compile project(':library')
Now I want to add library as a gradle file.I want to implement just one line in build.gradle file compile 'com.example.library' and then I can access that library files etc.I don't want to add the library folder in my project.Because when the library folder gets increased at that time my project size is also get increased which is not beneficial for me.So guys please suggest me how can I achieve this.How can I get that gradle file or if you have any idea please suggest me.
Read this. This might help. How to distribute your own Android library through jCenter and Maven Central from Android Studio
Related
How do I add a library project (such as Youtube Jar) to Android Studio?
(Not to the old ADT Eclipse-based bundle, but to the new Android Studio.)
i have one more question i if i have old version of youtube library in jar and i never want to update its affected to my future versionof android app or not.
Inside your project's app folder, there is one directory named libs which is empty may be. You need to paste your .jar lib file inside that libs folder.
After then go to your app's build.gradle file. In it inside your dependencies{} block write this line of code.
Inside your app's build.gradle file:
dependencies {
implementation files('libs/youtube_or_your_jar_file_name.jar')
}
I built one android studio project. I wanted to use it as a library in another project. I followed below steps for same:
Changed apply plugin: 'com.android.application' to 'com.android.library'
Removed applicationId from defaultConfig{}
Clicked on sync
This gave me .aar file in build-->outputs-->aar-->myapp.aar
I imported this .aar file in my other test project. I followed below steps for this:
File-->New-->New module-->Import .jar/.aar package-->myapp.aar
In build.grade of test application added compile project(path: ':myapp')
Clicked on sync.
This produced one folder inside external libraries called myapp-unspecified.
There i get all res files but i did not get the class files inside classes.jar.
Inside classes.jar I only have MANIFEST.MF.
Am I doing something wrong or am I missing something??
Experienced the same problem. My issue was that I had removed a dependency from my library project (in this case, testCompile 'junit:junit:4.12'), but did not delete the directory and classes that referenced the APIs from that dependency. An aar file was output to the build folder, but I was not able to access its contents when I included it in my application project.
After deleting the unused classes and directories and re-syncing my library project, I was able to produce a working aar.
Ran into the same issue. The classes are actually there or at least were for me. All that I needed to do was right click the application I was importing my library into. Click open module settings. Then go to dependencies on the right side. Add your library there as well so that the java will compile will your application.
I have a jar file called PhoneGestures.jar which contains a bunch of java files I want to use in my project, which I have added to my project as a module using New->Module->Import .Jar :
I then added this jar module to my project dependencies like so:
and as you can see it is included in my project's build.gradle:
But now when I go to use one of the classes from my jar file, like "MobXRotate", for example, Android Studio does not recognise it:
Does anyone have any ideas why this might not be working? Thanks.
Make sure you have imported the class if the class isn't been found either,
try build your project first, that gradle copies the source code in your project structure!
There's no need to create a new module for a jar file.
Putting the jar file in libs folder will do the trick.
Whenever I made a new android studio project, I usually have to add the same handful of libraries to my build.gradle file. To save time, is there a way to modify the template for the generated build.gradle file to include these libraries? I found a way to do that for gradlew and for the parent gradle file but not for the app itself. Any help is appreciated.
Cheers!
I've seen lots of libraries in github that has no dependencies for adding them to a project.
The questions are:
How can I use these libraries?
How can I add them to my project?
For instance, this is a gitbub project that I don't know how to use those:
https://github.com/zzhouj/Android-SlidingUpPanel
Normally, you would download a JAR file - if any - or download the project and build the JAR yourself (like you would do for Volley project). But if there is no JAR support, like Android-SlidingUpPanel, just download it and add it as a module in your project.
Try doing this way;
download android-support-v4.jar, add to your LIBS folder,
build project.