One app with multiple apk - android

I created an application which has different layout for phones and tablets. Can I add my app in two apk on Google Play one for Phones & one for Tablets? I found supports-screens in the documentation but not sure about that. I have to do this because my app is dealing with images and if I merge images for both (phones & tablets) then size of app is very large.

Yes, you can target apks to specific device configurations. Here's the documentation on it: http://developer.android.com/guide/google/play/publishing/multiple-apks.html

Yes this is possible.
I'd recommend to set the name as:
"..." for phone
"... HD" for tablets
I'd also include a link in both descriptions, referring to eachother (so the phone app refers to the HD version and visa versa).
Also, i'd recommend to read this:
http://developer.android.com/guide/google/play/publishing/multiple-apks.html

Yes, you can have single app with multiple APKs. See Multiple APK support, but unless you really see the difference there like completely different assets which bloats the whole app, then sticking to single binary app helps maintaining it further

Related

Android: different modules for Tablet & Phone, but one single app published & listed

As stated in my question, I am going to develop an app to be published on Google Play, and that app will properly support phones and tablets.
This means the phone and tablet apps will share pretty much the same features, but will display possibily very different layouts in order to offer the best UX for these respective platforms.
At this point, I wanted to go about as following and was wondering if that was the correct way:
I believe App Bundles will help me achieve that, so let's assume I create a new Android Studio project from scratch.
Then, using File > New > New Module, which opens the module creation dialog, I would generate two Phone * Tablet Module and one Android Library module, a module that will contain all the shared same business logic, common to both aforementionned modules.
Then, using the Manifest, I would add the restriction to target phones and tablets separately.
I believe both app modules will need to have the same package name (application id).
Would that be the correct way ? Am I missing anything ? Is there a better standardized way to do so ?
Thanks for the help !
You only really want the layout to change, right? So just create different layouts for the different devices, you can add the qualifiers on creating a new layout file.
https://developer.android.com/training/multiscreen/screensizes
Check this for further information.

How to manage code for different design to support all devices

I have an app and that's already been made for large devices i.e 10 inch tablets and kiosk. I made the same design for the mobile phones but that was not looking good ,so I thought to move the mobile device to material design and the rest of the devices (tablets & kiosk) would remain same.
I know how can I make different layouts for the different devices i.e normal , large and x-large but I am worried about the code. So basically followings are my confusions....
What is a best way to Judge which device my app is running on in code so that I have to run some methods on the basis of that because my normal device is following material design and contains some widgets that are not present in the design of tablets and kiosk i.e RecyclerView (for some purpose)?
I have searched a lot for this problem and came to a point that there are 2 ways of supporting multiple devices
1> make two separate apks , 2> Make one apk and check in code to differentiate the devices, but as i said above in point no#1 that i have material design in normal devices and that is completely changed design in terms of widgets and layouts , fragments and even navigation, so what would you suggest is the best way to handle this?
If I make 1 apk and put a check in code , then I must say I have a ton of code , and resources and in either case (if the device is normal and large) some resources and classes will never gonna used and will make apk size larger so what is a best way to make a work around about this problem ?
I have also searched through stackOverflow and only came up with these two links that were close to my question but rest of the links are about different layouts not the code:
Android app for phone and tablet: 1 or 2 apps?
Creating different layout for android phone and tablet
I hope I am quiet clear in my question please answer my these question with some authentic reasons and links.
Multiple apks for a single app is supported in Google Play. However, unless your app is very large (greater than 100MB) they recommend you release one apk for all devices.
So you need to inspect the screen size at run-time. You can do this by category, by device independent pixels, or even in inches. Then, as you said, you would load the appropriate layouts and fragments accordingly.
Even if you were to use different apks, you would likely do it in a similar fashion because you probably want to share SOME code.
In Gradle you would make productFlavors for each apk, along with a variable to define the build like this:
productFlavors {
bigtablet {
buildConfigField "String", "deviceType", "\"bigtable\""
}
smalltablet {
buildConfigField "String", "deviceType", "\"smalltable\""
}
}
Then at runtime you would use the BuildConfig.deviceType to drive the exact same logic as the screen size did in the one apk method. With this method Gradle will strip out all the unused code from each apk.
The last option would be create completely different projects for each apk. Pushing all the shared code into libraries.
You can always put it all in one apk for now and switch to multiple productFlavors if the apk grows too large. Since the logic is similar it wouldn't be too hard to swicth. Hope this helps.
The Support Libraries are designed to minimize the amount of work you need to do to detect differences in the Android version where your app runs. For example, RecyclerView is available in the Support Library. Between this and layout-xxx folders, you can usually build a single APK for all API levels and device form factors.

Compiling to different targets Android

Our app is distributed from multiple markets and as the developer I need to make different code run for each of those targets, something like:
if (target == ROCK) do A;
else if (target == PAPER) do B;
and so on, does ADT/Eclipse support these kinds of stuff?
How should I go about doing it?
you can set in the res/values folder a parameter (e. g. string in strings.xml) to check for. This string can be parametered with the target (e. g. screensize in res/values-480x800).
There are two approaches to this, depending on what you want:
Multiple APKs, each with hardcoded options.
A single APK that executes code conditionally.
For approach 1, you can use build flavors in gradle / Android Studio (I don't think ADT supports this). You can basically build multiple versions of a single APK choosing different source files in each. Then, in the Play Store, you can distribute these different files according to your criteria.
For approach 2, you have a few options:
For resources, you can provide different files depending on Language and Region (or MCC).
For code, getResources().getConfiguration().locale.getCountry() to get the country of the device or TelephonyManager.getNetworkOperator() for the MCC
once I had similar problem for J2ME development, I just developed preprocessor, you can try to use it for Android projects

Resources on installation of Android app

When android app is installed, does it keep only the resources required by the device current configuration (resolution, language etc) and remove all other redundant resources?
(What will be the point of keeping high resolution images when it won't use it ever?)
Whatever files you have in your APK will be persistent. it will not get deleted by any chance.
As far as I know, the idea is to make use of a single APK to be compatible with the different types of Android devices available. It is not a good practice to design different apk for different Devices.
But yes, some of your resources will never be used by the device and this is how it works.
if required you can create multiple apks for a single app itself.
And it is well explained here,
http://developer.android.com/guide/google/play/publishing/multiple-apks.html
Well, it is all compiled in one apk file, so no choice. It will keep all the resources.

Android app for phone and tablet: 1 or 2 apps?

I have to develop an application for both Android phones as tablets.
The application logic is the same, while the UI is completely different.
I'm wondering how I should deal with this: make 1 big app for both, or an app for phone and an app for tablet (and then upload the 2 apk's as 1 app in the market).
When I make 1 application, I should check if it's phone or tablet in code to redirect to the appropriate activity. Also I should include compatibility code to make it compile for phones.
If I would make 2 apps, I don't need that check and I also don't need to include the compatibility code, so the app would be a lot smaller. But in that case I'll have to copy/paste the application logic constantly from one project to the other one while development.
So that's why I'm wondering, what's the best practice in this case?
I've been searching for information about this, but I only find articles about how to manage the different xml layouts, or articles with not so much information in it.
My Answer, one app. The iosched - Google I/O App for Android demo example from Google I/O explains everthing about how and what. Source Code available! Worth trying it!
Apk Download Link : http://www.mediafire.com/?wck52jweyz1
Certainly make one application.
You can create different layout files for phones and tablets. For tablets you should create extra layout file in res folder which is called layout-large (for tablets), for phone which provides default layout file, and at the same time for landscape mode you can create one more folder named as layout-large-landscape (tablets) for phones layout-landscape
and add some tags to support multiple screens:
<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="9"/>
<supports-screens android:anyDensity="true" />
Certainly make one application.
Android is perfectly designed to be targeted to various devices, its automatic resource selection from res/ folders depending on device's capabilities is big help for you.
You can have completely different screen layout for large screens vs small ones, for portrait vs landscape, for tablets vs phones, etc.
And your code is written/maintained just once.
Of course, you would make come conditional code depending on if your loaded layout has particular view, for example loaded only on large screen, and conditionally fill there additional data if its present.
Read documents on Android developer site about how to support multiple screens, multiple Android versions, compatibility modes with older Android versions, etc.
Also, if you ship just one app, you get single users' feedback / rating on Android Market, not in 2 separate apps.
I have been mulling over the same stuff, although i already have my code layouts split out for tablet / phone variants I am looking for size optimisation by using two apps, however I set out a method for using ONE code set to build both variants.
https://stackoverflow.com/questions/13956515/android-should-i-split-my-app-into-tablet-and-phone-variants

Categories

Resources