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
Related
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?
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','')}.
I’m coding my first java Desktop application using eclipse and I’m having difficulty deploying it. My project uses JavaFX2 and the e(fx)clipse plugin, the latter is in charge of generating the build.xml file.
ABOUT THE APP
The app, amongst other things, provides an interface where the user can create categories and associate these with labels. All modifications are saved within a single file (the data is stored as a serialized object.) and are supposed to be loaded automatically when the app is reopened.
THE PROBLEM
When build as an executable jar using a .xml file (Ant), the project runs fine within the folder where it gets created. I can run my application, modify data, and save everything once I’m done. When I reopen the app everything gets loaded as it should.
However, if I copy the folder elsewhere, I can no longer save any data. Everything else seems to work; the app will even load the data that was saved when it was in its original directory. I assume that this means that the app can still see the data file, but can no longer write to it.
WHAT IVE TRIED
I’ve read that warping the .jar around an installer may fix the issue; however, one of the goals for the app was to make it as portable as possible. Meaning that it should be possible to move it around from one directory/computer to another, ideally in a manner that is cross-platform friendly, without the need of installing it.
I’ve tried various things to get it to work. I’ve shifted the whole project to Netbeans (to produce a different build), I’ve modified the save/load method file path to make sure the right document is targeted, I’ve tweaked the .xml file the best I could, and I even tried to build the project using the javafxpackager. No matter what I do, when the build works, I get the same results.
Right now, I’m thinking that there may still be something wrong with the .xml file but I’ve got a hard time understanding how to modify it. Perhaps the problem is somehow caused by the way the data gets serialized. I know that at one point when I moved things around within my project, both the save and load methods could no longer interact with the data.
What I find strange is that when the project is moved the load method still works. If the problem is caused by changing the file path, how come only the save method ceases to function?
APP FILES AND STRUCTURE
+src
-(Main.java)
+controller
-(misc.javas)
+modelData
-(Library.java) -->the object that is serialized
+modelLogic
-(misc.javas)
+view
-(misc.javas)
+files
-(library.data) -->the file where the serialized object is saved
+lib
-(empty.empty)
So, is their anything I can do to solve my problem?
Thanks in advance.
In the end, the problem was rather simple. When I was moving the app, I was always putting it on the desktop, which, in the case of my PC, sets by default all content as read-only (in relation to the app's privileges). Because of this, the app could not modify any files that were within folders on the desktop.
Therefore, all I had to do was to move the app to another directory, such as C:\randomFolder, and the problem was solved.
So, if anyone has a similar problem, moving the app elsewhere may be the solution. Alternatively, taking full ownership of the folder and its content can also work.
When possible, it is usually better to have the app ask its user for a specific location to save its data.
Background:
I am currently developing an Android application that makes use of a custom dialog to prompt for a password. Thinking ahead, I would like to be able to use this dialog (in its entirety) in my future projects with a minimum of configuration.
Question:
Is there any way I can encapsulate all of the code and XML for this dialog into one package? Ideally, I would like to simply import the dialog and be done with it. This is easy enough to do with the code, but I am not sure how to do this with the XML layout and string resources files. Basically, I just don't want to have to manually add the string elements to my strings.xml file for each project as well as not have to copy (and thus duplicate) my layout. I gave thought to hard-coding strings / layout into the code, but that seems like bad practice (even for only 4-5 strings and 2 textboxes).
So, what would be the best way to do this?
You need to create a library project, that allows to share both code and resources.
I'm working on an app that is meant to be used by fans of a sport team. In the future, I expect to use the same app but for any different team. So, what changes would be the colors, team logo, app name and the like.
So, is there any technique that allows me to build binaries for different teams without having duplicated resources?
Probably the best way is to depart from the default build system. That typically means writing custom Ant scripts (or you could use some kind of preparatory script that manipulates the resources prior to invoking the default build).
I've previously sketched an outline of how I achieved something similar.
Is it possible to have one binary that contains all the resources and have the user select which team they want from the app itself? Then the app can load whichever resources it needs.
There may be a better way to do this, but here goes:
Build your app for the first team and make all logos / team names / styles / etc resources. Then just write yourself a script that allows you to delete all the items in the res/ folder of your project and replace them with different items. If you are smart, then most of the string's like team names are included in the logos, so all your script has to do is to delete the old ones and copy in the new ones from some other location on your hard drive.
The worst part about this is that you will have to define android-type file for the styles. It might be good to have your script take as parameters a team primary & secondary color, and actually generate all the android-type style files.
Again, there might be a better way, I am just saying that this way could be a solution.
I think build your application which will load the image , colour information from internet / your server. then,
1) ask user for team name which they are following and download image,color information from internet/server and store it as local. don't download next time.
2) attach any global id with each build which will download the image,color information from server first time user installs the application.