How can I update the project name in Eclipse?
I have changed the project name by using "refactor" and "rename", but when I install the .apk in my device, it still shows the old project name.
How can I fix it and what is the problem?
Project name got nothing to application name. And there's no really anything like one application name on Android, but the label of Activity (one or more) user can access from his launcher. This is declared in AndroidManifest with android:label for every Activity with proper intent-filter.
<activity
android:name=".StartActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
See docs.
Related
I upgraded my project from Eclipse to Android Studio.
Everything is working, including different flavors (in Eclipse I had an ANT script that auto-generated the sourcecode for the different flavors).
I can also generate the different signed APK's. And these all work on the device.
Also uploading these APK's to GooglePlay is no problem.
User also get these updates, but after the update they need to re-create the shortcut to the app on the home screen. The old shortcut is removed.
I believe this is due to the fact that "Android Studio" modifies stuff in the AndroidManifest.xml when generating the APK.
In Eclipse source, in Android studio source and when I inspect the Eclipse generated APK I have the following (with the name being .StartUpActivity) :
<activity android:name=".StartUpActivity" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
However, when I look into the generated apk from Android Studio this is modified to :
<activity android:name="be.abc.android.StartUpActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
So the name has been changed from .StartUpActivity to be.abc.android.StartUpActivity.
In the end, this is the same path but I believe the shortcut just looks at the name .StartUpActivity, and decides it is no longer available and removes the shortcut....
Can I fix this in someway that the shortcuts don't get deleted. Or that Android Studio doesn't mess with the shortened package names in the AndroidManifest.xml ?
Indeed, as soon as you modify the launcher manifest entry, the shortcut has to be recreated. To avoid such issue, you can make use of activity-alias. A step-by-step guide can be found here.
I am working on an app which does not have any launcher activity. But when I try to install that app from Android Studio's Run icon, it says, 'Error running XYZApp: Default Activity not found'
I did not see such issue ever in Eclipse.
Can anyone help to fix this issue? How can I install my app in device which doesn't have any Launcher Activity.
Edit your configuration, and there in 'Launch' select 'Nothing' (or something else, what you want to run)
You must be missing the action and category for your main activity in AndroidManifest file
just add the intent filers in your activity as below :
<activity
android:name="com.example.MainActivity"
android:label="XYZApp"
android:theme="#android:style/Theme.NoTitleBar" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
If you are upgrading from Eclipse to Android Studio you might need to refresh the cache for Android Studio and restart IDE.
Follow the following steps:
File -> Invalidate Caches / Restart...
You also need to mention the Activity in the Manifest file of your Android project. You can use following code to do so: Here MainActivity will start when your app launches on the android device.
<context android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</context>
Run -> Edit Configurations.
On 'Launch' select the activity you want to start.
I have
Single main project which defines <action android:name="android.intent.action.MAIN" /> and <category android:name="android.intent.category.LAUNCHER" />
Multiple library projects, with some of them defines <action android:name="android.intent.action.MAIN" /> and <category android:name="android.intent.category.LAUNCHER" />
While I'm using Eclipse to build & run single main project with multiple library projects, only 1 app will be installed.
However, if I migrate to Android Studio to build & run single main project with multiple library projects, multiple apps will be installed,
depending on how many projects (regardless main project or library projects) define <action android:name="android.intent.action.MAIN" /> and <category android:name="android.intent.category.LAUNCHER" />
I was wondering, is there any configuration I had done wrong in Android Studio, which causes multiple app to be installed, when I build & run the projects?
Currently, my only workaround is to remove those lines (<action android:name="android.intent.action.MAIN" /> and <category android:name="android.intent.category.LAUNCHER" />) from all library projects' AndroidManifest.xml. Is that common & correct way, to import project libraries in Android Studio? As in Eclipse, those lines don't install extra apps into my device.
This is how my Project Structure looks like
As you can see the first folder icon, looks different than rest of the folder icons. I guess that indicate, the first folder icon is main project, the others are library projects.
If there is only 1 main project, how come there can be multiple apps being installed?
In Eclipse only the AndroidManifest.xml from main app project is used. In Android Studio (and Gradle build system) all the manifests are merged together.
The following lines inside an <activity> element in your manifest indicate that that activity should be shown in the launcher menu. If you do not wish this, remove those lines.
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
All of this is intended behavior.
There's another hackish way.
Look up at your merged AndroidManifest.xml. It should be located at:
<your_project>/build/intermediates/manifests/full/<debugOrRelease>/AndroidManifest.xml
Search for the LAUNCHER <activity> tag. In your case you should have more than 1 LAUNCHER <activity> tags. My case looks like this:
<activity
android:name="com.stockhut.SplashScreenActivity"
android:screenOrientation="portrait" >
<intent-filter>
<action android:name="android.intent.action.MAIN" >
</action>
<category android:name="android.intent.category.LAUNCHER" >
</category>
</intent-filter>
</activity>
...
<activity
android:name="com.todddavies.components.progressbar.main"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
In my case, com.todddavies.components.progressbar.main is a library project with a sample project that has been declared as LAUNCHER. The correct LAUNCHER should be com.stockhut.SplashScreenActivity.
Open AndroidManifest.xml in your main project, add the following:
<activity
android:name="com.todddavies.components.progressbar.main"
android:label="#string/app_name" tools:node="remove" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Take note on the Marker tools:node="remove". According to Android Manifest Merger Documentation:
A marker is a special attribute, in the tools namespace, used to express a specific decision for how to resolve conflicts.
Therefore an <activity> tag with the marker tools:node="remove" will tell Gradle to remove itself when there's a conflict. In other words, we are somehow "forcing a conflict". It is a little hackish, but it works.
You can always verify your merged AndroidManifest.xml in the abovementioned path.
In Android studio their can be only one project at a time that can be added.
If you have library with project then you have to either add whole code inside you project or
you can create jar for your library project and add them into your project.
There is another option of gradle in Android studio.
If we want to use any library in project we can add their dependency in "build.gradle" file of Project.
I am attaching a screen shot of "build.gradle" file please refer to it.
Now , As far as Library Projects are concerned , (if it is not contributing to your project) The Best Approach is that in Android manifest you should set only your defined activity as a launcher activity ,As In Most cases libraries AndroidManifest.xml Often contain some sample Activity (which should be removed), or Activity which you need to subclass , There should be minimal defined things in the library project (negligible) most of the things should be in your Manifest including all permission.
Also it is define on android developer site
"a filter with "android.intent.action.MAIN" and
"android.intent.category.LAUNCHER" settings advertises an activity as
one that initiates an application — that is, as one that should be
displayed in the application launcher. The icon and label set in the
filter are therefore the ones displayed in the launcher."
you can refer the link also...
http://developer.android.com/guide/topics/manifest/manifest-intro.html
I am having issues with Eclipse. I'm new to Android development so I wouldn't be surprised if I messed something up along the way.
My app installs twice on my phone. When I click 'Run', Eclipse does the usual with installation, but when it is finished, the app shows up twice (ie. two separate icons) on my phone. Any ideas what the problem is?
In your manifest:
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name" >
<activity
android:name="com.myapp.FirstActivity"
android:theme="#style/Theme.Apptheme" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.myapp.SecondActivity"/>
</application>
make sure only your first activity has an intent-filter.
Uninstall both programs from the emulator. If you change the name of the program and/or change some of the settings, then it can install as a different program. My guess is after you do the install, then run that you'll only have the one icon.
Did you run two different versions of this code?
If so it will not save over the old icon but make a new one.
If this is the case trying deleting boths apps from the emulator and re-running it cleanly.
In my case I had two activities with the following intent-filter
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
I got this warning from console when running my application on emulator
No Launcher activity found!
The launch will only sync the application package on the device!
In fact i have declared an activity as the main launcer in AndroidManifest.xml file
<activity
android:name=".myActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
I don't need any other intent-filter to use on that activity.. just basic main and launcher
What's the reason? Please give me a solution..
If the launcher activity is in another package, you will need to specify that as well.
For instance, from one of my personal projects:
<activity
android:name=".activities.MainScreen"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
The MainScreen.java is in the activities package. Also, check spelling for upper or lower case letters.
It seems that you must have "android.intent.action.MAIN" specified immediately before "android.intent.category.LAUNCHER". I encountered the same issue as you when I had the following:
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="android.intent.action.SEARCH" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
The issue was resolved only when I re-orderd as follows:
<intent-filter>
<action android:name="android.intent.action.SEARCH" />
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
In all normal circumstances, listen to what the other guy(s) said.
I was able to replicate your issue using a Mac Book Pro & Eclipse Indigo. when you create your android project, you MUST have Eclipse start you off with a templated activity (like a blank activity). if you don't, and you try to add an activity to your manifest later, Eclipse just derps and can't find the launcher. (i looked at other manifest files and i can't see any differences. i really don't think it's your poor manifest's fault in this special case.)
here's your lazy easy fix:
start a new project, and copy over all the files (make sure you back up ur files first, in case you delete something wrong or mess up the ordering)
Using Eclipse Indigo, open Run Configurations windows, click the project and use launch default activity on Android tab, choose Automatically pick compatible device...and apply.