安装失败:解析失败,清单文件格式错误。

11

安装应用程序时遇到了奇怪的问题。

当我编译项目时没有错误,但是在尝试启动时出现以下错误:

安装错误:INSTALL_PARSE_FAILED_MANIFEST_MALFORMED 错误。

我尝试了很多与 "安装错误:INSTALL_PARSE_FAILED_MANIFEST_MALFORMED" 有关的方法,也遵循了那些规则,但某些地方出了问题。

<manifest
android:hardwareAccelerated="true"
android:versionCode="1"
android:versionName="0.0.1"
package="Work.Work"
xmlns:android="http://schemas.android.com/apk/res/android">
<supports-screens
    android:anyDensity="true"
    android:largeScreens="true"
    android:normalScreens="true"
    android:resizeable="true"
    android:smallScreens="true"
    android:xlargeScreens="true" />
<uses-permission android:name="android.permission.INTERNET" />
<application
    android:hardwareAccelerated="true"
    android:icon="@drawable/icon"
    android:label="@string/app_name"
    android:supportsRtl="true">
    <activity
        android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale"
        android:label="@string/activity_name"
        android:launchMode="singleTop"
        android:name="MainActivity"
        android:screenOrientation="portrait"
        android:theme="@android:style/Theme.DeviceDefault.NoActionBar"
        android:windowSoftInputMode="adjustResize">
        <intent-filter android:label="@string/launcher_name">
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity
        android:exported="true"
        android:name="com.plugin.gcm.PushHandlerActivity" />

    <receiver
        android:name="com.plugin.gcm.CordovaGCMBroadcastReceiver"
        android:permission="com.google.android.c2dm.permission.SEND">
        <intent-filter>
            <action android:name="com.google.android.c2dm.intent.RECEIVE" />
            <action android:name="com.google.android.c2dm.intent.REGISTRATION" />

            <category android:name="Work.Work" />
        </intent-filter>
    </receiver>
    <service android:name="com.plugin.gcm.GCMIntentService" />
    <activity
        android:exported="true"
        android:name="com.adobe.phonegap.push.PushHandlerActivity" />

    <receiver android:name="com.adobe.phonegap.push.BackgroundActionButtonHandler" />
    <receiver
        android:exported="true"
        android:name="com.google.android.gms.gcm.GcmReceiver"
        android:permission="com.google.android.c2dm.permission.SEND">
        <intent-filter>
            <action android:name="com.google.android.c2dm.intent.RECEIVE" />
            <category android:name="${applicationId}" />
        </intent-filter>
    </receiver>

    <service
        android:exported="false"
        android:name="com.adobe.phonegap.push.GCMIntentService">
        <intent-filter>
            <action android:name="com.google.android.c2dm.intent.RECEIVE" />
        </intent-filter>
    </service>
    <service
        android:exported="false"
        android:name="com.adobe.phonegap.push.PushInstanceIDListenerService">
        <intent-filter>
            <action android:name="com.google.android.gms.iid.InstanceID" />
        </intent-filter>
    </service>
    <service
        android:exported="false"
        android:name="com.adobe.phonegap.push.RegistrationIntentService" />
</application>
<uses-sdk
    android:minSdkVersion="14"
    android:targetSdkVersion="23" />

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission
    android:name="Work.Work.permission.C2D_MESSAGE"
    android:protectionLevel="signature" />
<!--<uses-permission android:name="Work.Work.permission.C2D_MESSAGE" />-->
<!--<uses-permission android:maxSdkVersion="18" android:name="android.permission.WRITE_EXTERNAL_STORAGE" />-->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission
    android:name="${applicationId}.permission.C2D_MESSAGE"
    android:protectionLevel="signature" />
<!--<uses-permission android:name="${applicationId}.permission.C2D_MESSAGE" />-->

你的“Package Name”是什么?它只包含“package =“Work””吗? - Jay Rathod
不,我会更改包名。@jaydroider - Milan Patel
请提供待翻译的内容。 - Jay Rathod
我会检查,但是这行代码有错误: - Milan Patel
12个回答

26

因为我的包名中有大写字母,所以我遇到了这个错误。

Com.Droider.packagename;

我将其更改为类似于以下内容后:

com.droider.packagename;

对于您的情况,请尝试将其更改为:

work.work;

编辑 1:

也许这也是原因。

android:name="MainActivity"

将此更改为。

android:name=".MainActivity"

我检查所有小写字母,例如com.droider.packagename; - Milan Patel
尝试一下吧,兄弟。我现在无法假设。这个错误有所有主要问题,我建议解决它们。通常情况下,这会解决问题。 - Jay Rathod
告诉我一个小写的包名,在清单中使用的所有地方都要替换掉。因为我注意到你使用了超过两次。所以兄弟,检查一下吧。 - Jay Rathod
所有必要的地方都进行了更改并且正确检查了吗?对于小写字母。 - Jay Rathod
好的,最后但并非最不重要的是,尝试从清单中删除“支持屏幕”部分。 - Jay Rathod
让我们在聊天中继续这个讨论 - Milan Patel

8
可能是由于 Android 12 导致的。为此,在您的 Activity 中添加 exported = true。 示例:
 <activity
            android:exported="true"   />

1
是的!!! 谢谢。尝试修复这个问题失败了很多次,最终你解决了它。干杯! - CWD
我之前和另一个项目一起使用了一个更新的Android Studio(Electric Eel?),它对缺少android:exported属性给出了正确的错误提示。但是,当我回到旧版本的Android Studio 4.1.3来更新另一个较旧的项目到API级别33时,它只是显示了一个普通的清单格式错误信息。感谢您指出这一点。 - undefined

3

Just check all the

 android:name="..."

检查您的清单文件,看看是否忘记在应该有点号的名称开头加上点号,大多数情况下是您的类的名称。


2
<activity
        android:exported="true"   />

1
我遇到过同样的问题。我创建了一个首字母大写的新包,导致出现了这个问题。请检查你的所有包文件夹名称,并确保所有名称都是小写。

it was my problem

愉快的编码


1
package="Work"
APK清单文件中的package名称必须至少包含一个.分隔符。例如:
package="work.work"

你可以阅读 PackageParser源代码 了解各种安装失败的方式,包括INSTALL_PARSE_FAILED_MANIFEST_MALFORMED

这不是一个解决方案,我改变了包名。 - Milan Patel
这是你所面临的一个问题,可能还有其他问题存在。 - laalto

1
在我的案例中,我在android:process的值上放置了“:”符号。
<service
        android:name=".Views.Views.services.MyService"
        android:process=":remote" />

它对我有效


0
在我的情况下,我将Application类放在了主包文件夹之外的位置。
只需将Application类移动到根活动文件夹即可。

0

你的包名中含有大写字母。尝试重构你的包名,使所有字母都变成小写。为此,在项目面板中,确保你在 Android 视图模式下,然后单击位于视图指示器右侧的齿轮,接着确保紧凑的空中间包未被选中。接下来,右键单击包名中含有大写字母的包,并选择重构 -> 重命名。将其更改为小写,如果 AndroidManifest.xml 不是小写,请手动编辑。


0
在清单文件中,对于每个 XML 资源文件都可以使用元数据标签。 如果该元数据没有指定 android:resource 位置,则会出现此问题。
示例:
   <meta-data android:name="com.google.android.actions"
   android:resource="@drawable/cellphone"/>

1
请完整回答问题,因为似乎缺少了一部分。 - Sach

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接