【问题标题】:Android widget only showing up for debug; app icon always showingAndroid 小部件仅显示用于调试;应用程序图标总是显示
【发布时间】:2026-02-07 07:10:02
【问题描述】:

我的简单小部件应用程序在作为调试应用程序签名时安装并运行良好,但是当我尝试将其签名准备上市时,我遇到了奇怪的行为:它没有出现在小部件列表中 直到我卸载该应用程序,当它显示为标准 Android 的“我没有这个”机器人图标时。

尝试将这个“缺失”的小部件拖到屏幕上会导致启动器崩溃。

为了对此进行调查,我向其中一个活动添加了 MAIN/LAUNCH 意图,它在安装时按预期显示,在我卸载时消失。

令人毛骨悚然的是,如果我重新安装,当启动器显示“我没有这个”机器人图标时,我的小部件会短暂替换该图标,然后从列表中消失。

除了正常的“我正在卸载/安装它”之外,我在日志中没有看到任何错误消息或发出的意图。

我是否遗漏了一些愚蠢而明显的东西,例如“已签名的应用程序必须专门注册其小部件”,这在调试模式下是不必要的?

这是我的清单和小部件属性:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      android:versionCode="1"
      package="uk.org.baverstock.appghoul">
<uses-sdk
        android:minSdkVersion="4"
        android:targetSdkVersion="9"/>
<application android:icon="@drawable/icon" android:label="@string/app_name">

    <receiver android:name="uk.org.baverstock.appghoul.AppGhoulWidgetProvider">
        <intent-filter>
            <action android:name="android.appwidget.action.APPWIDGET_UPDATE"/>
        </intent-filter>
        <meta-data android:name="android.appwidget.provider"
                   android:resource="@xml/appwidget_provider"/>
    </receiver>

    <activity android:name=".Configure"
              android:excludeFromRecents="true"
            >
        <intent-filter>
            <action android:name="android.appwidget.action.APPWIDGET_CONFIGURE"/>
        </intent-filter>
        <intent-filter>
            <!-- Why does this show up, when the widget doesn't? -->
            <action android:name="android.intent.action.MAIN"/>
            <category android:name="android.intent.category.LAUNCHER"/>
        </intent-filter>
    </activity>

    <activity android:name=".ControlsChoiceActivity"
              android:theme="@android:style/Theme.Dialog"
              android:excludeFromRecents="true"
            />

    <activity android:name=".ReconfigureWidget"
              android:theme="@android:style/Theme.Dialog"
              android:excludeFromRecents="true"
            />

    <receiver
            android:name=".WidgetRescanner"
            android:label="WidgetRescanner"
            >
        <intent-filter>
            <action android:name="android.intent.action.PACKAGE_ADDED"/>
            <action android:name="android.intent.action.PACKAGE_CHANGED"/>
            <action android:name="android.intent.action.PACKAGE_REPLACED"/>
            <action android:name="android.intent.action.PACKAGE_REMOVED"/>
            <data android:scheme="package"/>
        </intent-filter>

    </receiver>

</application>
</manifest>

和小部件属性:

<?xml version="1.0" encoding="utf-8"?>

<appwidget-provider
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:minWidth="72dp"
    android:minHeight="72dp"
    android:updatePeriodMillis="86400000"
    android:initialLayout="@layout/widget"
    android:configure="uk.org.baverstock.appghoul.Configure"
android:previewImage="@drawable/icon"
android:widgetCategory="home_screen">
<!--
android:resizeMode="horizontal|vertical"
android:initialKeyguardLayout="@layout/example_keyguard"

 -->
</appwidget-provider>

【问题讨论】:

    标签: android widget installation signing


    【解决方案1】:

    我认为这可能与发布签名密钥过长有关,但各种实验表明即使使用 2048 密钥也会发生这种情况。

    当我使用 Gradle 构建 http://javatechig.com/android/app-widgets-example-in-android/ 时也会发生这种情况,所以它似乎不是我的代码。

    我不认为我所做的任何事情都应该能够在我的应用程序被卸载后使启动器崩溃,所以在我看来这一定是一个 Android 错误:我已经在https://code.google.com/p/android/issues/detail?id=61387

    【讨论】:

      最近更新 更多