5

I'm trying to make update for my application that will be delivered through own server. Everything goes well until updating process which says: Parse error - There was a problem parcing the package.

From logcat

PackageParser: Unknown element under <manifest>: meta-data at

and looking with aapt

  A: android:name(0x01010003)="android.permission.MANAGE_USB" (Raw: "android.permission.MANAGE_USB")
E: meta-data (line=21)
  A: android:name(0x01010003)="android.support.VERSION" (Raw: "android.support.VERSION")

One post from same issue suggested that Instant run feature should be disabled but still no go.

I have latest AS and latest updates on it.

meta-data part in my app/src/main/AndroidManifest.xml is

<meta-data
android:name="android.app.device_admin"
android:resource="@xml/device_admin_receiver" />

Another post has discussion also about the meta-data and how it should include name and resource but in my meta-data there is both so that could not be the issue.

I also looked from manifest-merger-release-report.txt

meta-data#android.support.VERSION
ADDED from [com.android.support:appcompat-v7:25.3.1] /home/test/.android/build-cache/0babb927f9685604721e7d79f796b3104e7aa65c/output/AndroidManifest.xml:25:5-27:34
MERGED from [com.android.support:support-v4:25.3.1] /home/test/.android/build-cache/c982b10f45110a04eb75ca3351098dfbfe082732/output/AndroidManifest.xml:25:5-27:34

and from app/build/intermediates/manifests/full/release/AndroidManifest.xml it has:

<uses-permission android:name="android.permission.MANAGE_USB" />

<meta-data
    android:name="android.support.VERSION"
    android:value="25.3.1" />

<application

I have external libraries

compile 'com.fasterxml.jackson.core:jackson-core:2.9.0'
compile 'com.fasterxml.jackson.core:jackson-databind:2.9.0'
compile 'com.fasterxml.jackson.core:jackson-annotations:2.9.0'
compile 'uk.co.chrisjenx:calligraphy:2.3.0'

and CarouselLayoutManager as module which have

compile 'com.android.support:recyclerview-v7:25.3.1'

I have tried to find root cause for this but all guides, hints and tips came to dead end.

Update 1 Here is full AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.xxx.yyy.app_android">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.MANAGE_DEVICE_ADMINS" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.INSTALL_PACKAGES" />
<uses-permission android:name="android.permission.MANAGE_USB" />

<application
    android:fitsSystemWindows="true"
    android:allowBackup="false"
    android:icon="@mipmap/icon"
    android:supportsRtl="true"
    android:label="@string/app_name"
    android:name=".ui.App"
    android:theme="@style/SplashTheme"
    android:windowSoftInputMode="adjustNothing"
    tools:ignore="GoogleAppIndexingWarning">
    <activity android:name=".ui.SplashActivity">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity android:name=".ui.USBDeviceConnectionActivity" />
    <activity android:name=".ui.MainActivity" />
    <activity android:name=".ui.MainAppViewActivity" />
    <activity android:name=".ui.InstructionsActivity" />

    <service android:name=".machine.AdjustSeatHeightService" />
    <service android:name=".machine.AdjustPressureService"/>
    <service android:name=".machine.RFIDService"
        android:exported="false" />
    <service android:name=".machine.MVUControlService"
        android:exported="false" />
    <service android:name=".machine.PressureNModeControlService"
        android:exported="false" />
    <service android:name=".machine.MachModeChangeService"
        android:exported="false" />
    <service android:name=".machine.ReadMotorPos"
        android:exported="false" />

    <receiver
        android:name=".ui.DeviceAdminReceiver"
        android:description="@string/app_name"
        android:label="@string/app_name"
        android:permission="android.permission.BIND_DEVICE_ADMIN">
        <meta-data
            android:name="android.app.device_admin"
            android:resource="@xml/device_admin_receiver" />
        <intent-filter>
            <action android:name="android.intent.action.DEVICE_ADMIN_ENABLED"/>
            <action android:name="android.intent.action.PROFILE_PROVISIONING_COMPLETE"/>
            <action android:name="android.intent.action.BOOT_COMPLETED"/>
            <action android:name="android.app.action.DEVICE_ADMIN_ENABLED" />
            <action android:name="android.app.action.DEVICE_ADMIN_DISABLED" />
        </intent-filter>
    </receiver>

    <!-- Start the Service if applicable on boot -->
    <receiver android:name=".ui.BootReceiver">
        <intent-filter >
            <action android:name="android.intent.action.BOOT_COMPLETED"/>
        </intent-filter>
    </receiver>
</application>
</manifest>

Update 2

Replaced recyclerview-v7 version from 25.3.1 to 25.3.0 and now i'm getting this error. From my guess is that problematic meta-data comes from appcompat-v7 but i don't know how it's getting included and why it's going wrong place when merging AndroidManifest files.

Error:Execution failed for task ':app:processDebugManifest'.
> Manifest merger failed : Attribute meta-data#android.support.VERSION@value value=(25.3.1) from [com.android.support:appcompat-v7:25.3.1] AndroidManifest.xml:27:9-31
is also present at [com.android.support:recyclerview-v7:25.3.0] AndroidManifest.xml:24:9-31 value=(25.3.0).
Suggestion: add 'tools:replace="android:value"' to <meta-data> element at AndroidManifest.xml:25:5-27:34 to override.

Update 3

Ok. Seems that problem is external module that i have taken into build. For some reason androidManifest.xml get merged from it which brings that extra meta-data information.

Update 4 Removed external module and it's still problem is coming. It seems that problem is com.android.support:recyclerview-v7:25.3.1 but i'm not sure why.

Update 5 Found the problem. It seems that supportlibraries 25.3.0 and newer brings changes on their manifest files:

 <manifest package="android.support.v7.appcompat">
    <uses-sdk android:minSdkVersion="9" tools:overrideLibrary="android.support.graphics.drawable.animated"/>
    <meta-data android:name="android.support.VERSION" android:value="25.3.0"/>
    <application/>
 </manifest>

meta-data is not under application tags there and it gets injected to wrong place in final AndroidManifest.xml when creating APK.

Now i just have to figure out how to revert back to earlier support libraries as i get notification that i have mismatching versions from other libraries that are not included. :(

Juge
  • 536
  • 8
  • 21

1 Answers1

0

According to this android reference meta data tags are contained with in the below tags

<activity> 
<activity-alias> 
<application> 
<provider> 
<receiver> 
<service>

But your tag is out side any of these. The error you posted is

PackageParser: Unknown element under <manifest>: meta-data

So the tag is placed directly under <manifest> tag which is causing the issue.

So please move it into <application> tag and it will work.