I'm attempting to use a custom Android vertical scrollbar widget that seems to work fine in its own example project, but I am having trouble trying to include it into my project. I've exported a .jar from it to use in my project, but it seems to be a minefield of problems, from duplicate resources, to my XML layouts not able to get at styles inside the library, and errors "inflating class" when reading my XML layout file.
How should I go about using the widget from another project in my own?
Quite new to Java development (know the language, but not much of the overarching project/package management), so if there's some good text regarding that it would be appreciated.
Create an Android Library Project for the widget.
As far as I can understand the problem should be related to the "R" class which is created in the same package as the main activity. When you create the new project this class is located in "the wrong place".
Giving up compatibility and require the use of the same package in all projects is not an option: market will not allow you to publish more than one application per namespace. Moreover, is is not a good practice for software engineering.
A much better solution is, as already pointed out by fhucho, to create a library project with your widget to be imported in the main application project.
If you are also looking for a book on android development and already know java I usually recommend "Hello Android" by Ed Burnette, it is quick to read but gives a nice overview with examples.
Related
I have a project that I have been working on which is a standard android application that does not include any other external libraries at this time. I am now looking at making a game at the end of the app(its a quiz so after the questions I want to make a mini game).
So what I am trying to find out is can I just import the libraries that it uses and connect them to my project rather than creating a LibGDX project and importing that?
What it comes down to is your personal preference. In answer to your question, yes you could just add in the jar files and such into your current project, however you are going to have to edit your manifest and some add in some other stuff besides jars using this Setup. In my personal opinion it would be easier to create a libgdx project using the tutorial found here, but in the end as I said before it all depends on what exactly you want to do.
Before deciding, ask yourself.
Do I want to have everything in one project, or can it be in more than one?
What would be better in the long run for managing my app.
Do I want ease now or later?
Cheers!
As a total Android development beginner, I might be asking a stupid question here, but I thought I'd go for it anyway, since I have no clue about what to do.
I want to have a carousel kind of menu on my MainActivity for the app I'm trying to develop. I found this project after some searching : http://www.codeproject.com/Articles/146145/Android-3D-Carousel
It's exactly the kind of carousel I want to put in my app, but I'm not sure whether I should import parts of the project containing the carousel (which is a demo of it, available to download) so I can use the same type of carousel in the MainActivity of my own app, or if it's a totally wrong way of thinking.
I think I've also figured that Android libraries are .jar files, and this carousel is a project, not a .jar, so I don't know if there is a way to get this kind of component inside my app.
I tried some dirty copying and adapting from one project into another, but I'm so new with even the basic structure of an Android app that I couldn't make anything out of it.
Any help or guidelines would be greatly appreciated.
I'm planning to make a menu out of this kind of component, and couldn't find anything else closer to what I'm trying to do, for Android.
EDIT : I'm working on Eclipse
Stick the visual language of Android, Holo. Pushing clunky GUI that looks out of place is the last thing this platform needs.
You may mark a project as a library when you create it. You can then import it to another project with Project Properties > Android > Add Library. This point answers you question the most, I guess.
I strongly suggest understanding basic widgets and classes first. Don't go onto the deep waters. If you want flashy slidy things, take a look at Fragment and FragmentPagerAdapterclasses. Plenty more examples that are free, to begin with. By using support library v4 and Android Sherlockbar you should get a better feel of the platform while keeping it up to day date and backward compatible.
Download the project, then go File->Import->Android->Existing Code into Workspace and you will have that project in workspace.
If you want to add only activity then create your own one, File->New->Other->Android->Android Activity and then copy the code and check method setContentView() if it have the layout you need. If you have MainActivity activity with layout called activity_main (which is default) then just check if you have setContentView(R.layout.activity_main);.
I have created a custom library that contains a UI that is to display data being read in from an external device. I have successfully created and applied the library to the project I need it in.
My main issue is I cant seem to use it at all. Ive tried to create an instance of the class file and this is failure. I have functions inside that class file I would like to use, but am unable since a simple declaration of a new class throws an exception for me.
Basically I dont want you to fix my problem, I want to see how this is done correctly. Ive searched the Internet for days and can not even find examples on how to do this.
I thought it would work just like creating an instance of any other class, but it does not. Thank you.
It sounds like you need to do some Eclipse project management.
The custom library including the UI and code that accesses the data source should be in an Android library project (see: "setting up a library project"). The Application which will use this functionality needs to include this library project (see: "referencing a library project").
See the Android docs about Managing Projects from Eclipse.
I'd like to bring out an Android app in the near future, so I was wondering
how to support a couple of funcitonalities I have got used whilst
developing for J2ME and iPhone
first the versioning. With J2ME (using NetBeans as IDE) I had the
option to auto-increment the softwwares version every time I compiled
it. I was wondering if something like this is available for Eclipse
and if so how to use it ?
secondly a common code base. Is it possible to have a common code
base for several projects ? For example I might have a game which
actually uses the same code but needs different graphic resources. I'd
hate to have a different project for every game/app and have to
manually edit every project's source every time I want to submit a new
code-change. Any solution for this ?
Thanks in advance for every kind of help/hints/tips !
Another idea:
If you can package the common code into Classes then a library approach would help.
In eclipse under project properties you can add a library to your project.
Hope this helps you on.
I have a particular collection of code along with some XML files that I need to share with every application I will make.
At the moment I can't because as far as I am aware there is no way to do this. This seems like a massive oversight by the development team.
If the code needs changing, I have to change it in every app that I create - and will create in the future.
Are there any ways to share code in android yet?
I am using Eclipse for development.
You can create an Android library project. The TicTacToeMain sample project in the SDK shows how to reference your created library project.
You can reference a third party JAR like you would any Java project. Or are you talking about something else?
As for sharing XML files, I think you may have to just copy them to each project, but I'm not certain about that.
You can reuse particular Activity classes in applications other than the one they were installed with. Is that sufficient?
To do that, you need to set android:exported="true" in the Activity's declaration in AndroidManifest.xml. http://developer.android.com/guide/topics/manifest/activity-element.html has more details.