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
Pl开发者_如何转开发ease can any one help me to sort out this error.
There could be another reason for this error. The attribute
android:taskAffinity="string"
Should always start with a dot, like:
android:taskAffinity=".string"
Activity name should be prefixed with "." in your manifest file.
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
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.
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.
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>
Check your Activity name in manifest file
or the Package name in main activity/class
<activity android:name="MainActivity"></activity>
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.
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
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 .
...
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.
Read your Android device logs to diagnose this error. Expect a "W/PackageParser" line explaining the problem.
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.
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.
<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
Got the same error! had empty permission tag and that was causing the problem!
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
<activity/>
must be defined BEFORE
<activity-alias/>
activity created name folder must be small letters, Dont use capital letters for activity folder name.... its always better to use small letters.
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) .
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.
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.
Target <activity>
needs to be specified before the <activity-alias>
.
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>
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"
[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>
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.
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.
My problem was as follows:
I was specifying my permissions in the following way and it was not working.
<permission android:name="android.permission.INTERNET">
<meta-data />
</permission>
<permission android:name="android.permission.ACCESS_NETWORK_STATE">
<meta-data />
</permission>
It was working fine when I changed it to be as follows:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
I was having this error because i had the line below.
android:protectionLevel="developer"
After I've changed it to
android:protectionLevel="signature"
issue was solved
精彩评论