I have a template app which can be easily reskinned changing config params according to a client's brand. When it comes to publishing on Google Play, I obviously need to change packagename on AndroidManifest.xml.
My question is: is that possible without changing folder names, so that I don't need to mess with the whole project structure?
It's totally possible. In your AndroidManifest.xml you should change your package name according to your need, then all your activities and services should target the full path of your classes.
For instance if your application package name should be com.mybrand.myapp and your old java package name is com.myoldbrand.myoldapp your manifest should look like this :
<application
android:allowBackup="true"
android:icon="#mipmap/common_app_icon"
android:label="#string/common_app_name"
android:supportsRtl="true">
<activity android:name="com.myoldbrand.myoldapp.MyActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
hi it's 4 years after your problem, I faced the same problem today,
and here is my solution to the next one who face the problem
change com.example.your_app_name to what you need like com.companyname.your_app_name
you will find that in many places
i know 4 of them
1.) src/profile/AndroidManifest.xml
2.) src/debug/AndroidManifest.xml
3.) src/main/AdroidManifest.xml
4.) build.gradle .
to find other places search about them with ((edit>>find>>find in path))
after changing them all it worked with me
Android Studio has a really powerful refactor tool that allows you to rename the whole package structure on a easy way by also renaming all directories. You should not use different names in java packages and in your project directory tree, that will make your project pretty dirty.
Did you try this answer. It worked for me when I was working on Eclipse.
Related
Good afternoon, I'm new to app development and I would like to see if there is someone who can give me like a tip or advice on this particular problem.
Basically this apk is going to use features from another apk and I think I understand how it's integrated inside the code, for example:
<application
android:theme="#ref/0x7f14024a"
android:label="#ref/0x7f13003b"
android:icon="#ref/0x7f0f0000"
android:name="com.example.appname.BaseApplication"
<activity
android:name="com.example.appname.activities.SplashActivity"
android:exported="true">
but my question is how do I include the actual app or anything necessary to use the features of this other app inside mine since it seems I have not included the app in the libraries or the project, but how do you achieve that? and "#ref/0x7f13003b" the part 0x7f13003b refers to a file in the libraries?
Thank you in advance.
I have added applicationIdSuffix in on every build type in gradle, to be able have every build type installed at the same device at the same time. I also have different string resources for every build type, which means I can have a string resource "app_name" unique for every build type (e.g. My App, My App (beta), My App (debug)). I use the android:label="app_name" on <application> element in AndroidManifest.xml, android:label="app_title" on <activity> and android:label="app_name" on <intent-filter> element, which gave me a perfect setup: in launcher, every build type got its unique launcher name but the title in the Toolbar was the same (no unique resource for app_title).
But running the same app with multiple build types on Android Nougat phones (and emulators) gives med the same launcher names. I'm able to have the installed at the same time, but the app launcher title is the same... Any idea how to solve this on Nougat devices? It works on Marshmallow and below.
Update 1:
Can't get it to work. Let me share some code:
<application
...
android:label="#string/launcher_name">
<a... android:name=".MainActivity"
android:label="#string/app_name">
<i...
android:label="#string/launcher_name">
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</i...>
</a...>
</app...>
/debug/res/values/strings.xml contains launcher_name="My app -D"
But launcher label is My app when running in AS on emu.
Update 2:
Filed a bug at Android.com. http://code.google.com/p/android/issues/detail?id=223706
BR,
J
Ok, I just tested this myself and can't reproduce the problem. My advice is that you check how your resource strings are placed. If you want the app name to differ for each build type, make sure you have that resource placed in each different build and not in the main/res/ folder.
I created a labels.xml where added <string name="app_name">My App (X)</string> where X is release, debug or beta depending on the build type. That works on all Android versions I've been able to test on.
Just make sure you don't have the string resource in the main folder as well. Although, that should result in build error due to duplicate resources.
When I am debugging my Android App, I see multiple apps of it installed on my device, each one seems to be of an holder version. This is really annoying because most are bugged and crash on launch. Anyway I can have Android studio just install the current version.
I've tried to uninstall all the app (uninstalling one uninstalls them all) and re-launching it and It adds them back. I am debugging, not building APK's.
Thank you.
Try deleting the old not working project folders.
Are you accidentally building and deploying multiple flavours? How does your modules .gradle file look like?
Edit: you might want to check this: https://stackoverflow.com/a/27633032/3540885 (Have you set up more than one activity to be launched at start?)
I believe there could be various reasons for multiple installation of app during debug. I also faced similar issue once for one of my app and I after a thorough analysis I found AndroidManifest.xml was the culprit, though it was my mistake as at some point while adding and testing multiple activities I defined two of the activities as launcher activities and hence it was creating two instances of the app when I was debugging.
Check if in your case too, you have defined multiple activities as launcher activities.
Following code part should only exist for your actual launcher activity which you want to launch when you app starts.
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
This is a question concerning android applications with two different .apks (or two apps contained in the one .apk file)
I have two apps which do completely different things but are related, say one is a standard user app and one is an admin app. But a user can be both a user and an admin. I am wondering is it possible for me to create one .apk file that installs two applications to the phone? And how would I got about this?
Thanks,
Matt
You can have two activity elements in the same manifest file, which have both the intent filter with action=MAIN and category=LAUNCHER. Further, you have also to use the attribute "android:taskAffinity" for both activity elements (see also here):
<application android:allowBackup="true"
android:icon="#drawable/main_icon"
android:label="#string/main_name"
android:theme="#style/AppTheme" >
<activity android:name="com.foobar.MyActivity2"
android:taskAffinity="com.foobar.MyActivity2"
android:icon="#drawable/icon1"
android:label="#string/name1" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.foobar.MyActivity2"
android:taskAffinity="com.foobar.MyActivity2"
android:icon="#drawable/icon1"
android:label="#string/name2" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
When the APK file with this manifest is installed on a device, then it will create two icons on the homescreen. The titles of these icons will be taken from the attributes android:label, and the icons will be taken from the attributes android:icon. In the list of apps under "Settings | Apps" you will see the name & icon defined by the attributes of the application tag. When you choose "uninstall" for this entry in the list of apps, then both "apps" will be removed from the device.
It depends on your definition of "application". You cannot install 2 applications if you use the more official definition, as you can have only 1 <application> in your manifest.xml
You can define several activities in your manifest.xml, and they can do seperate things, so in that way YOU CAN have 2 things a person might describe as "application" in one APK
Just define multiple activities and use those could be defined as an option, but it depends on your definition of 'application', but in this case I'd say it would work
Yes, you can install multiple apps by just installing one app.
In Manifest.xml
Project Structure:
You should either build 2 APKs are use APK Expansion Files.
Btw, this is a security measure.
No.
what you can do is to check if the second app is already installed, and if the answer is no, you can prompt the request to install the second app using this post.
Solved
Thanks to #Ifor's suggestion I think I have discovered what was causing it. Since I was not making any changes to the code, only to the resources eclipse must have not bothered creating a new .apk.
Deliberately breaking the code meant that I was changing the code therefore prompting eclipse to re-create the apk. I could be wrong in my hypothesis being a bit of a newbie but it's fixed now anyway so thanks everybody!
I have two home-made applications both with icon A. Recently I got sick of being confused by them so I tried to change one of them for a new icon, icon B.
This is not working!
I have tried:
Re-installing the app;
Un-installing the app then re-installing it.
Un-installing the app then rebooting the phone and the computer then re-installing the app.
None of this works, I still end up with the original Icon A.
I have replaced the icons in the hdpi, ldpi and mdpi folders. I've also searched the folder containing my application for .png files, the only ones there are the three versions of Icon B (the correct one)
What's happening, is there a cache problem like with the windows phone development? I came across this while searching for an answer.
Btw I'm using Eclipse on Windows Vista Ultimate
Any Ideas Anyone?
As Requested here's the Manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.PianoSets" android:versionCode="1" android:versionName="1.0">
<uses-permission android:name="android.permission.WAKE_LOCK" />
<application android:icon="#drawable/icon" android:label="#string/app_name">
<activity android:name=".PianoSets" android:label="#string/app_name"
android:screenOrientation="landscape"
android:theme="#android:style/Theme.NoTitleBar.Fullscreen">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".SavedAccounts"></activity>
</application>
</manifest>
A 'cleaner' method (pardon the pun!) that worked for me (forcing an update of replaced ic_launcher icon):
Project -> Clean
I got the idea from this tutorial:
http://www.slideshare.net/YasmineSherif91/android-application-how-to-change-the-icon-tutorial-2
EDIT: Although clean updates the icons, I get build errors unless I do a Refresh on the added resources before doing the clean. More info about the complementary function of refresh and clean:
Does refreshing in Eclipse also Clean the project?
Some cautions and limitations of clean here:
Function of Project > Clean in Eclipse
Thanks to #Ifor's suggestion I think I have discovered what was causing it. Since I was not making any changes to the code, only to the resources eclipse must have not bothered creating a new .apk.
Deliberately breaking the code meant that I was changing the code therefore prompting eclipse to re-create the apk. I could be wrong in my hypothesis being a bit of a newbie but it's fixed now anyway so thanks everybody!
I find deleting the gen directory fixes this sort of problem easily. It gets rebuilt immediately, and the rebuild refreshes everything.
Make sure the file you use to replace the old ones are also in lower caps. Ie, replacing home.png with Home.png will not work in Eclipse.
You probably updated icon in only one folder. Make sure you've updated the icon in all "drawable" folders:
res/drawable-ldpi/icon.png
res/drawable-mdpi/icon.png
res/drawable-hdpi/icon.png