升级Gradle后的清单错误

时间:2018-05-08 08:10:09

标签: android

我最近决定将我的Android项目升级到gradle 4.4(因为插孔太慢了),但我现在有另一个问题。

请不要回复“android.enableAapt2 = false”,因为这不是解决方案,它基本上只是忽略了所有这些错误。

50%的AndroidManifest.xml报告错误。 (你可以看到下面的内容)

    <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="app.puresecure"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="19"
        android:targetSdkVersion="26" />

    <provider
        android:name="app.puresecure.MailSender"
        android:authorities="com.purescure.MailSender"
        android:enabled="true"
        android:exported="true"
        android:grantUriPermissions="true" />

    <supports-screens
        android:largeScreens="true"
        android:normalScreens="true"
        android:smallScreens="true"
        android:xlargeScreens="true" />

    <uses-feature
        android:name="android.hardware.camera2"
        android:required="true" />

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

    <uses-feature android:name="android.hardware.camera" />

    <supports-screens
        android:largeScreens="true"
        android:normalScreens="true"
        android:smallScreens="true"
        android:xlargeScreens="true" />

    <uses-permission android:name="android.Manifest.permission.READ_PHONE_STATE" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.READ_PHONE_STATE" />
    <uses-permission android:name="android.Manifest.permission.READ_PHONE_STATE" />
    <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
    <uses-permission android:name="android.permission.READ_PHONE_STATE" />
    <uses-permission android:name="android.permission.DEVICE_POWER" />

    <!-- Optional permission for Analytics to run. -->
    <uses-permission android:name="android.permission.WAKE_LOCK" /> <!-- Required by older versions of Google Play services to create GCM registration tokens -->
    <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />

    <uses-feature
        android:glEsVersion="0x00020000"
        android:required="true" />

    <permission
        android:name="app.puresecure.permission.C2D_MESSAGE"
        android:protectionLevel="signature" />

    <uses-permission android:name="app.puresecure.permission.C2D_MESSAGE" />

    <application
        android:allowBackup="true"
        android:debuggable="true"
        android:icon="@drawable/logo_transparent"
        android:label="PureSecure"
        android:roundIcon="@drawable/logo_transparent"
        android:supportsRtl="true"
        android:testOnly="true"
        android:theme="@style/AppTheme" >
        <activity
            android:name="app.puresecure.DevicesActivity"
            android:label="My devices"
            android:theme="@style/AppTheme.NoActionBar" />
        <activity
            android:name="app.puresecure.SignupActivity"
            android:label="Sign up" />
        <activity
            android:name="app.puresecure.LoginActivity"
            android:label="PureSecure" />

        <meta-data
            android:name="com.google.android.geo.API_KEY"
            android:value="@string/google_maps_key" />

        <activity
            android:name="app.puresecure.MapsActivity"
            android:label="@string/title_activity_maps" />
        <activity
            android:name="app.puresecure.MainScreen"
            android:label="Device Info"
            android:theme="@style/AppTheme.NoActionBar" />

        <service android:name="app.puresecure.BackgroundService" />

        <receiver
            android:name="app.puresecure.DeviceAdmin"
            android:permission="android.permission.BIND_DEVICE_ADMIN" >
            <meta-data
                android:name="android.app.device_admin"
                android:resource="@xml/device_admin_policies" />

            <intent-filter>
                <action android:name="android.app.action.DEVICE_ADMIN_ENABLED" />
            </intent-filter>
        </receiver>

        <activity android:name="app.puresecure.PINActivity" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <intent-filter>
                    <action android:name="android.intent.action.MAIN" />

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

                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name="app.puresecure.SetPINActivity" />
        <activity
            android:name="app.puresecure.GoingOutActivity"
            android:theme="@style/AppTheme.NoActionBar" />
        <activity android:name="app.puresecure.ControlActivity" />
        <activity
            android:name="app.puresecure.FriendsActivity"
            android:label="Friends"
            android:theme="@style/AppTheme.NoActionBar" />

        <!--
            <service
            android:name=".PictureCapturingServiceImpl"
            android:enabled="true"
            android:exported="true" />
        -->

        <activity
            android:name="app.puresecure.Splash"
            android:label="Settings" />
        <activity android:name="app.puresecure.SettingsActivity" />
        <activity android:name="app.puresecure.LocationActivity" />

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

        <receiver android:name="com.google.android.gms.cast.framework.media.MediaIntentReceiver" />

        <service android:name="com.google.android.gms.cast.framework.media.MediaNotificationService" />
        <service android:name="com.google.android.gms.cast.framework.ReconnectionService" /> <!-- Include the AdActivity and InAppPurchaseActivity configChanges and themes. -->
        <activity
            android:name="com.google.android.gms.ads.AdActivity"
            android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
            android:exported="false"
            android:theme="@android:style/Theme.Translucent" />

        <receiver
            android:name="com.google.android.gms.analytics.AnalyticsReceiver"
            android:enabled="true"
            android:exported="false" >
        </receiver>

        <service
            android:name="com.google.android.gms.analytics.AnalyticsService"
            android:enabled="true"
            android:exported="false" />
        <service
            android:name="com.google.android.gms.analytics.AnalyticsJobService"
            android:enabled="true"
            android:exported="false"
            android:permission="android.permission.BIND_JOB_SERVICE" />

        <activity
            android:name="com.google.android.gms.appinvite.PreviewActivity"
            android:exported="true"
            android:theme="@style/Theme.AppInvite.Preview" >
            <intent-filter>
                <action android:name="com.google.android.gms.appinvite.ACTION_PREVIEW" />

                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>
        <activity
            android:name="com.google.android.gms.auth.api.signin.internal.SignInHubActivity"
            android:excludeFromRecents="true"
            android:exported="false"
            android:theme="@android:style/Theme.Translucent.NoTitleBar" />
        <!--
            Service handling Google Sign-In user revocation. For apps that do not integrate with
            Google Sign-In, this service will never be started.
        -->
        <service
            android:name="com.google.android.gms.auth.api.signin.RevocationBoundService"
            android:exported="true"
            android:permission="com.google.android.gms.auth.api.signin.permission.REVOCATION_NOTIFICATION" />

        <activity
            android:name="com.google.firebase.auth.internal.FederatedSignInActivity"
            android:excludeFromRecents="true"
            android:exported="true"
            android:launchMode="singleInstance"
            android:permission="com.google.firebase.auth.api.gms.permission.LAUNCH_FEDERATED_SIGN_IN"
            android:theme="@android:style/Theme.Translucent.NoTitleBar" />
        <activity
            android:name="com.google.android.gms.common.api.GoogleApiActivity"
            android:exported="false"
            android:theme="@android:style/Theme.Translucent.NoTitleBar" />
        <!--
             FirebaseMessagingService performs security checks at runtime,
             no need for explicit permissions despite exported="true"
        -->
        <service
            android:name="com.google.firebase.messaging.FirebaseMessagingService"
            android:exported="true" >
            <intent-filter android:priority="-500" >
                <action android:name="com.google.firebase.MESSAGING_EVENT" />
            </intent-filter>
        </service>
        <service
            android:name="com.google.android.gms.tagmanager.TagManagerService"
            android:enabled="true"
            android:exported="false" />

        <activity
            android:name="com.google.android.gms.tagmanager.TagManagerPreviewActivity"
            android:exported="true"
            android:noHistory="true" > <!-- optional, removes the previewActivity from the activity stack. -->
            <intent-filter>
                <data android:scheme="tagmanager.c.app.puresecure" />

                <action android:name="android.intent.action.VIEW" />

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

        <receiver
            android:name="com.google.android.gms.measurement.AppMeasurementReceiver"
            android:enabled="true"
            android:exported="false" >
        </receiver>
        <receiver
            android:name="com.google.android.gms.measurement.AppMeasurementInstallReferrerReceiver"
            android:enabled="true"
            android:exported="true"
            android:permission="android.permission.INSTALL_PACKAGES" >
            <intent-filter>
                <action android:name="com.android.vending.INSTALL_REFERRER" />
            </intent-filter>
        </receiver>

        <service
            android:name="com.google.android.gms.measurement.AppMeasurementService"
            android:enabled="true"
            android:exported="false" />
        <service
            android:name="com.google.android.gms.measurement.AppMeasurementJobService"
            android:enabled="true"
            android:exported="false"
            android:permission="android.permission.BIND_JOB_SERVICE" />

        <receiver
            android:name="com.google.firebase.iid.FirebaseInstanceIdReceiver"
            android:exported="true"
            android:permission="com.google.android.c2dm.permission.SEND" >
            <intent-filter>
                <action android:name="com.google.android.c2dm.intent.RECEIVE" />

                <category android:name="app.puresecure" />
            </intent-filter>
        </receiver>
        <!--
             FirebaseInstanceIdService performs security checks at runtime,
             no need for explicit permissions despite exported="true"
        -->
        <service
            android:name="com.google.firebase.iid.FirebaseInstanceIdService"
            android:exported="true" >
            <intent-filter android:priority="-500" >
                <action android:name="com.google.firebase.INSTANCE_ID_EVENT" />
            </intent-filter>
        </service>

        <provider
            android:name="com.google.firebase.provider.FirebaseInitProvider"
            android:authorities="app.puresecure.firebaseinitprovider"
            android:exported="false"
            android:initOrder="100" />

        <meta-data
            android:name="com.google.android.gms.version"
            android:value="@integer/google_play_services_version" />
        <meta-data
            android:name="android.arch.lifecycle.VERSION"
            android:value="27.0.0-SNAPSHOT" />

        <provider
            android:name="com.android.tools.ir.server.InstantRunContentProvider"
            android:authorities="app.puresecure.com.android.tools.ir.server.InstantRunContentProvider"
            android:multiprocess="true" />
    </application>

</manifest>

我得到的一些错误:

error: unknown element <provider> found.

error: unknown element <intent-filter> found.

Attribute android:theme is not allowed here.

1 个答案:

答案 0 :(得分:0)

此块应位于标记

<provider
    android:name="app.puresecure.MailSender"
    android:authorities="com.purescure.MailSender"
    android:enabled="true"
    android:exported="true"
    android:grantUriPermissions="true" />