I have a simple calculator app. It's a complete application all by itself.
I also have a more advanced calculator app that's based on the first app, but has more features. Its main Activity extends the first app's main Activity. The advanced app references quite a lot of resources and methods from the simpler app.
Getting the advanced app to build under Android Studio has been a nightmare. I've been googling and trying things blindly in the build.gradle files, but not making much progress. At first, the problem was dependent features configured but no package id was set (whatever that means, Google turned up no documentation.)
I got past that by tweaking the build.gradle files, and now I'm getting Manifest merger failed with multiple errors, see logs, but I can't find the relevant logs. It looks like the build failed because Android Studio tried to merge the AndroidManifest.xml files from the simple app and the advanced app, but I just wanted to use the manifest from the advanced app.
This is all very frustrating because I made it all work under Eclipse but now I have to move to Android Studio.
I guess my first question is: How can I tell Android Studio to just use the Android Manifest from the current project and not try to merge from the other project.
In general: can an application project serve as a library for another project, and if so how? Are there any examples?
Third question: where can I find good documentation on build.gradle?
I could attach my current build.gradle files and AndroidManifest.xml files if people need to see them, but I'm really hoping to learn enough that I can help myself.
Confirm the problem first:
Switch the same model in Library / application
Application ID androidmanifest conflict problem
if this is the problem, the official documents can see the channel packaging
https://developer.android.google.cn/studio/build
And I wrote you a little demo
https://github.com/yuanweiwork/lytools
I hope it can help you
Reading this article, thought having the same problem - One code base, two applications on Android
I have created an application testApp that has items like topics, splash screens, logos, charts, rules, statuses and/or events.
Now, I want different applications (testApp_USA, testApp_Canada, testApp_Australia)from the same code base and put them on Google Play Store so that if user downloads the application, say, testApp_USA, then only the specific items to that region should be shown like splash Screen of USA, USA logos, etc..
So I want to configure multiple applications according to countries and then set the items as defaults according to which application the user has downloaded.
Presently, I have a single application which is for all regions and I am imposing multiple conditions to distinguish or change the items according to the regions.
For example:
(In many Java files, I used)
if(rule.contains("USA"))
{
//Show splash screen of USA
}
(Similarly, In many Java files, I used)
if(rule.contains("Australia"))
{
//Show splash screen of Australia
}
This is just a one item out of many repeated throughout code. Considering all, it will be lot more.
There should be a better way to create multiple applications in android with different names and settings.
I know, iOS allows me to easily change the application name and profile to allow multiple apps to be created. But I don't know or this is not easy to do on the Android code.
My question:
Is it possible to create different applications with the same source code in android with different settings of items and publish them to Google Play Store ? If YES, How to set such configuration ?
UPDATE:
Read this Post - multiple-android-application-package-apk-files-from-single-source-code
Then I came up with the same idea -
1) Taking some string variable that holds values about which application type you want to create.
public static final String app_Name = "testApp_CANADA" ;
2) Have multiple AndroidManifest.xml files for multiple apps you need to create .apk for.
3) Create corresponding launcher activities for each manifest.
But then how to have multiple AndroidManifest.xml files in a single app ?
UPDATE:
My first AndroidManifest.xml is in main project folder (application root folder) as usual that we have. Consider this for testApp_USA.
My second AndroidManifest.xml is in separate package under main project. Consider this for testApp_CANADA.
Both AndroidManifest.xml have different launcher activities with corresponding splash screens, icons defined. The package names are given different in both so that they will create different .apk files as per requirement.
Now, how to switch code between testApp_USA/testApp_CANADA provided my main app has setting:
public static final String app_Name = "testApp_CANADA" ;
OR
More clearly,
How to call a particular AndroidManifest.xml according to the value of app_Name ?
With the current setup that I have, only first AndroidManifest.xml is called always.
I had similar problem with putting project to different markets - Google Play, Samsung, Amazon. All code base is the same, difference only in billing code.
The best solution I found is creating separate project for each market and pushing common code into library project.
In more detail, you need to leave common code in main project, make it library project and enable manifest merger for library and child projects.
Add following lines to project.properties of main project:
android.library=true
manifestmerger.enabled=true
and this to project.properties of every child project:
android.library.reference.1=../testApp //absolute or relative path to your main project
manifestmerger.enabled=true
Also you need to attach main project as library in ADT plugin (in Eclipse - project properties -> Android) to all child projects.
Main project manifest should not contain any launcher activity, it will be ignored, same thing with appWidget xml's and config activities, if you have some.
In child projects you can configure whatever you want and use main code by extending or just using needed classes as normal Java library. Also, you can use main project activities, services, broadcast receivers, etc just as they are in your child project without any duplication of manifest of child projects.
After all configured, you can just build needed project for needed country as usual single project and you would have different apk's for different countries, as you want.
Here is more detail description of manifest merging http://www.platoevolved.com/blog/programming/android/merging-android-manifest-files/
Note, this feature was added in ADT version 20 preview 3.
Hope this helps.
I had this same question. Maybe you have found the answer at this point, but some searching finally led me to this website, which explains Gradle.
It seems to explain all the basics really well. For the answer to your specific question, look for the section Product Flavors under Build Variants.
As the website explains, part of the purpose behind this design was to make it more dynamic and more easily allow multiple APKs to be created with essentially the same code, which sounds exactly like what you're doing.
I probably didn't explain it the best, but that website does a pretty good job.
The way to have multiple apps from a common code base is to have the common code as a library project, and have each app use the library project (see http://developer.android.com/tools/projects/index.html).
Each project can override strings.xml, and the common come can check the package id.
In your case it seems that this is against the Google Play policy (cookie cutter apps), so it may be better to create one app and let the user choose a country.
For this you have to use App Localization concept. For this you have to create different resources, durables. Let say You want to run your application in japan, you have to create drawable folder like "res/drawable-ja". This is same as you create different layouts to support tablet and small devices.
here is reference link:
http://developer.android.com/guide/topics/resources/localization.html
http://developer.android.com/distribute/googleplay/publish/localizing.html
I am not sure what you want exactly. But at my point of level, you can able to get the geo location, there you can find-out where you app currently running out, or in more easier get the location from locale, once you find the locale or geo-location, you can navigate the source according to that.
Friends I have 3 android projects in eclipse say App1, App2, App3 and i want to combine all these into another android project say AppStarter which only has buttons to start the main activity of each of those 3 projects. So how can combine all the files of App1,2,3 under AppStarter and what changes do i have to make in android manifest of each project?
Don't refrain from going into details, I am really confused. Although pointing me to right way is also helpful.
Simplest way to do what you want is to use App1,2 and 3 as Android Library project and link them to your main project. All what you have to do this is HERE.And there you can find something helpful about library project.
It's just few mouse clicks.
Hello I am trying to build an app which will hold "other app's"
For example MY app will hold different apps of different ClIENTS.
Now i want to make it so that 1 client has the option to only download his part, BUT he still has to use MY main app. (in other words i don't want to reference to another APK, cause then he can start his app without using mine(i think))
And the download option should be at runtime, cause else he has to download everything in one go.
I have thought about using jar files as library files, but what i found so far is that you have to add them in Eclipse (else they are not found)
I also thought about building the app with the jar files in it, and then leave them out when i compile the app. Then my client can download those files afterwards. But i am guessing that will cause reference errors?
So the questions are;
Is it possible?
How to go about?
The main idea is that i don't want to make one HUGE app where as my client will only use his part of it.
Thanks in advance
It can be achieved in android, and some big platform apps could let the 3rd party developers to develop plugins for them. The main idea is try to create your own DexClassLoader to replace the default one, the custom DexClassLoader could load classes from apkfile.
Try to look through this article for details.
Same with this question.
It seems this is a difficult topic. I can only give you some point.
Since you don't want to make a huge app, then you have to build CLIENTs as separate APKs. But if you don't define CLIENT's activity as MAIN and DEFAULT in manifest, after install CLIENT app, user could not find CLIENT app from system menu (launcher). You can define a private intent name for CLIENT app's activity, this way, only your main app could start CLIENT app's activity.
I have two independently developed Android projects (with own activities etc.), tested and working independently.
One project is now supposed to be launching (via Intent) the second project.
I could have kept it that way, but when distributing it via the Android Market, it will necessitate 2 APKs, 2 icons, etc. which could be very confusing to the end user.
So I would like to integrate the second project into the first one, while keeping it as a separate package.
A straightforward approach for doing this is to manually create an empty package, then copy over all files, one by one, from the second project. Tedious.
Is there a built-in shortcut in Eclipse (or ADT) to do this, similar to the File > Import > Existing Projects into Workspace ?
I think you can make your second project as a Library Project by right clicking on it and in the Android tab check isLibrary. And then in your first project, you link the one that you made a library by right clicking again and under the Android tab, Libraries, click Add and point to your Library Project. You could also have a look at Managing Projects from Eclipse.
If this does not work (but I really should), you can simply just right click on your packages, then select Copy and go to your first project, and just right click -> Paste. This also worked for me.