After extracting code to lib widget is no longer working - android

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>

Related

Automatically merge meta-data resources from libraries

I'm the developer of a library that makes use of APP_RESTRICTIONS. Till now I had the following configuration in the AndroidManifest.xml:
<meta-data
android:name="android.content.APP_RESTRICTIONS"
android:resource="#xml/library_restrictions" />
However, one of our customers now contacted us because his build was failing after adding our library. It turns out that he uses another library which also provides APP_RESTRICTIONS. I know that I can use
tools:node="replace"
or
tools:node="merge"
however this basically means that just one of the restriction configurations get active since it is an attribute on the meta-data. What I need is the content of the two resource files merged automatically to guarantee that the configuration field shows up in the MDM solution. Does anyone know a solution other than informing the developer in the readme that he has to manually merge the content of these two files?

android: allow creation of an activity-alias whose targetActivity is in an aar/sdk

I'm writing an SDK and would like developers to be able to create an activity-alias whose targetActivity is set to an activity inside my SDK. I'm doing this because I'd like them to be able to customize the intent filter on a specific activity in the SDK. If in the sdk's manifest there is ActivityX, I'd like them to be able to write an activity-alias like this in their app's manifest:
<activity-alias
android:name="abc"
android:targetActivity="ActivityX">
<intent-filter>
... user's custom intent filter
</intent-filter>
</activity-alias>
The problem I'm coming across is that the targetActivity has the restriction that it:
"... must match the name attribute of an activity element that
precedes the alias in the manifest."
This is a problem because no matter where I place the activity in the sdk's manifest or where I place the alias in an example app's manifest, the alias always comes before the activity in the final merged manifest causing an INSTALL_PARSE_FAILED_MANIFEST_MALFORMED error.
One idea is to put an alias without an intent filter just after ActivityX is declared in the sdk manifest and hope that the two aliases will be merged together and stay in the sdk alias's position. But I can't figure out how to do that. One reason that might not be working is that two aliases may not be able to conflict.
Do you have thoughts on solving this via a merge solution or some other technique?
An identical issue was brought up in the AOSP. A workaround to the problem is described there as follows:
Manually include the manifest entry for the Activity from [the sdk] in
the manifest of the application project, placing it before the
activity-alias entry.
Despite the fact that this workaround has the problem of
... duplicate code across manifests.
it seems that the project maintainers deemed this solution as adequate. There is no indication that a fix to the underlying problem will be released any time soon.

Eclipse loads separate activities instead of application

I'm using Eclipse and android SDK (with ADT Plugin), I don't know if it's some kind of configuration issue or it's some code problem. Whenever I load an app that I made from scratch (this means not using another existing code or one sample from the library) to my device or run it on the emulator, the entire app will load as "separate" apps, which are the activities. For example, if the app is named "Hello world" and it has two activities, "MainActivity" and "SecondaryActivity", both of them will show up on the device with their names as app names and sharing the app icon on the menu. Now, if I go to settings, "Hello World" appears as an application, now behaving again like it should. This doesn't affect the operation of the app, however, it's annoying to have more than 1 icon launching the same app. The problem is that, when i first used eclipse, this was not happening.
Just in case it helps, I've already re-installed the entire android SDK and the ADT plugin, as well, I tried using 3 different Eclipse versions (classic, EE, and Java developers), none of them seem to work, even though, in the Graphical Layout for any activity, the name of the app is showed in the bar with the app's icon, but running on the emulator or a real device it shows the activity's name there instead. I've looked everywhere and I haven't solved the problem.
Thanks!
Check your manifest to see if more than one activity has this:
<category android:name="android.intent.category.LAUNCHER" />
The answer I found for the above problem is, replace category.LAUNCHER to category.EMBED in all the activities apart from the MainActivity in your manifest file.

.apk installed on Android but cannot be found anywhere!

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.

Android emulator shows error when 2 apps with the same activity name

I have 2 projects in my Eclipse. Both of them have a activity called "MainActivity". The weird thing is, when I tried to launch the 2nd app, the emulator showed an error and pointed it to the 1st app. I can bypass this problem by changing the activity name to something different. Then everything will be fine.
I suppose this is only a emulator problem. I haven't tested it yet but I cannot image this happening on real devices, which will make Android totally unusable.
But still, I need to use the emulator and I'd like to keep the name MainActivity. Has anyone has the same experience before? Thanks in advance.
Do you also have the same package name?
Applications are distinguished by their package names so you should change those on per-project basis.
Update:
In manifest package attribute is prepended to name attribute of Activity. Combined they must be the same as your full qualified class name.
<manifest package="com.myapp">
<activity android:name=".MyActivity"/>
</manifest>

Categories

Resources