No Launcher activity found! in a widget - android

Good evening.
I've seen that there are people with questions similar to this but I suppose mine is a little different since I haven't found a solution yet.
I've developed a basic widget that displays the battery percentage, and today, two people told me that they can't add my widget to their home screen because it doesn't appear neither in the widget list, neither in the installed applications list. They had to uninstall it from the Android Market.
I'm not sure if this is a bug on their AppWidgetPicker.apk or a bug in my Manifest since my widgets works in most devices. Feel free to search for "henrique rocha" in the Market and install my "Battery Widget" to see if you have the same problem.
In Eclipse I'm getting the following errors:
No Launcher activity found!
The launch will only sync the application package on the device!
I don't know if that might be the problem that causes the widget to not get listed in the widgets list.
Since I don't have an activity, neither a configuration activity and adding both action.MAIN and category.LAUNCHER to my intent-filter tag inside my receiver tag didn't solve the problem, I'm asking for your help.
Here is my full of Manifest if it helps.
<uses-sdk android:minSdkVersion="3" />
<application android:icon="#drawable/battery" android:label="#string/app_name">
<receiver android:name="BatteryAppWidgetProvider">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
</intent-filter>
<meta-data android:name="android.appwidget.provider"
android:resource="#xml/appwidget_info" />
</receiver>
<!-- Service to maintain widget alive -->
<service android:name="BatteryService" />
</application>
And here is my appwidget_info.xml:
<?xml version="1.0" encoding="utf-8"?>
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
android:minWidth="72dip"
android:minHeight="72dip"
android:updatePeriodMillis="0"
android:initialLayout="#layout/main"
>
</appwidget-provider>

Well, you're right that since it is a widget you can't launch it from Eclipse: there is no Activity with the Launcher intent filter.
Include your entire Manifest so we can be sure you aren't leaving anything else out The AppWidget provider list should include any receivers that handle the AppWidgetManager.ACTION_APPWIDGET_UPDATE Intent, which yours does, BUT also has the AppWidgetProviderInfo XML metadata. If you have that it should work reliably on every handset that isn't somehow borked. I'd check if the folks reporting that it doesn't work are using alternative widget pickers.

Related

Can't start App from Android Studio with neither Launch Option "Default" nor "Specific" Activity

The problem occurred overnight. One day, everything worked fine. I shut my computer down and started it back up on another day. However, without changing a thing, I tried to launch my App on the same virtual device I had before and somehow it wont launch because:
"Error running 'app'. Default Activity not found."
My manifest looks like this. I changed the package name and the two activities below (see comments below). The rest is exactly the same.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="MyPackageName">
<!-- To auto-complete the email text field in the login form with the user's emails -->
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.READ_PROFILE" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity
android:name=".LoginActivity"
android:label="#string/title_activity_login"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".MainActivity"
android:label="#string/title_activity_main"
android:screenOrientation="portrait">
</activity>
<activity android:name=".AnotherActivity" />
<activity android:name=".OneMoreActivity">
</activity>
<meta-data
android:name="io.fabric.ApiKey"
android:value="364e8b3f6acfddf9ad32bed8c1503bb762b19cd5" />
</application>
</manifest>
And normally my app would just start with the Login Activity. However, now it does not. I tried to "Invalidate Caches / Restart". Nothing changed. I restarted AS multiple times. Still, nothing.
Then I tried to change the Launch Options. Current Option was set to "Default Activity". So I tried to change it to a specific one. Namely, the LoginActivity. But then it tells me:
"Error running 'app'. The Activity 'LoginActivity' is not declared in AndroidManifest.xml."
It tells me it's not declared, which it clearly is. Otherwise I wouldn't be able to choose it from the dropdown in the first place. I also tried to start on another Activity. "MainActivity". Still nothing.
What exactly am I doing wrong? Is there maybe a workaround where I can manually get the APK on my virtual device so that I can at least keep working?
Edit
I already tried deleting the .gradle-folder. Sadly this didn't work. I tried pushing it to git and cloning it again in another folder. That didn't work either.
Workaround
So far I've only been able to find a workaround:
Go to Run/Edit Configurations...
Go to General/Launch Options -> Launch: Nothing
Run as you normally would. Android Studio will build the project and install the application to your device, but won't launch it!
Launch your app manually on your device.
Go to Run/Attach Debugger to Android Process.
Choose your app.
Obviously, that's a little bit of a hassle and might make debugging the start of an app more difficult. So I'm still looking for an actual solution.
I've found the answer when I tried to look for a solution to another problem that randomly popped up out of nowhere.
Androidstudio wouldnt load any previews and put warnings in my layouts, because
One or more layouts are missing the layout_width or layout_height attributes.
One solution suggested in
the answer I found for that problem
was to delete all files in
C:\Users\UserName.AndroidStudio3.2\system\caches
Thats what I did and it solved both problems. Guess the developers have some fixing to do.

Android widget not showing up on the list after developed

I'm upgrading my app with widget. It's not the first widget I've done. I was always encountering weird issues, but the widget was shwoing up on the list eventually.
Here is what I've done so far:
Created widget_layout.xml
Created widget_info.xml
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
android:minWidth="110dp"
android:minHeight="30dp"
android:updatePeriodMillis="86400000"
android:initialLayout="#layout/widget_layout"
android:resizeMode="none">
</appwidget-provider>
Created WidgetProvider class
Added widget to manifest in the <application> section (for some reason can't paste manifest fragment here, it's just not showing, see the code here)
Still, can't find widget on the widgets list. I'm debugging the app on real device. I'm using library project, but the widget files but all in the project I run directly. What could be happening here?
Ran across similar issues and this is what happened for me. The below Widget never showed up in the Widget drawer till minResizeHeight was added. Weird, but may be that is required for resizable widget. Could have been more friendly.
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
android:initialLayout="#layout/pmt_schedule_scroll_widget"
android:minHeight="146dip"
android:minResizeHeight="73dp"
android:minWidth="146dip"
android:resizeMode="vertical"
android:updatePeriodMillis="0" />
This kind of issue can happen with 2 scenarios. Both are answered above and this is a complete answer and I have faced both the scenarios and resolved both of them.
Scenario1
If the application specifies android:installLocation="preferExternal" parameter in manifest, App will be installed in external memory and it will not show in the widget list. Also if you have made your phone to install all the apps on sd card, this will also happen.
solution
Go to Settings->Apps->YourApp
Then "move to phone". This will move the app to your phone memory and now you can see the widget in your widget list
Scenario2
If the above fix did not solve your issue, then you may have a device with android 4.X.X version.
Then you have to set at least following parameters in widget_info.xml file
solution2
android:minHeight="XXXdp"
android:minWidth="XXXdp"
The problem was android:installLocation="preferExternal"
It somehow causes problem with widget list if the app is installed on SD
I tried every possible solution and nothing worked for me...
And finally I solved it.
In my case the problem was overthinking: I believed that in meta-data tag we need to define a unique name for provider (eg: "com.example.myprovider") as well as link to the xml resource.
Wrong:
<meta-data
android:name="com.example.myprovider"
android:resource="#xml/widget_info" />
Right:
<meta-data
android:name="android.appwidget.provider"
android:resource="#xml/widget_info" />
You need to register a BroadcastReceiver in the manifest file. For example:
<receiver
android:icon="#drawable/icon"
android:label="Example Widget"
android:name="MyWidgetProvider" >
<intent-filter >
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
</intent-filter>
<meta-data
android:name="android.appwidget.provider"
android:resource="#xml/widget_info" />
</receiver>
I borrowed this code from http://www.vogella.com/articles/AndroidWidgets/article.html
See the link for a full tutorial
after hours of searching and failing to resolve, I decided to open a sample project of a widget that works and go comparing item by item to see what was wrong, in the end, I solve added the following lines on my res/xml/widget_info.xml:
android:minHeight="XXXdp"
android:minResizeHeight="XXXdp"
android:minResizeWidth="XXXdp"
android:minWidth="XXXdp"
where XXX is some value.
In my case, the issue was in the intent-filter within the receiver.
Wrong:
<intent-filter>
<action android:name="APPWIDGET_UPDATE" />
</intent-filter>
Correct:
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
</intent-filter>
In my case, it was the minWidth, it was too large, just put a smaller dp, it works also with a minHeight too height as well!

Android application doesn't appear on recent apps list

i'm deploying an android application (Android 4.0.3) and when I press the home screen the application doesn't stay on the recent apps list. I've noticed that when I restart the application, it starts on the last screen i've navigated before press the home button. Anyone can help? Here is me Manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.test"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="15" />
<uses-permission android:name="android.permission.INTERNET" />
<application android:icon="#drawable/logo_home"
android:allowBackup="true">
<activity
android:name="com.test.activity.CommunicatorActivity"
android:launchMode="singleTop"
android:label="" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.test.activity.InputActivity"
android:windowSoftInputMode="adjustPan|stateHidden">
</activity>
<activity android:name="com.test.activity.SettingsActivity"
android:windowSoftInputMode="adjustPan|stateHidden">
</activity>
<activity android:name="com.test.activity.OutputActivity"
android:windowSoftInputMode="adjustPan|stateHidden">
</activity>
</application>
</manifest>
I'm going to go out on a limb and suggest that this is your problem:
android:label=""
In your root activity CommunicatorActivity you've set the label to be an empty string. This label is used to identify your app in the list of available apps and because it is empty, this may be causing it not to show up in the list of recent apps.
Remove android:excludeFromRecents="true" from your manifest
You should use
android:label="your app_name"
2 things
Ok, there isn't something obvious in your manifest that should prevent it from appearing in your recents list.
1. Wrong identification
It's not always straight forward to tell which task contains your activity, using the GUI.
One of the possibilities is that an activity from some other app is on top of your task making you believe that your activity isn't there. Since, clearly it resumes to the last screen.
I suggest you to remove the single top temporarily and check the same.
2. Launcher modification
Has the launcher you use the standard launcher? Has the launcher or some other app modified the presentation or behavior of the recents screen (unlikely but worth a check)
For this, I suggest using a stock launcher or try the same app on a different phone or an emulator.
What would help is steps you followed and some screen shots of recents
screen and also of your app
I had the same problem.
The reason is that I had set android:label="" in manifest.xml.
I hadn't set android:launchMode="singleTop".
I declared on purpose android:label="" because I didn't find any better way to remove the title of the action bar from my main activity.
I turned android:label="app_name" again and everything now is OK; the app appears again in recent app list when pressing the home screen and doesn't start on the last navigated screen when restarting it.

Marmalade SDK Widget

I'm using Marmalade SDK and I want to create an app widget. I wrote this in pure Android and now I have a problem: how to attach it to my Marmalade project? I have access to AndroidManifest.xml and there I must add a receiver section but I don't now how to attach my classes and resources to Marmalade.
Edit:
Thanks for your answer Max.
I added
android-manifest=AndroidManifest.xml
android-external-res=android-external-res
android-external-jars="libs/Widget.jar"
to my .mkb file
and this
<receiver android:name="WidgetProvider" android:label="#string/widget1name">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
</intent-filter>
<meta-data android:name="android.appwidget.provider"
android:resource="#xml/widget_info" />
</receiver>
to my AndroidManifest.xml
Now, when I start my application I haven't errors but my widget is not show on widget list.
Any ideas? Should I also use this?
android-custom-activity
android-extra-application-manifest
And how should I use it?
Edit:
Ok, I found it, section receiver sholudn't be in activity but in application. But next problem is a file R.java from my widget. Marmalade application doesn't see it. Where I have to put it? When I start my widget I get exception:
android.widget.RemoteViews$ActionException: can't find view: 0x...
You need configuration options:
android-external-jars
android-external-res
android-custom-activity
android-manifest
android-extra-application-manifest
http://developer.roolez.com/marmaladesdk/deploy/deploymenttoolsettings/configurationsettings/androidconfigurationsettings.html

Android Application not running at startup

I have a basic Android application that is supposed to reboot the phone continuously a set number of times. In order to do this, I need the application to be started upon phone startup. In order to that, I essentially followed the instructions found here, adding the permissions to the manifest and creating a BroadcastReceiver class that starts the activity. Here is some of my relevant code:
public class StartMyServiceAtBootReceiver extends BroadcastReceiver {
#Override
public void onReceive(Context context, Intent intent) {
System.out.println("StartMyServiceAtBootReceiver called.");
if ("android.intent.action.BOOT_COMPLETED".equals(intent.getAction())) {
// Intent activityIntent = new Intent("com.example.rebooter.MainActivity");
Intent activityIntent = new Intent(context,MainActivity.class);
activityIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(activityIntent);
}
}
}
From the manifest file:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.rebooter"
android:versionCode="1"
android:versionName="1.0" >
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="15" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="#string/title_activity_main" >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</activity>
<service
android:name=".RebootManager"
android:label="Reboot Manager" >
<action android:name="com.example.rebooter.RebootManager" />
</service>
<receiver android:name=".StartMyServiceAtBootReceiver"
android:enabled="true"
android:exported="true"
android:label="StartMyServiceAtBootReceiver" >
<action android:name="android.intent.action.BOOT_COMPLETED" />
</receiver>
</application>
In the Eclipse emulator, the application appears to be working properly. That is, though my emulator isn't rooted and the phone doesn't execute the reboot commands correctly, I do see that, upon startup, the correct activity is started.
Now, when I'm trying it on a particular system running Android 4.0.4, everything in the application is working properly EXCEPT boot upon startup. Any ideas?
I tried to eliminate the possibility of any hardware problems (since I'm not using a commercially-released phone) by installing another application that boots upon startup and confirming that it does indeed boot upon startup, and it does indeed show up under running apps as a cached process after startup.
I would appreciate any help. Let me know if you need any additional information.
There are a number of issues here.
First, you neglected to post StartMyServiceAtBootReceiver, the component you are expecting to get control at boot time, so we cannot comment on whether there are any particular problems with it.
Second, unless something has explicitly executed one of your components (e.g., the user launched MainActivity from the home screen), StartMyServiceAtBootReceiver will never be invoked, on Android 3.1+. Make sure you run your activity before trying a reboot, and see if that helps.
Third, you implemented a constructor on StartupManager, which is a bad idea. Please move this logic to onCreate().
Fourth, your code will likely crash in that constructor, as getApplication() will not return a valid value at this point in the code, particularly since you failed to chain to the superclass' constructor. Again, moving this code to onCreate() will help here.
Fifth, starting an activity from onCreate() of a service (let alone its constructor) is very unusual and may not be appreciated by the user. Moreover, if that service is not doing anything else, you could just as easily start that activity from StartMyServiceAtBootReceiver and skip StartupManager entirely.
Sixth, you have <intent-filter> elements on your services, as if you are expecting third party developers to invoke those services. If that is the case, fine. If not, please remove the <intent-filter> elements and use explicit Intents within the rest of your app code to refer to them (e.g., new Intent(this, StartupManager.class)), for better security. Or, add android:exported="false" to those services, though that is automatic if you remove the <intent-filter> elements.

Categories

Resources