简体   繁体   中英

Error between manifests with my app and library

I am writing an Android Library that uses Sugar Orm to store stuff into the SQLite database. The AndroidManifest.xml of my Android Library.

The error I get are:

Error:(13, 9) Attribute application@name value=(com.example.app.App) from AndroidManifest.xml:13:9
Error:(20, 13) Attribute meta-data#DATABASE@value value=(test_car.db) from AndroidManifest.xml:20:13
Error:(23, 13) Attribute meta-data#VERSION@value value=(4) from AndroidManifest.xml:23:13
Error:(29, 13) Attribute meta-data#DOMAIN_PACKAGE_NAME@value value=(com.example.app) from AndroidManifest.xml:29:13

It says " Suggestion: add 'tools:replace="android:value"' to element at AndroidManifest.xml:21:9 to override"

How would I solve this?

The Main App uses:

<application
        android:name=".App"
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme">
        <meta-data
            android:name="DATABASE"
            android:value="example_scans.db" />
        <meta-data
            android:name="VERSION"
            android:value="4" />
        <meta-data
            android:name="QUERY_LOG"
            android:value="true" />
        <meta-data
            android:name="DOMAIN_PACKAGE_NAME"
            android:value="com.example.usps" />

My Library Uses:

 <application
        android:allowBackup="true"
        android:label="@string/app_name"
        android:name="com.orm.SugarApp">

        <meta-data android:name="DATABASE" android:value="example_logs.db" />
        <meta-data android:name="VERSION" android:value="3" />
        <meta-data android:name="QUERY_LOG" android:value="true" />
        <meta-data android:name="DOMAIN_PACKAGE_NAME" android:value="com.example.usps" />

In your manifest file try adding xmlns:tools="http://schemas.android.com/apk/res-auto" in your manifest tag, then add in your application tag tools:replace="label" .

Something like this:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/apk/res-auto"
      package="yourpackage">
    <application
        android:name=".App"
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme"
        tools:replace="label">
        <meta-data
            android:name="DATABASE"
            android:value="example_scans.db" />
        <meta-data
            android:name="VERSION"
            android:value="4" />
        <meta-data
            android:name="QUERY_LOG"
            android:value="true" />
        <meta-data
            android:name="DOMAIN_PACKAGE_NAME"
            android:value="com.example.usps" />

        ...other stuff....
</manifest>

EDIT

I checked on my sample project and updating Sugar library to version 1.3.1 resolved this problem. If you are using gradle, please use:

compile 'com.github.satyan:sugar:1.3.1'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM