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.