Android - Create second instance of my app - java

I have created my first app using Eclipse and now wish to implement NFC into it. However I don't want to add it yet to my first app in case I encounter problems. I wish to copy and paste my app into Eclipse a second time so I can have 2 versions in my workspace (App1 & App1NFC).
Is copying and pasting and then renaming the NFC version a safe way to do this. I'm worried the Java source files may conflict each other. Will renaming the project name sufficient enough or will I have to change other things in the manifest/res folders etc?
Thanks

You might want to look into using a version control system such as git. You could create a branch with the NFC code and then be able to switch back and forth pretty easily.

If you want two apps to run on the same device then the package names should not be identical to each other so that they won't conflict with each other.or else installation of the existing app will be replaced by installing app.
i.e
If app1 has the package name as com.mycompanyname.myappname
then make sure the other app doesn't have the same package you could rename it into something like com.mycompanyname.myappname1

You can just copy the entire folder and rename it to whatever you like.Then you can open it as another project
Btw
Why don't you use Android Studio?

Related

Java: Transfer Eclipse Project from One Computer to Another?

I'm using eclipse to write my code in Java. I switch back and forth from home computer to work computer on a regular basis. I wanted to be able to sync the work done on one computer to the other computer automatically - how can it be done?
Further, I want to export all the files from my work computer to home computer as I do not have eclipse setup on my home computer yet. I know I can export the files but this will not export the all the Java jars I imported in my project. Basically I want to export everything so once I import it on my home computer I can continue from wherever I left off at work..
Thanks
The best bet, would be setting up a version control system like GIT (e.g : using github) and then you will have the chance to easily synch through the remote repository.
Regarding the libraries used by your project, to keep them organized and automatically managed you can take a look at Maven build tool.
If you don't want to go with the version control system, though it will be the best option, you can try with the FileSynch plugin and work through an FTP site or whatever shared location you want ...
Unfortunately there is no way to auto sync projects in eclipse, since there is no account/cloud system for projects so you will have to do the job manually. But I can offer you an alternative as long as all the computers are at home (connected to the same router) , there is something in windows called a home group, it enables sharing of documents and devices like printers, faxes, etc. you can make a home group and share the document folder of the user and place the eclipse workspace there then you can just use it whenever you want (your host computer needs to be always online though but you can just copy the folder to the computer and switch workspace via project > switch workspace in eclipse) , then it's the closest you can get to auto sync. I don't know about other OS but I think they should support some equivalents form of a homegroup, hope this helps.
I've been doing this using the dropbox for a while, Install dropbox app in both computers, then turn on sync :)

java files missing in scr folder in each Activity (eclipse)

Details: I have reinstalled eclipse 3 times, updated it & the ADT and DDMS, too.
I have found out that when I create a new android project the scr file is nearly empty. In each Activity there is only one java file and the rest is missing. I have attached a screenshot from the Maste/Detail flow activity so that you see where the problem is.
If you can help me please leave a response.
This is not a bug - it might generate additional files
depending on what starting activity you choose e.g. login activity it requires additional logic for working with Google+, however most will contain all the logic for a specific activity in a single source file, the source code included in the source files will often be minimal to make sure the activity works without the developer having to manually implement things they might otherwise not know about e.g. the fragment activity.
You might want to try out android studio instead if you are not dependent on eclipse as android seems to be moving towards using it and gradle.
(I do use android studios and am currently working on android apps and even though it's in beta it has not given me any problems)
This is a reported bug. Refer to https://code.google.com/p/android/issues/detail?id=72571
To solve the problem, look for ftl files in the tools\templates\activities subfolder of the SDK. In the files found, change <#if appCompat> to <#if appCompat?has_content>, and ${appCompat?string('Fragment','')} to ${(appCompat?has_content)?string('Fragment','')}.

Android apk differentiation

I load an apk created in Eclipse Android Java bin, which works fine. However, I want to make a slight change and also load the resulting apk on the same machine along with the original version. What do I have to change to make the Android tablet see two different apks?
Change the package name of the second app. You cannot have two apps installed at the same time with the same package name.
Technically you just need to change the package name in the manifest, but I would suggest that you change also the app name so you can identify which is what.

Java Updater Game Launcher

I'm trying to make a Java game updater launcher for my game. Similar to how minecraft works. However, minecraft has only a few .jar's to download wheras I would need to redownload all of my game assets. Is there any easy way for Java to check a file for which operations need to be taken? One idea I had was using .7z files since those can be compressed really small. That wouldn't work though because I can't seem to get Java to hook onto 7zip operations. Another idea I had was if it determined if an update was needed it would read a file with a set of commands like this:
remove assets/models/malecharacter.obj
add assets/models/alien.obj
...etc
But I'm not sure this is very efficient and I am also not able to find a lot of help with managing files. Any help and ideas would be appreciated.
I made a Game Launcher in Java recently, I still have a few problems to solve like how to update the launcher itself.
Anyhow, for the game updates/versions I just have a "versions" folder with a folder for each downloaded version, it might not be the prettiest of solutions but it works for multiple versions and it's easy to make.
My launcher checks a URL from my dedicated server which has all available versions, which I call it versionlist, then since the versions folder on the server obeys a path order I can call any versions which are in the versionlist. I download the selected version and extract it to a separate version folder on the user's pc.

How do I make multiple Android apps from a single code base?

I have done this with iOS perfectly and now I need it for Android. I have one codebase that can create unlimited different apps with a simple config file change.
Each app is created based on a complex XML config file that I included in the resources. All I make is one simple change in my strings.xml file and it points to the config file needed, which in turn makes this my project a new standalone app. Easy.
<string name="xmlconfig">nike-shoes</string>
But now that I have done that, how do I make the change so each app is it's own APK?
How can I switch between apps (and uploadable apk's) easily with one codebase and one project. I have heard people say "use a library and then just create a project for each that includes it" but that gets overly complicated when you have 15+ apps and growing.
And I've also seen people say "why not just make one app where you can switch between them all within the app" but that also is irrelevant to my project and doesn't make sense to my users. I can't explain more than that unfortunately, but the short answer is that this won't work as well.
What I did on the iOS project I have is that I just change the Bundle ID, change the code signing identify to match, change the app name, and point to the new plist from within my main Info.plist file. BAM! Whole new app. A few simple steps that takes me less than a minute.
How can I do this with Eclipse/Java/Android? What is the easiest way?
A few steps is fine, as long as I am not mucking with every file to get it done.
I figured I would answer my own question here using Android Studio (2.2.3 at the time I'm typing this), do the following:
In your AndroidManifest file, click on your package name (click the whatever part of com.myapp.whatever) and then hit Shift+F6. Choose "Rename package" and then rename it (without the com.myapp part). Don't do it for comments, strings, and text unless needed. You'll need to approve the refactor with the button at the bottom of the Android Studio window.
Check your build.gradle file and make sure your applicationId under defaultConfig matches what you changed it to.
In your strings.xml file, change your app_name and other strings as needed to make your app its own.
Takes me about 1-2 minutes to have a whole new app. Hopefully someone else finds this useful.
All you need to do is change the package name in the manifest(and a little re-factoring in your code file due to base package name changed), and the next build will create a new App.
If you want to maintain all your apps I would also recommend to create a branch for each app that will contain this change set. this way you can fix something and push it to all versions.
Lets say you change com.foo to com.foo.bar, then rebuild, all your R imports should be now added .bar, just find replace import com.foo.R to com.foo.bar.R, thats about it.
Convert your initial project in a library project, then reference to it from all other projects. This way you have a big advantage: all modification made to the library project are yet available in the other projects. Refernce: http://developer.android.com/tools/projects/projects-eclipse.html#SettingUpLibraryProject

Categories