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.
Related
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.
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>
I created an Andriod app for a Chinese Newspaper Company.
From the Exception/ANR report of Google Play Store, it was found that some users encountered the problem of ClassNotFoundException when they launch the app.
The app cannot found the activity marked as
<category android:name="android.intent.category.LAUNCHER" />
The frequency is about every 3 sessions out of 500000.
What are the possibilities leading to ClassNotFoundException?
Remakrs:
I doubt if this related to the package name.
In the first few lines of AndroidManifest
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.abc.news"
the source code are stored in different folder name (Real file storage place)
com.anotherCompany.abc
so.. in the activity tag (AndroidManifest)
<activity
android:name="com.anotherCompany.abc.MainActivity"
android:label="#string/app_name"
Thank you for your time
If this happens rarely, I think you shouldn't worry too much about it.
It can be due to a bad installation, a bad phone backup, or some android mods. But probably not something related to your code.
I have developed two small applications for Android using Eclipse. Then i ran them both on the phone by right-clicking on the project and "run as android application", and they were successfully tested. However, when i try to install their .apk files, one of them appears in the list, while the other does not appear. I checked the application manager and it shows that the application is saved.
I tried to find it using the "search" in the phone, it can find all saved .apk except this one.
Pls do you have any idea where did i go wrong especially that it seems saved, and only this application does not appear in the phone although the application manager says it is installed.
Found out why this was happening. You need this in your AndroidManifest as a part of your main activity.
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
My mistake was that I used <action android:name="android.intent.category.LAUNCHER"/> instead of <category android:name="android.intent.category.LAUNCHER"/>. Without the category.LAUNCHER, you're not telling it to list the software in the application launcher, so it becomes invisible.
You may need to enable third party apps on your phone since it is not able to find the one you created.
(Applications >> Enable Unknown sources)
Also you may want to use an APK installer(search) App like App Installer to easily find your own APKs and install them.
And as always uninstall and give it another go, as mentioned above it has happened to everyone it seems.
Your way of description is quiet messy. By phone do you mean the emulator? If it cannot find the .apk and it doesn't appear in the project folder, then clean the project (Project menu) or restart Eclipse. This usually solves the problem. Idk why this is happening so often.
I had a perfectly working widget as part of my project. Then I decided to extract common code (including the widget) into the library project. After doing this everything works except the widget. It appears in the list of widgets available for addition but when I place it on the desktop all I get is this toast message: "Application is not installed on your phone". Can someone shed light on this?
Neither configuration nor code has changed. Widget definition exists in both meta files (project and lib) with project metafile containing absolute (including path) names and all permissions.
I've ran into the same problem today. However I guess I've found an answer.
Check the correctness of android:configure element in AppWidget metadata XML file. If you have widget configuration activity, probably its class name or package has changed when you extracted widget to different project.
Now system cannot find activity that you mentioned and complains with cryptric "Application is not installed on your phone".
Put into manifest:
<intent-filter
<action android:name="com.mypage.activityConfig" />
</intent-filter>