Android TwoWayView Import and Usage - android

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.

Related

Linking an Android library that is on local machine

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

Merging two android studio projects from github

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.

Gradle: error: package does not exist

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).

Trying to add facebooksdk.jar file to my project

I have installed facebookSDK and the sample apps. The sample apps all copilr and run fine.
I tried to make my own app. The only thing I did was creat a new android project, test it, runs fine. Then I added the facebooksdk jar file. Now my project no longer runs and I get a error that says
“jar miss match fix your dependencies”
The jar file seed to load in correctly, if I click on android dependences I see
Facebooksdk.jar ../programming/facebooksdk/……
I tried to see what was different from my project ans facebook's sample code.
Under android dependencies it had the same line I had Facebooksdk.jar ../programming/facebooksdk/……
And also had another jar file called android-suppert-v4-.jar that I do not have.
Other then that both the sample code and my test project seem to be the same.
there is a jar that exists both in the facebook sdk project and in yours.
This is caused by having a duplicate jar -- a .jar file of the same name that appears in both projects, but is not the exact same file. In this case, it is probably android.support.v4.jar, since Facebook uses it, and your project likely does too.
Check your dependencies carefully (and check your assets, bin, etc. folders) for the android support library in your own project -- even if you didn't add it yourself, the dependency could have been added by default, especially if you used the wizards provided with ADT for eclipse.

In eclipse, unable to reference an android library project in another android project

As I was writing up this question I managed to solve it so repeat it here for the benefit of others. Here is the initial problem:
I have created a very simple library project which I want to reference in another project. I have done this previously with no problems so not really sure why it is not working this time. I have:
Flagged the library project via project properties. The default.properties file has this set : android.library=true
In my other project added reference to my library project via project properties. The default.properties file has the reference added as expected ie android.library.reference.1=K:/android_test_ws/applicationRegistrar
The green tick against the referenced library project starts off green and then changes to a red cross.
This implies that there must be something wrong / missing from the library project but I don't know what. My library project on this occasion is MUCH simpler than the previous one I created.
OK Here is the solution which I found when I was looking for the default.properies file of the referencing project (not the library) in my file system. Although the referencing project was in the same eclipse workspace as the library project, the actual files were somewhere else in the file system ie they were'nt in the same parent folder of the library project. As soon as I placed the referencing project in the same physical folder as the library project it all went fine.
I guess that this must be something to do with android using ant underneath the covers.
Edit: The project name needs match the folder name on the file system. What you are seeing in the Project Properties->Android->Library Reference is a relative file system path.
Make Sure both the projects are present in same work space.
To Do it, while importing the projects make sure "copy project into work space" check box is checked.
the same problem will occur if your library project is in different partition from your current workspace. I have the same problem just now. My git source is in C: and I just move my workspace to D: and everything start to collapse.
Simplest way to get the library paths paths correct is to use the GUI from Eclipse to add the library as shown in the following screenshot and let Eclipse take care of putting the correct relative paths in project.properties. Its a common setup to have your library projects hosted at directories vastly different than your main projects that uses the library. This method will work if the "libary project" and the project using it are in the same eclipse "workspace" (they "need not" be in same parent folder):
Please ensure that the library project is marked as "Is Library" - right click on the library project - properties - Android - mark the "Is Library" checkbox - in project.properties of the library project you should have a new entry:"android.library=true. Now add it into the project you want as described in the post below.(the post with image integrated - from Nilesh Pawar).
This bug is referenced several times here 27199, 35786, 36460 & 38052
Maybe by voting for them, it will be fixed one day...
Yet another observation on the same issue.
For me the two projects where on the same parent folder, and were both local inside the workspace. Even then the issue was still happening.
The I edited the "project.properties" file and put the absolute path(with forward slashes '/' for seperator) of the library project. Saved and closed it. Then went to the project properties dialog, removed the library(which was still showing the cross icon but with abs path) and added it back as usual.
Surprisingly the issue is resolved, and the project compiles and runs.
This is really strange and must be a bug with the ADT.
I am using ADT version 20.0.2
when developer referencing the facebook or any other library project then first of all clean the project from eclipse->project->clean project.
that want allow the error of red cross in referencing screen.
For me, I just restart the eclipse and the added library works fine.
I mean first time it showing red marks after adding the library project.
Though eclipse main project and library project are in same workspace folder and no resources files are in outside of the project folder.
So, you can try with to restart your eclipse. Happy coding....
Workaround for me was to
Create a new workspace
Import Library Project in that workspace
Import The desired project in that workspace
Having both project and library project the same target Android OS version
Reference library project in my project
solved my problem
i had the same problem there when i try to change my workspace so this my solution:
import and copy all project data including library project into workspace
delete the old project reference by Right-click on the project-->Properties-->Android-->Library, and select corrupted library(so that waht i call it) and choose Remove
clean project first (to refresh ur project properties)
go to library project Properties-->Android-->Library and check the is library if it does'nt click Apply then OK
if the library project is library is already checked, first Unchecked it then Clean the library project after that do the Step 4 again
go to project that u want the library are in then Right-click on the project-->Properties-->Android-->Library, Add then choose the library project (it should be there) and click Apply then OK
if still doesn't appear clean the project once more time and that should do
Just restart your eclipse. It's solve my problem
When you have a look at the reference-path before and after, it comes from i.e. "C:/workspace/mylib" and goes to "../../mylib" when copied to the correct location, quite interesting.
FYI,
What worked for me was to delete the 'library' projects (the actual projects) from my workspace (without deleting the files), and then re-importing them using the wizard (import existing android project from source code).
Thanks for posting the question.
I had exactly the same problem while integrating Facebook with my Android application. I fixed the issue by moving my development project to the same Windows drive in which library project was located. Somehow Eclipse is unable to read the library project's location properly from default.properties file if it is in a different drive.
Similar to Sufi Khan's post I also solved this issue with a reboot. My case differed in that when I first accessed Properties->Android and added the library I got a lovely green checkmark. When I closed the dialog Eclipse was still showing class-not-found type errors. When I checked the properties again I saw the red X. But Mr. Kahn's solution (delete the bad lib, restart Eclipse, add the lib again) worked fine.
I'm using the 0702 version of the ADT bundle (starts with "cluster", rhymes with "duck").
I followed the accepted answer but also had to make sure my "project.properties" file was readable.
If the file is readonly (checked into source control) eclipse will not edit it. Adding the library reference will succeed, but the change won't be persisted after hitting OK.
If closing the preferences window and reopening in again removes the library you just added, this may be your solution.
In case your library project still doesn't show up try adding library flag in your library project properties
Add android.library=true
project.properties
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system edit
# "ant.properties", and override values to adapt the script to your
# project structure.
#
# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
# Project target.
target=android-17
android.library=true

Categories

Resources