安装错误:INSTALL_PARSE_FAILED_MANIFEST_MALFORMED?

发布于 2024-11-07 21:38:12 字数 161 浏览 0 评论 0原文

我正在开发一个小应用程序,其中列出了 Android 设备上存在/安装的所有应用程序。但是当我尝试运行代码时出现以下错误。

安装错误:INSTALL_PARSE_FAILED_MANIFEST_MALFORMED

请任何人帮助我解决此错误。

I am developing a small application that lists all the applications present/ installed on the android device. But I'm getting the below error while i'm trying to run the code.

Installation error: INSTALL_PARSE_FAILED_MANIFEST_MALFORMED

Please can any one help me to sort out this error.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(30

喜爱纠缠 2024-11-14 21:38:12

此错误可能还有其他原因。该属性

android:taskAffinity="string" 

应始终以点开头,例如:

android:taskAffinity=".string" 

There could be another reason for this error. The attribute

android:taskAffinity="string" 

Should always start with a dot, like:

android:taskAffinity=".string" 
秋凉 2024-11-14 21:38:12

活动名称应以“.”为前缀。在你的清单文件中。

Activity name should be prefixed with "." in your manifest file.

路弥 2024-11-14 21:38:12

在Android 12或Android S中[您可以检查将targetSdkVersion“S”设置为targetSdkVersion 30,它将正常工作]。为此,为了工作,我们需要将所有依赖项更新到最新的依赖项,并且必须将 - 添加

android:exported="true"

到在应用程序的 AndroidManifest.xml 文件中声明了意图过滤器的任何活动、活动别名、服务或接收器组件。因为 Android 12 中的行为发生了一些变化

In Android 12 or Android S [You can check to make targetSdkVersion "S" to targetSdkVersion 30 it will work fine]. For this, to work we need to update all of our dependencies to the latest one and have to add -

android:exported="true"

to to any activity, activity-alias, service, or receiver components that have intent-filters declared in the app’s AndroidManifest.xml file. Because there are few behaviors changed in Android 12.

待天淡蓝洁白时 2024-11-14 21:38:12

INSTALL_PARSE_FAILED_MANIFEST_MALFORMED 错误代码由 PackageParser.java 返回
当它检测到manifest.xml 文件中存在大量错误时。

要隔离错误,请查看 logcat(当您执行“adb install foo.apk”命令时)。在我遇到的问题中,logcat包含:

W/ActivityManager(  360): No content provider found for permission revoke: file:///data/local/tmp/foo.apk
D/Finsky  (32707): [1] PackageVerificationReceiver.onReceive: Verification requested, id = 6
D/Finsky  (32707): [1] WorkerTask.onPreExecute: Verification Requested for id = 6,   data=file:///data/local/tmp/foo.apk flags=112 fromVerificationActivity=false
W/PackageParser(32707): /data/local/tmp/foo.apk (at Binary XML file line #214): <provider> does not include authorities attribute
D/Finsky  (32707): [716] PackageVerificationService.getPackageInfo: Cannot read archive for file:///data/local/tmp/foo.apk in request id=6
D/Finsky  (32707): [1] PackageVerificationReceiver.onReceive: Verification requested, id = 6
W/ActivityManager(  360): No content provider found for permission revoke: file:///data/local/tmp/foo.apk
I/PackageManager(  360): Copying native libraries to /data/app-lib/vmdl1205566381
W/PackageParser(  360): /data/app/vmdl1205566381.tmp (at Binary XML file line #214): <provider> does not include authorities attribute

在上面的第四行中,您可以看到PackageParser抱怨manifest.xml文件的第214行不包含权限属性”。请参阅下面的 PackageParser 中返回该错误代码的所有情况的列表。 (PackageParser 是唯一产生 PackageManager.INSTALL_PARSE_FAILED_MANIFEST_MALFORMED 错误代码的类)

在我的例子中,消息“不包括权限属性”是由 parseApplication 调用的 parseProvider 函数中 PackagerParser.java 的第 2490 行生成的。


从frameworks/base/core/java/android/content/pm/PackageParser.java 4.1.1版本开始,这些方法中的这些行引用了PackageManager.INSTALL_PARSE_FAILED_MANIFEST_MALFORMED。如果源代码行号后跟一个带引号的字符串,则该字符串是 logcat 中打印的消息。如果行号后跟一个 Java 表达式,该表达式是导致返回错误代码的代码,则应该调查该函数以查看导致返回错误消息的原因。在某些情况下,我无法将错误原因隔离到一个特定的方法调用。

in parsePackage:
  536:  (only used in 'core apps' with no 'pkg')
  973:  "<manifest> has more than one <application>"
  1275: "Bad element under <manifest>: "      --if RIGID_PARSER

in parsePermissionGroup:
  1464: !parsePackageItemInfo(owner, perm.info, outError,
    "<permission-group>", sa,
    com.android.internal.R.styleable.AndroidManifestPermissionGroup_name,
    com.android.internal.R.styleable.AndroidManifestPermissionGroup_label,
    com.android.internal.R.styleable.AndroidManifestPermissionGroup_icon,
    com.android.internal.R.styleable.AndroidManifestPermissionGroup_logo)
  1482: !parseAllMetaData(res, parser, attrs, "<permission-group>", perm,
    outError)

in parsePermission:
  1506: !parsePackageItemInfo(owner, perm.info, outError,
    "<permission>", sa,
    com.android.internal.R.styleable.AndroidManifestPermission_name,
    com.android.internal.R.styleable.AndroidManifestPermission_label,
    com.android.internal.R.styleable.AndroidManifestPermission_icon,
    com.android.internal.R.styleable.AndroidManifestPermission_logo)
  1530: "<permission> does not specify protectionLevel"
  1541: "<permission>  protectionLevel specifies a flag but is not based on signature type"
  1548: !parseAllMetaData(res, parser, attrs, "<permission>", perm, outError)

in parsePersmissionTree:
  1572: !parsePackageItemInfo(owner, perm.info, outError,
    "<permission-tree>", sa,
    com.android.internal.R.styleable.AndroidManifestPermissionTree_name,
    com.android.internal.R.styleable.AndroidManifestPermissionTree_label,
    com.android.internal.R.styleable.AndroidManifestPermissionTree_icon,
    com.android.internal.R.styleable.AndroidManifestPermissionTree_logo)
  1585: "<permission-tree> name has less than three segments: "+perm.info.name
  1595: !parseAllMetaData(res, parser, attrs, "<permission-tree>", perm, outError)

in parseInstrumentation:
  1625: new Instrumentation(mParseInstrumentationArgs, new InstrumentationInfo())
  1648: "<instrumentation> does not specify targetPackage"
  1654: !parseAllMetaData(res, parser, attrs, "<instrumentation>", a, outError)

in parseApplication:
  1678: buildClassName(pkgName, name, outError) == null
  1851: (Set by various other functions)
  1869: parseActivity(owner, res, parser, attrs, flags, outError, false, hardwareAccelerated) == null
  1878: parseActivity(owner, res, parser, attrs, flags, outError, true, false) == null
  1887: parseService(owner, res, parser, attrs, flags, outError) == null
  1896: parseProvider(owner, res, parser, attrs, flags, outError) == null
    2484: "Heavy-weight applications can not have providers in main process"
    2890: "<provider> does not incude authorities attribute"
  1905: parseActivityAlias(owner, res, parser, attrs, flags, outError) == null
  1917: parseMetaData(res, parser, attrs, owner.mAppMetaData, outError) == null
  1969: "Bad element under <application>: "+tagName

遗憾的是,您必须在 logcat 和源代码中查找才能找出导致问题的原因。

The INSTALL_PARSE_FAILED_MANIFEST_MALFORMED error code is returned by PackageParser.java
when it detects any of a large number of errors in the manifest.xml file.

To isolate the error, look in logcat (when you do the 'adb install foo.apk' command). In the problem I encountered, logcat contained:

W/ActivityManager(  360): No content provider found for permission revoke: file:///data/local/tmp/foo.apk
D/Finsky  (32707): [1] PackageVerificationReceiver.onReceive: Verification requested, id = 6
D/Finsky  (32707): [1] WorkerTask.onPreExecute: Verification Requested for id = 6,   data=file:///data/local/tmp/foo.apk flags=112 fromVerificationActivity=false
W/PackageParser(32707): /data/local/tmp/foo.apk (at Binary XML file line #214): <provider> does not include authorities attribute
D/Finsky  (32707): [716] PackageVerificationService.getPackageInfo: Cannot read archive for file:///data/local/tmp/foo.apk in request id=6
D/Finsky  (32707): [1] PackageVerificationReceiver.onReceive: Verification requested, id = 6
W/ActivityManager(  360): No content provider found for permission revoke: file:///data/local/tmp/foo.apk
I/PackageManager(  360): Copying native libraries to /data/app-lib/vmdl1205566381
W/PackageParser(  360): /data/app/vmdl1205566381.tmp (at Binary XML file line #214): <provider> does not include authorities attribute

In the fourth line above, you can see that PackageParser complains that line #214 of the manifest.xml file "<provider> does not include authorities attribute". See the listing below of all the cases in PackageParser that returns that error code. (PackageParser is the only class that produces the PackageManager.INSTALL_PARSE_FAILED_MANIFEST_MALFORMED error code)

In my case the message "<provider> does not include authorities attribute" is produced by line 2490 of PackagerParser.java in the parseProvider function called by parseApplication.


From the 4.1.1 version of frameworks/base/core/java/android/content/pm/PackageParser.java, PackageManager.INSTALL_PARSE_FAILED_MANIFEST_MALFORMED is referenced on these lines in these methods. If the source code line number is followed by a quoted string that is the message printed in logcat. if the line number is followed by a Java expression that is the code that caused that error code to be returned that that function should be investigated to see what caused the error message to be returned. In a couple cases I couldn't isolate the error cause to one specific method call.

in parsePackage:
  536:  (only used in 'core apps' with no 'pkg')
  973:  "<manifest> has more than one <application>"
  1275: "Bad element under <manifest>: "      --if RIGID_PARSER

in parsePermissionGroup:
  1464: !parsePackageItemInfo(owner, perm.info, outError,
    "<permission-group>", sa,
    com.android.internal.R.styleable.AndroidManifestPermissionGroup_name,
    com.android.internal.R.styleable.AndroidManifestPermissionGroup_label,
    com.android.internal.R.styleable.AndroidManifestPermissionGroup_icon,
    com.android.internal.R.styleable.AndroidManifestPermissionGroup_logo)
  1482: !parseAllMetaData(res, parser, attrs, "<permission-group>", perm,
    outError)

in parsePermission:
  1506: !parsePackageItemInfo(owner, perm.info, outError,
    "<permission>", sa,
    com.android.internal.R.styleable.AndroidManifestPermission_name,
    com.android.internal.R.styleable.AndroidManifestPermission_label,
    com.android.internal.R.styleable.AndroidManifestPermission_icon,
    com.android.internal.R.styleable.AndroidManifestPermission_logo)
  1530: "<permission> does not specify protectionLevel"
  1541: "<permission>  protectionLevel specifies a flag but is not based on signature type"
  1548: !parseAllMetaData(res, parser, attrs, "<permission>", perm, outError)

in parsePersmissionTree:
  1572: !parsePackageItemInfo(owner, perm.info, outError,
    "<permission-tree>", sa,
    com.android.internal.R.styleable.AndroidManifestPermissionTree_name,
    com.android.internal.R.styleable.AndroidManifestPermissionTree_label,
    com.android.internal.R.styleable.AndroidManifestPermissionTree_icon,
    com.android.internal.R.styleable.AndroidManifestPermissionTree_logo)
  1585: "<permission-tree> name has less than three segments: "+perm.info.name
  1595: !parseAllMetaData(res, parser, attrs, "<permission-tree>", perm, outError)

in parseInstrumentation:
  1625: new Instrumentation(mParseInstrumentationArgs, new InstrumentationInfo())
  1648: "<instrumentation> does not specify targetPackage"
  1654: !parseAllMetaData(res, parser, attrs, "<instrumentation>", a, outError)

in parseApplication:
  1678: buildClassName(pkgName, name, outError) == null
  1851: (Set by various other functions)
  1869: parseActivity(owner, res, parser, attrs, flags, outError, false, hardwareAccelerated) == null
  1878: parseActivity(owner, res, parser, attrs, flags, outError, true, false) == null
  1887: parseService(owner, res, parser, attrs, flags, outError) == null
  1896: parseProvider(owner, res, parser, attrs, flags, outError) == null
    2484: "Heavy-weight applications can not have providers in main process"
    2890: "<provider> does not incude authorities attribute"
  1905: parseActivityAlias(owner, res, parser, attrs, flags, outError) == null
  1917: parseMetaData(res, parser, attrs, owner.mAppMetaData, outError) == null
  1969: "Bad element under <application>: "+tagName

It's regrettable that you have to poke around in logcat and the source to figure out what causes a problem.

峩卟喜欢 2024-11-14 21:38:12

我遇到此错误是因为

Com.Example.packagename

在我将其更改为类似

com.example.packagename

解决方案后,我的包名称中有大写字母

I was having this error because i had capital letters in my package name like this

Com.Example.packagename

after i had changed it to something like

com.example.packagename

it was solved

不打扰别人 2024-11-14 21:38:12

像这样添加

android:exported="true"

到 Manifest.xml 中的活动中

<activity
    android:name=".MainActivity"
    android:exported="true">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
</activity>

Add

android:exported="true"

to your activity in Manifest.xml

Like this;

<activity
    android:name=".MainActivity"
    android:exported="true">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
</activity>
皇甫轩 2024-11-14 21:38:12

检查清单文件中的活动名称

或主活动/类中的包名称

<activity android:name="MainActivity"></activity>

Check your Activity name in manifest file

or the Package name in main activity/class

<activity android:name="MainActivity"></activity>
自由如风 2024-11-14 21:38:12

我有同样的问题,但是当我这样调用流程时:

<service
    android:name="com.dexode.tama.AppService"
    android:process="screen" >
</service>

当我更改为:

<service
    android:name="com.dexode.tama.AppService"
    android:process=":screen" >
</service>

一切都开始工作。

I have the same issue but when i call process like this:

<service
    android:name="com.dexode.tama.AppService"
    android:process="screen" >
</service>

When i change to:

<service
    android:name="com.dexode.tama.AppService"
    android:process=":screen" >
</service>

Everything starts working.

智商已欠费 2024-11-14 21:38:12

我不久前遇到了同样的问题,在 android docs 他们说如果你在android:process中不使用“:”作为前缀,你应该使用小写字母,但他们从来没有这么说过,那么它应该是一个像包一样的进程名称,就像com.company.app.services.MyService

I ran into the same problem time ago, in the android docs they said that if you don't use ":" as prefix in android:process you should use a lower case letter, but they never said that, then it should be a package like process name, like com.company.app.services.MyService

深府石板幽径 2024-11-14 21:38:12

任何名称,例如 android:nameandroid:process 都应采用包名称的形式:以 a..z 开头,与其他名称组合以 . 结尾,不要以 . 结尾...

Any name such as android:name, android:process should be in form of package name: starts with a..z, combines with others with ., do not end with ....

黯淡〆 2024-11-14 21:38:12

写了(注意 - 与 _):。

<meta_data ... /> 
<!-- instead of -->
<meta-data ... />

我的问题是我在一项活动下 这也可能是导致您出现问题的原因。

My issue was that I had written (Notice the - vs. the _):

<meta_data ... /> 
<!-- instead of -->
<meta-data ... />

under an activity. This might be the cause of your issue as well.

ペ泪落弦音 2024-11-14 21:38:12

阅读您的 Android 设备日志来诊断此错误。期待“W/PackageParser”行解释该问题。

Read your Android device logs to diagnose this error. Expect a "W/PackageParser" line explaining the problem.

倦话 2024-11-14 21:38:12

就我而言,我指的是使用如下属性的图标:

<meta-data android:name="com.google.firebase.messaging.default_notification_icon" android:resource="?attr/ic_notify" />

而不是可绘制的:

<meta-data android:name="com.google.firebase.messaging.default_notification_icon" android:resource="@drawable/ic_notify" />

我在多个地方使用此属性,但它似乎在清单中不起作用。

In my case I was referring to an icon using an attribute like this:

<meta-data android:name="com.google.firebase.messaging.default_notification_icon" android:resource="?attr/ic_notify" />

instead of the drawable:

<meta-data android:name="com.google.firebase.messaging.default_notification_icon" android:resource="@drawable/ic_notify" />

I am using this attribute in several places but it seems it does not work in manifest.

度的依靠╰つ 2024-11-14 21:38:12
        <activity android:name=".MainActivity"
        android:exported="true">
        <intent-filter>
            <action android:name="android.intent.action.MAIN"/>

            <category android:name="android.intent.category.LAUNCHER"/>
        </intent-filter>
    </activity>

如果您使用目标API 31+,则必须添加导出true

        <activity android:name=".MainActivity"
        android:exported="true">
        <intent-filter>
            <action android:name="android.intent.action.MAIN"/>

            <category android:name="android.intent.category.LAUNCHER"/>
        </intent-filter>
    </activity>

if you're using target API 31+ you have to add exported with true

攒一口袋星星 2024-11-14 21:38:12

由于以下代码,我遇到了此错误:

<intent-filter>
     <action android:name="android.intent.action.VIEW" />
     <category android:name="android.intent.category.DEFAULT" />
     <data android:mimeType="*" android:host="*" android:scheme="content" />
</intent-filter>

当我将 android:mimeType="*" 更改为 android:mimeType="*/*" 时,它修复了该错误。

I had this error because of the code below:

<intent-filter>
     <action android:name="android.intent.action.VIEW" />
     <category android:name="android.intent.category.DEFAULT" />
     <data android:mimeType="*" android:host="*" android:scheme="content" />
</intent-filter>

When I changed android:mimeType="*" to android:mimeType="*/*", it fixed the error.

无畏 2024-11-14 21:38:12

遇到同样的错误!
有空的权限标签,这就是导致问题的原因!

Got the same error!
had empty permission tag and that was causing the problem!

零崎曲识 2024-11-14 21:38:12

添加本地化后,我遇到了同样的问题

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="my.package"
    android:versionCode="10"
    android:versionName="@string/version_name" >

字符串 @string/version_name 意外传递到新添加的本地化字符串文件之一(它仅出现在新文件中)。
检查所有本地化并从除 eng 语言环境之外的每个文件中删除 @string/version_name 后,一切再次正常工作

I run into the same problem after adding localizations

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="my.package"
    android:versionCode="10"
    android:versionName="@string/version_name" >

The string @string/version_name accidentally passed into one of new added localized string-file (it appeared only in the new files).
After checking all the localizations and removing @string/version_name from every file except eng locale everything worked again

久而酒知 2024-11-14 21:38:12
<activity/>

必须在之前定义

<activity-alias/>
<activity/>

must be defined BEFORE

<activity-alias/>
猫腻 2024-11-14 21:38:12

活动创建的名称文件夹必须是小写字母,不要使用大写字母作为活动文件夹名称......使用小写字母总是更好。

activity created name folder must be small letters, Dont use capital letters for activity folder name.... its always better to use small letters.

猫烠⑼条掵仅有一顆心 2024-11-14 21:38:12

这可能有很多原因,但对我来说,这是通过将包的名称更改为小写名称来解决的(包名称是“活动”,用“活动”解决)。

this can be for many reasons , but for me it was solved by changing the name of package with lowercase name (package name was Activities , solved with activities) .

涫野音 2024-11-14 21:38:12

[解决方案]
转到您的项目文件夹并打开 AndroidManifest.xml 文件

中添加以下代码

在活动android:exported="true"

示例

<activity
 android:name=".MainActivity"
 android:exported="true"
 android:launchMode="singleTop"
 android:theme="@style/LaunchTheme"
</activity>

[Solution]
Go to your project folder and open AndroidManifest.xml file

Add the below code in activity

android:exported="true"

Example

<activity
 android:name=".MainActivity"
 android:exported="true"
 android:launchMode="singleTop"
 android:theme="@style/LaunchTheme"
</activity>
皓月长歌 2024-11-14 21:38:12

如果您在清单中使用 multidex,则应为其添加值或资源。
就像..

<meta-data android:name="android.support.multidex.MultiDexApplication"
android:value="@string/yourValue" />

或者

<meta-data android:name="android.support.multidex.MultiDexApplication"
android:resource="@string/yourValue" />

然后清理项目并重新安装应用程序。

If you are using multidex in manifest then it should be added with value or resource.
Like..

<meta-data android:name="android.support.multidex.MultiDexApplication"
android:value="@string/yourValue" />

OR

<meta-data android:name="android.support.multidex.MultiDexApplication"
android:resource="@string/yourValue" />

then clean the project and reinstall the app.

梦幻的心爱 2024-11-14 21:38:12

我创建了一个新应用程序并将其定位到 Android Pie。一切都运行良好,但最近我发现我的应用程序无法安装到 Android 操作系统的 Android Naught 及以下版本

安装时,我看到失败消息

安装失败,并显示消息 INSTALL_PARSE_FAILED_MANIFEST_MALFORMED。

因此,我所做的修复如下,它们都只需要在 AndroidManifest.xml 文件中完成。

对于活动、服务、接收器和所有

Instead of:
    android:name=".service.MyService"

Used: 
    android:name="com.complete.appicationID.service.MyService"

清单权限,

Instead of: 
     <uses-permission android:name="{applicationId}.permission.MAPS_RECEIVE" />
     <permission
         android:name="{applicationId}.permission.MAPS_RECEIVE"
         android:protectionLevel="signature" />

Used:
     <uses-permission android:name="com.complete.appicationID.permission.MAPS_RECEIVE" />
     <permission
         android:name="com.complete.appicationID.permission.MAPS_RECEIVE"
         android:protectionLevel="signature" />

这些都是我必须执行的更改,以使其也适用于较低版本的设备。

I create a new application and target it to Android Pie. Everything was working well and good then lately I found that my application don't installs to Android Naught and below version of Android OS.

While installing, I see failure message

Installation failed with message INSTALL_PARSE_FAILED_MANIFEST_MALFORMED.

So what fixes which I made are as follow and they all need to be done in AndroidManifest.xml file only.

For activity, service, receiver and all

Instead of:
    android:name=".service.MyService"

Used: 
    android:name="com.complete.appicationID.service.MyService"

For Manifest permissions

Instead of: 
     <uses-permission android:name="{applicationId}.permission.MAPS_RECEIVE" />
     <permission
         android:name="{applicationId}.permission.MAPS_RECEIVE"
         android:protectionLevel="signature" />

Used:
     <uses-permission android:name="com.complete.appicationID.permission.MAPS_RECEIVE" />
     <permission
         android:name="com.complete.appicationID.permission.MAPS_RECEIVE"
         android:protectionLevel="signature" />

That were all changes which I had to perform to make it work for lower version devices as well.

一紙繁鸢 2024-11-14 21:38:12

需要在 之前指定目标

Target <activity> needs to be specified before the <activity-alias>.

影子是时光的心 2024-11-14 21:38:12

如果您在 Android 12 或 Android S 中使用目标 api 31 或 32,那么您会遇到此错误,请解决此问题

将此行添加到 laucher Activity in Manifest

android:exported="true"

该元素设置 Activity 是否可以由其他应用程序的组件启动:

  • 如果“true”,则任何应用程序都可以访问该 Activity,并且可发射的
    通过其确切的类名称。
  • 如果“false”,则该活动只能由
    相同的应用程序、具有相同用户 ID 或特权的应用程序
    系统组件。当没有意图时这是默认值
    过滤器。

是否应为此 Activity 启用硬件加速渲染 — 如果应启用则为“true”,否则为“false”。默认值为“假”。

<activity
    android:name=".MainActivity"
    android:exported="true">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
</activity>

if you're using target api 31 or 32 in Android 12 or Android S so you'd face this error to solve this

Add this line to the laucher activity in Manifest

android:exported="true"

This element sets whether the activity can be launched by components of other applications:

  • If "true", the activity is accessible to any app, and is launchable
    by its exact class name.
  • If "false", the activity can be launched only by components of the
    same application, applications with the same user ID, or privileged
    system components. This is the default value when there are no intent
    filters.

Whether or not hardware-accelerated rendering should be enabled for this Activity — "true" if it should be enabled, and "false" if not. The default value is "false".

<activity
    android:name=".MainActivity"
    android:exported="true">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
</activity>
潦草背影 2024-11-14 21:38:12

我在 Android 12 上遇到了同样的问题,并修复了这个问题:

如果您的应用程序以 Android 12 或更高版本为目标,并且包含使用意图过滤器的活动、服务或广播接收器,则必须为这些应用程序组件显式声明 android:exported 属性。
如果应用程序组件包含 LAUNCHER 类别,请将 android:exported 设置为 true。在大多数其他情况下,将 android:exported 设置为 false。

我还更新了第三方依赖项。

I had same issue on Android 12 and fixed it this:

If your app targets Android 12 or higher and contains activities, services, or broadcast receivers that use intent filters, you must explicitly declare the android:exported attribute for these app components.
If the app component includes the LAUNCHER category, set android:exported to true. In most other cases, set android:exported to false.

Also I updated third party Dependencies.

笑饮青盏花 2024-11-14 21:38:12

如果您有 AndroidStudio 4.1.2 尝试添加:
android:exported="true" &文件“AndroidManifest.xml”中的 android.name=".MainActivity"

平台/android/AndroidManifest.xml

您的应用程序 &活动应该是这样的:

<application .....
  <activity android:exported="true" android:name=".MainActivity" 

If you have AndroidStudio 4.1.2 try to add :
android:exported="true" & android.name=".MainActivity" in the file "AndroidManifest.xml"

platform/android/AndroidManifest.xml

Your application & activity should seen be this way:

<application .....
  <activity android:exported="true" android:name=".MainActivity" 
一抹微笑 2024-11-14 21:38:12

问题

INSTALL_PARSE_FAILED_MANIFEST_MALFORMED 错误仅表明您的清单(或项目和依赖项中的清单之一)中存在错误,当应用程序被推送到模拟器或设备进行安装。

Installation failed due to: 'INSTALL_PARSE_FAILED_MANIFEST_MALFORMED: 

这些运行时错误不会阻止 Android Studio 中项目的编译,因此乍一看您会看到“构建成功”,一切看起来都很好。

找到实际的根源

最好的解决方案是首先确保您拥有最新的构建工具。这将增加获得如下所示的正确错误详细信息的可能性。您可以通过打开 Android Studio 底部的“运行”选项卡来查看安装 adb 命令的结果。

Installation failed due to: 'INSTALL_PARSE_FAILED_MANIFEST_MALFORMED: Failed parse during installPackageLI: /data/app/vmdl1428212790.tmp/base.apk (at Binary XML file line #96): be.hcpl.android.phototools.links.AddLinkActivity: Targeting S+ (version 31 and above) requires that an explicit value for android:exported be defined when intent filters are present'

使用所有默认设置,该窗口应在运行应用程序后打开。如果没有,则可以在此处找到它(也在默认布局上)。

android studio run tab

我也将完整的错误消息粘贴到此处,以便您可以清楚地看到,在我的情况下,详细消息清楚地表明清单中的问题是什么。这里; AddLinkActivity 活动声明中缺少 export 标记。

替代方法

如果由于某种原因,该详细消息丢失或不够清晰,无法指出根本原因,则替代方法是打开项目中的 AndroidManifest.xml 文件,然后打开 问题选项卡。

输入图片此处描述

此视图是当选择当前文件时在该特定文件上发现的所有错误和警告的列表。

在文件本身中,您还可以看到编辑器中标记了 Activity 声明。包括一个快速修复工具提示以添加缺少的 export 标签。

The Problem

This INSTALL_PARSE_FAILED_MANIFEST_MALFORMED error only indicates there is an error within your manifest (or one of the manifests in your project & dependencies) that manifested (pun intended) itself when the app was pushed to an emulator or device for installation.

Installation failed due to: 'INSTALL_PARSE_FAILED_MANIFEST_MALFORMED: 

These runtime errors won't block compilation of the the project within Android Studio so at first view you get a Build Success and everything seems fine.

Finding the actual root source

Best solution is to start by making sure you have the latest build tools. That will increase the likelihood of having a proper error detail message like the one listed below. You can find this by opening the Run tab at the bottom in Android Studio to see the outcome of the installation adb commands.

Installation failed due to: 'INSTALL_PARSE_FAILED_MANIFEST_MALFORMED: Failed parse during installPackageLI: /data/app/vmdl1428212790.tmp/base.apk (at Binary XML file line #96): be.hcpl.android.phototools.links.AddLinkActivity: Targeting S+ (version 31 and above) requires that an explicit value for android:exported be defined when intent filters are present'

With all default settings this window should open after running the app. If not this is where to find it (also on a default layout that is).

android studio run tab

I've pasted the full error message here also so you can clearly see that in my case the detail message clearly indicates what the issue in the manifest is. Here; a missing export tag on the AddLinkActivity activity declaration.

Alternative Approach

If, for whatever reason, that detail message is missing or not clear enough to point to the root cause an alternative approach is to open the AndroidManifest.xml file in your project and then open the Problems tab.

enter image description here

This view is a list of all the errors and warnings found on that specific file, when Current File is selected.

In the file itself you can also see that the Activity declaration is marked in the editor. Including a quick fix tooltip to add the missing export tag.

不知在何时 2024-11-14 21:38:12

可能还有其他格式错误但未在 IDE 中突出显示的文件,例如清单可能会引用标签等内容的 res/values/strings。

There could be other files that are malformed but aren't highlighted in the IDE, for example the res/values/strings which the manifest may reference for things like labels.

隐诗 2024-11-14 21:38:12

就我而言,原因是 << 中缺少 android:name 属性。活动别名>。
这是强制性的<活动别名>尽管它不能命名现有的类。
有趣的是 - 该项目编译没有问题。

In my case the cause was absence of android:name attribute in < activity-alias >.
It is obligatory for < activity-alias > although it must not name an existing class.
Funny thing is - the project compiles without problems.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文