I'm trying to merge a project called Termux-app from github with its extensions (termux-boot, termux-api, termux-float all opensource from github) to complete it i used the answer given here and it seems to work with termux-app and termux-boot but when i tried to do it with termux-app and termux-api i found some problems, I've been trying to understand what does the errors mean but i had no success.
Some posts said that probably it was because of android studio gradle 3.0 migration but i've checked the xml files of termux-api and it seems to follow the suggestions.
So i have no idea why after adding the module to termux-app and rebuilding the project i got the errors:
The steps that i did to make termux-app and termux-boot work are this:
Download both projects.
Modify the build.gradle of termux-boot and made it a library deleting the ApplicationID, shrinkResources line and changing 'com.android.application' to 'com.android.library'.
Rebuild to generate the aar file in order to add it to termux-app project
From termux-app project click on menu 'File/New/New Module' added the file aar.
Added the dependecy by clicking on 'File/Project Structure/', click on 'app', click on 'dependencies' and on '+' in order to add the dependecy.
Android studio will show a problem with the manifest merged, open the manifest file and clicked on all the 'suggestions' of android-studio to solve the problem.
I repeated the same steps to merge termux-api and termux-app but it didnt work.
It isnt a questions related only to this termux-app but its more about 'the right way to merge two android-studio projects from github'
I Found out that this method was right, It is elegant and works.
My problem was that i had to add a dependency that was in Termux-api and that Termux-api wasnt able to find its resources.
In order to solve this I copied and pasted all the resources from Termux-api to Termux-app and I added the dependency:
implementation 'com.android.support:design:27.1.1'
that was supposed to be called from Termux-api.
Related
I have a set of utils and custom widgets that I want to pull out of my project as an Android library so that I can use them in other projects (and possibly share in the future). I created a new Android Studio project and changed the build.gradle file so that 'com.android.application' was 'com.android.library' and deleted the applicationId. It all compiles fine and I have a .aar file created.
I now want to use this new library as a module in my original project. When I do an Import Project, all the files from the library project are copied into my original project. But I don't want that because if I change the imported library code, it isn't reflected in the library project or vice versa.
I also tried adding this to settings.gradle:
include ':myutils'
project(':myutils').projectDir = new File(settingsDir, '../../../../Development/MyUtils/')
and in the original project app build.gradle:
dependencies {
implementation project(':myutils')
...
But I get this error:
ERROR: Unable to resolve dependency for ':app#debugUnitTest/compileClasspath': Could not resolve project :myutils.
Show Details
Affected Modules: app
How can I link the library to my project without importing it? I would prefer not to go through an external maven repo yet. I'm happy to (and would expect to) recompile my library whenever there is a change there and then rebuild my original project.
Thank you in advance.
I think I just had the same problem - I wanted to put the library .aar file somewhere on my local drive and then use it in a new app as a dependency. I didn't want to have to go through a repo or to include it in the libs folder in the new app. Hopefully that is what the OP asked and the following might be of help to others.
Searching on SO (Aug 2021), majority of answers seemed much more involved than what Android Studio offers (tested on version 4.2). That is, an .aar file that lives outside the app project can now be added as an implementation file in the gradle dependencies. So, it doesn't have to go through a repo, and it doesn't have to be included in the libs folder in the project.
The current documentation (Aug 2021) gives a fairly straightforward answer how to do it:
https://developer.android.com/studio/projects/android-library#psd-add-aar-jar-dependency
In short, if you have put your .aar file somewhere on your local drive, this is how to add it as an implementation file in another app project:
In Android Studio, in your new app project, go to: File > Project Structure > Dependencies.
In: Modules > app > Declared Dependencies, click '+' and select 'Jar Dependency'. (Even though you are trying to use an .aar file, you still select 'Jar Dependency').
In the 'Add Jar/Aar Dependency' popup dialog:
in step 1 enter the path to your .aar file on your local drive, and
in step 2 select 'implementation'.
If everything worked out, your build.gradle(Module) should have a line in the dependencies that looks like:
dependencies {
implementation files('../../../MyFolder/MyLibraryFile.aar')
A few notes:
You can actually just add the dependency manually, by typing it into the build.gradle(Module) dependencies, so you don't actually have to go through the Android Studio dialog outlined above.
you can either use a relative path (as the example above), or an absolute path.
the Android Studio dialog is somewhat limited in that you cannot just browse to your file (in point 3, step 1), but you have to actually enter the path manually.
Probably the most important: Whenever you make a change in the library and assemble a new .aar file, then remember to do the following in your app project that uses the .aar file as a dependency: Clean Project, then Sync Project with Gradle Files, and only then run the app, so that the changes in the library could take effect in your app.
I have been using Phgr's above technique for four years. I have three comments -
First, I don't clean the app project each time I change the library - I just do a Sync Project before building and testing the app.
Second, I changed the File-Settings-Keymap-Main Menu-File-Sync to Alt-S for easy of syncing - I hate wasting time using the mouse for selecting the Sync icon.
Third, I have an implementation line in the app's build module file for each app variant such as the following -
debugImplementation files('c:/Android Studio Projects/PciLibrary/app/build/outputs/aar/PciLibrary-debug.aar')
releaseImplementation files('c:/Android Studio Projects/PciLibrary/app/build/outputs/aar/PciLibrary-release.aar')
All of this is working fine with Android Studio 4.2.2 and sdk version 30.
Hope this helps others with this problem
I'm new on Android Studio, and I'm still learning to importing libs and modules.
The thing is I have created my project as usual but in some point I lost the "project" gradle file and no I have only modules.
I wonder why none of gradle files have the "Project" word. In fact I'm interesting in the file build.gradle (Module:Swipe) to (Project:Swipe)
Question
How can I set the file build.gradle (Module:Swipe) changes to (Project:Swipe)
Not sure I understand your question...
It seems like you are missing the Project gradle file. I dont know what caused that.
To add a new one, just copy one from another project and edit it (it needs to be located on the project folder)
*Maybe it will be easier on the project pane. see here how to change to project panel:
http://i.stack.imgur.com/l4nm5.jpg
For 4 days now I have been trying to get this TwoWayView Library to work in Eclipse. I am not sure if the issue is me or Eclipse. Since I updated Eclipse two weeks ago it has been nothing but a nightmare. Anyways, I downloaded the TwoWayView Project from GitHub, Imported into Eclipse as existing Code, Set project as Library. That should be it for the TwoWayView Lib.
In my project I Right Click> Properties> Android> Add> (Select TwoWayView)> Apply>.
I have Right Click> Properties> Project> Add TwoWayView>.
So far, nothing. I have read in 3 blogs about how simple it should be by just importing the project and using it. Even Lucas' instructions are 3 steps and for the life of me can't figure out how in the world it could sound so simple yet I can't get it to work at all. Has anyone got this to work and if so, HOW?
you could try using gradle, simply add this line to your dependencies in build.gradle: compile 'org.lucasr.twowayview:twowayview:0.1.1'
Just today I had the same problem as you, but I'm working with Android Studio, but I hope you serve.
It turns out that the content of the project is not the library, are just some of the folders that are within twoway-view-master so you have to go one by one and only necessary. Only you need to include the following folders:
core
layouts
Here are the steps to follow:
Download the library project TwoWayView of Lucasr
Create, in your Android project you're working in a new folder. In C:\Users\your-user\AndroidStudioProjects\your-name-of-application\ create a new folder called libraries.
Within the libraries folder created, paste the library project TwoWayView you just downloaded (twoway-view-master folder).
In the project tree of our IDE us that new folder (libraries) will appear. Access the settings.gradle of libraries and add the following lines of code:
include ': app'
include ': libraries: twoway-view-master: core'
include ': libraries: twoway-view-master: layouts'
Now go to the libraries/ twoway-view-master/core and access build.gradle folder. Change this line of code:
apply from: "${rootDir}/gradle/scripts/gradle-mvn-push.gradle"
By the following:
apply from: "${rootDir}/libraries/twoway-view-master/gradle/scripts/gradle-mvn-push.gradle"
Perform step 5 but this time with the build.gradle file layouts folder.
In the build.gradle file layouts folder, you also have to change the line:
compile project (':core')
By the following:
compile project (':libraries:twoway-view-master:core')
Finally you just have to access the build.gradle of your project and add the following lines in the section dependencies:
compile project (':libraries:twoway-view-master:core')
compile project (':libraries:twoway-view-master:layouts')
If you do not understand very well what to do, this question is the solution that gives the user prudhvi.
https://stackoverflow.com/a/32402832/6129931
EDIT: However, since Google launched the Android version L, exist the called RecyclerView, there that can do everything you do with TwoWayView, i.e. can create lists and grids in horizontally and vertically. I recommend you reports about it rather than use separate libraries because Google is starting to demand their use.
Here you can get information about RecyclerView use in horizontal and vertical:
https://stackoverflow.com/questions/36355506/learn-step-by-step-to-use-the-recyclerview-in-android - StackOverflow
Hope this can help you.
I added the following dependency to to build.gradle file in Android Studio and resync-ed the project successfully:
compile 'se.emilsjolander:stickylistheaders:2.1.3'
However I was unable to use any of the class in this library. Feeling strange I opened the source tree and see if there's anything wrong. I noticed the following:
You can see Android Studio can found the available classes for other downloaded archives, but not the one I mentioned in this question. The classes.jar file is reported empty.
I tried adding an older version of the stickylistheaders library (2.1.3). Still an empty classes.jar.
When I start this question I found a similar post here. But the author of that post tried to include the downloaded project in settings.gradle, and he finally managed to include the library through the "compile" directive. My problem is that I AM using the "compile" directive, but the downloaded archive has a "empty" classes.jar. I also tried adding the library mentioned in that question (i.e. 'se.emilsjolander:StickyScrollViewItems:1.0.0'). Also an empty classes.jar.
Some notes:
The actual classes.jar file found in build/exploded-bundles is not empty.
I tried cleaning the project. I suppose this will cause all dependencies be removed and re-downloaded. However, after that, Android Studio still cannot spot any class in stickylistheaders' classes.jar.
So far, this problem only exists for se.emilsjolander's libraries. Strangely, the answerer of this post1 posted a screenshot showing that he does see a non-empty classes.jar.
Update:
I also tried deleting .gradle's cache directory in my profile directory, clean the project and rebuild again. No luck.
I can unzip the classes.jar in question. Looks like the file isn't corrupt.
Anyone knows what's wrong here? Thanks.
I think I have found the cause: it should be a bug in Android Studio.
https://code.google.com/p/android/issues/detail?id=64008
In fact, the code can build and run despite seeing errors in Android Studio. So it is obviously an issue with Android Studio.
Update 27 Jan: It should have been resolved in Android 0.4.3. As from the release notes:
Fixed a bug around library syncing (where library dependency classes
and resources could suddenly not be found by the IDE)
Have you tried syncing your project with Gradle?
Tools -> Android -> Sync project with Gradle Files.
That should reload the build.gradle file and download the (missing) dependencies.
Try this once and make sure you are not getting any error in project Structure saying that "your_lib_name not used/added"
Open File > Project Structure
and check for erros. If error is shown click on it , it will expend the errors and will show some options on right, click on the Red bulb and choose "Add to dependency".
This seems be a bug in Studio which will be fixed in next release(Android Studio 0.4.3).
I know that there are different solutions with different libraries posted. But, could anyone help me with this one?
I've busting my head for the past couple of days, and I really don't know what to do. I already tried importing the modules in all the suggested ways from different posts. (Project Structure --> Dependencies --> Add dependencies), etc. My project does not show any errors, but when I run it, it throws me a compilation error that complains about some classes missing. The library only depends on the ViewPagerIndicator's library which I also imported.
here is a picture. Thanks!!!
NOTE:I also have tried it with Eclipse, but the problem is different there. The app crashes when I run it. When I uncheck isLibrary from Properties -> Android and erase those libraries, the app works.
Inspired by this answer, these are the steps I did:
Put the jar file (in my case, 'xxx.jar') into the libs folder of your project
Right click it and select Add as library
Type this in the dependencies part of build.gradle file: compile files('libs/xxx.jar')
Do a clean build. It can be done inside the android studio, but I also ran the gradlew.bat included inside the project folder
Now, the project should be built and run just fine.
You are referencing the library wrong. You need to add the dependency in the build.gradle file. I recommend you to read the documentation first. It's a long read, but totally worth it.
I noticed that a user uploaded the library as .aar file in his maven repo. You might want to use the library from his repo. The setup is very easy (you only need to include the dependency of the better picker library).