Mobile File Structure - android

This is more of a general question. I am developing my first relatively large Android application, and I realize the file structure is probably not the "best practice" organization. I feel like I have one folder full with all of my Activities and Java classes, and it is getting a bit messy. Does anyone know what the best option is for making the project structure a bit cleaner?

For organizing your source files take a look at some open source projects to get an idea about organizing your file structure. An example is the Google sample project android-topeka.
This project groups the source code into sub-folders in the following structure:
/source
/activity
/adapter
/fragment
/helper
/model
/persistence
/widget

I found these links very helpful. Link 1, Link 2 and Link 3.
Its a very debatable question. Some IDEs like Android Studio of google, Eclipse IDE for android automatically manage and keep ur source codes clean and compact.

Related

How to edit the lib2cpp.so file of a unity build inside my Android Project

A third party created a unity project for me but they lost their project on their end. A guy had it on his laptop, never backed it up but he did send the integrated unity project for android. The only issue is that we need to change something inside it. So I have the android project, I just need the built unity's source code.
The same situation occurred with our IOS version, luckily Xcode had the Assembly-Csharp accessible and I could find the value I needed to change. The Android's Unity was built with il2cpp. I've managed to re-secure the assets using some tools I've found online. So I can potentially rebuild the project with new scripts. However this may take a rather large amount of time. So I found I can edit the source code through the hex code, but this seems limited/nigh impossible as I need to make a condition on this string instead of simply setting the value. If there is a way to do this with a hex editor on the lib2cpp.so file I would greatly appreciate even a lead. Alternatively I have found some things on hooking a string, but I am unsure of how to go about this and cannot find sources of where to start such a thing.
Any leads or information on how to edit a string on a condition in the unity source code through it's lib2cpp.so file or libunity.so file would be greatly appreciated!

Save android studio activity on separate file

I had created a bulky activity and now I need to modify a lot in it. I decided to first copy paste the entire code on text box but I do not think it is the right way. I want to save the activity consisting of xml file and .java file in a single file that can be recalled if required. Is this possible or should I copy and paste both file to some location manually.
Thanks
In modern Software development it is often a good practice to use some kind of version control system.
A lot of people are using systems based on git like GitLab, GitHub, BitBucket etc.
These tools help to manage your source code in different versions and enable you to switch between versions easily.
In your case you could decide to work with github and after pushing your project you could compare your recent code with the new one until you decide your refactoring is done.
If you decide to dive into this you find many tutorials with google.
e.G https://www.codecademy.com/learn/learn-git

Android complex project organization

Im thinking about trying to build a complex android app structure for a game maybe or just for practice reasons. Im used to code in objective-c, so im not that much experienced in android...
Anyway in work, we structure our app on ios like this:
-core framework: handling all core items, navigation, datahandling, mechanisms, etc. its the same in all of our project
-project framework: its files are mostly relying (including) the core framework's files, extending/modifying them, and doing the project depending stuff
-skin framework: this contains all the resources and images, if we want to do a re-skinned project, we only have to alter this
-main project: this includes everything just bashing together everything into an app. just starts the application, nothing more, anything else is done by the different frameworks
So I wanted to do a similar structure on android, but I'm not sure that I'm even able to do it... I see that there is android project and library project, I can include them into eachother... but my questions are:
1: can I build a similar structure as on ios?
2: can I make for example a "core" library what contains the basics of mechanisms, and another library containing only the resources, and a third one (or the third could be the actual runnable project), what can get resources from the resource library, can distribute jobs to the core library, etc...
3: can I organize the resources as I like (so not to throw every picture into the drawable folder root for example). For example to have somehow a characters folder (i know i cant do forlders in the res folder), and map files into map folder, etc... My only chance to name them "properly"? (map_sheet_type_1, map_sheet_type_2, character_sheet_type_1, etc) (if its going to be a game, it would use opengl, lots of sprite drawing, etc)
or I should do everything in a single project, dividing everything into a lot of packages, and use libraries only for jobs like "how to transcode "A" object into "B" object" ?
Thanks for the answers in advance
although I've never developed a game before, but an app is an app:
yes
as you mention you have executable projects and libraries projects, libraries can use other libraries and the only thing that goes to the device is whatever the executable project is building. It's just important to remark that compiled libraries *.jar files resources cannot be used in your executable project (that's why the ActionBar Sherlock have to be used as a library-project). In order to use a resource placed in a library project the project must be with its full source code open in the Eclipse so it can be compiled together. That is because inside an app, there's only one R (resources) object, and during build all the resources from all the projects are put together.
unfortunately no. As you mentioned yourself the resources cannot be in subfolders and even their file names are restricted as they can only use lower case letters, numbers and _ (underline). Just be clever and organised, write a spec or something.
packages IS the way to organize a single project in Java. If you gonna use multiple or single is your choice. Usually you can encapsulate in a library-project stuff that can easily be re-used in different projects, and the final project will contain everything that is specific to that one app/game. I'll give you an example on the place I work, we have a KicthenLibrary that is a library-project that we use in every single Android app we do. That library already contains an excellent multi-threaded bitmap download and cache classes, we used to have a MapFragment (now deprecated) before Google released their MapFragment, easy Http GET/POST methods, etc. As you can see, all of those are stuff that can easily be re-used in several different projects.
And just as a last trick, http://www.eclipse.org/egit/ IMHO is much easier to use GIT directly from inside Eclipse.
Here are a couple links that should help you get started on this.
http://kasperholtze.com/android/how-to-best-organize-your-android-source/
http://bartinger.at/organization-tips-for-android-projects/
Also, when I worked at a start-up, we made an app for both iOS and Android. We started creating native apps for each, and ended up having somewhat different structure. Global information/variables were handled different, and I couldn't structure my files quite like iOS did. That said, Android structure isn't terribly hard to figure out, and I made a fair amount of sub-folders in my assets folder (for libraries and js and such). And yes, you can definitely have several libraries.
As for having several projects in several in one app, see this link How to create a single application from multiple Android projects

Questions on Notepad Tutorial:

URl of page - http://developer.android.com/resources/tutorials/notepad/index.html
Under "Preparing for the Exercise" the instructions say to
Download the project exercises archive (.zip).
Unpack the archive file to a suitable location on your machine.
Open the NotepadCodeLab folder.
QUESTION 1 - What is considered a suitable location?
I unpacked the samples to.
- *c:\Development\NotePadTutorieal* -
BUT I don't want to modify the files here. Sometimes I need (or just want to) work the tutorial 2 or 3 times from scratch, and would prefer my base files serve as an untouched template, so I can restart from scratch if necessary. I'd like to have the working code for the tutoriel end up where all my other Android Projects are stored at c:\Development\eclipse... but weather I select "Create Project from from existing source" - or - "Create project from existing sample" it seems to leave the files where they are, and work on them in suite (modifying what I'd like to keep as a reusable template) - Am I missing something?
Thanks in advance for any helpful comments.
Joe
Why don't you just keep two copies? Work on one, and let the other serve as your untouched template.
EDIT: Make a copy of the entire NotePadTutorial folder in c:\Development\eclipse\ and work on it there. Leave the other one untouched.
A suitable location is anywhere on your system where you have read and write permissions. If you want them in the same place as your other project files, copy the sample project directory to wherever you want it and then select "Create project from existing source".

android c2dm navigate the jumpNote source code

all,when i open jumpNote project in eclipse,i encounter some mistakes like the following description.
many variables related with c2dm like
Config.C2DM_ACCOUNT_EXTRA,
Config.C2DM_MESSAGE_SYNC,
Config.C2DM_SENDER etc
****cannot be resolved.****
i uses the latest sdk(2.2).
any one konws the reasons, i think that if i miss some jar files?
any help is grateful.
You need to check out trunk/src.shared and merge it into the src dir of jumpnote. Then clean/build. If it still doesn't work re-import it into eclipse.
Those are just examples of what you can do in your own app, they don't actually exist within the Android API.
There is a Config class if you browse the source code, com.example.jumpnote.android.Config.java

Categories

Resources