7

我正在尝试发布 APK,在尝试生成签名 APK 时出现此错误

Error:Error: Permission name C2D_MESSAGE is not unique (appears in both com.company.myApp.permission.C2D_MESSAGE and com.company.myApp2.permission.C2D_MESSAGE) [UniquePermission]

这是我的清单文件:

<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.company.myApp">

    <permission
        android:name="com.company.myApp.permission.MAPS_RECEIVE"
        android:protectionLevel="signature" />

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

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

    <uses-permission android:name="android.permission.KILL_BACKGROUND_PROCESSES" />
    <uses-permission android:name="android.permission.WRITE_SETTINGS" />
    <uses-permission android:name="android.permission.WRITE_SECURE" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
    <uses-permission android:name="android.permission.CHANGE_CONFIGURATION" />
    <uses-permission android:name="android.permission.READ_PHONE_STATE" />
    <!--<uses-permission android:name="android.permission.INTERNET" />-->
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.CAMERA" />
    <uses-permission android:name="android.permission.GET_TASKS" />
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
    <uses-permission android:name="com.company.myApp.permission.MAPS_RECEIVE" />
    <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
    <uses-permission android:name="android.permission.CLEAR_APP_CACHE" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

    <permission
        android:name="com.company.myApp.permission.C2D_MESSAGE"
        android:protectionLevel="signature" />

    <uses-permission android:name="com.company.myApp.permission.C2D_MESSAGE" />

    <!-- App receives GCM messages. -->
    <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
    <!-- GCM requires a Google account. -->
    <uses-permission android:name="android.permission.GET_ACCOUNTS" />
    <!-- Keeps the processor from sleeping when a message is received. -->
    <uses-permission android:name="android.permission.WAKE_LOCK" />
    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />

    <application
        android:name="com.company.myApp.TruckApplication"
        android:allowBackup="true"
        android:icon="@drawable/myApp_logo"
        android:label="@string/app_name"
        android:largeHeap="true"
        android:sharedUserId="android.uid.system"
        android:theme="@style/AppTheme" >
        <uses-library android:name="com.google.android.maps" />

        <activity
            android:name="com.company.myApp.Authenticate_user_Activity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name="com.company.myApp.Login_Activity"
            android:configChanges="keyboardHidden|orientation|screenSize"
            android:screenOrientation="portrait" >
        </activity>


        <activity
            android:name="com.company.myApp.SubmitWaiver_Activity"
            android:configChanges="keyboardHidden|orientation|screenSize"
            android:screenOrientation="portrait" >
        </activity>
        <activity
            android:name="com.company.myApp.PrepStopChoice"
            android:configChanges="keyboardHidden|orientation|screenSize"
            android:screenOrientation="portrait" >
        </activity>
        <!--<activity-->
            <!--android:name="com.company.myApp.Surveyold_Activity"-->
            <!--android:configChanges="keyboardHidden|orientation|screenSize"-->
            <!--android:screenOrientation="portrait" >-->
        <!--</activity>-->
        <activity
            android:name="com.company.myApp.GetStops_Activity"
            android:configChanges="keyboardHidden|orientation|screenSize"
            android:screenOrientation="portrait" >
        </activity>
        <activity
            android:name="com.company.myApp.Load_Activity"
            android:configChanges="keyboardHidden|orientation|screenSize"
            android:screenOrientation="portrait" >
        </activity>
        <activity
            android:name="com.company.myApp.AddComment_Activity"
            android:configChanges="keyboardHidden|orientation|screenSize"
            android:screenOrientation="portrait"
            android:windowSoftInputMode="adjustResize" >
        </activity>
        <activity
            android:name="com.company.myApp.StopDetail_Activity"
            android:configChanges="keyboardHidden|orientation|screenSize"
            android:screenOrientation="portrait" >
        </activity>
        <activity
            android:name="com.company.myApp.CaptureImage_Activity"
            android:configChanges="keyboardHidden|orientation|screenSize"
            android:screenOrientation="portrait" >
        </activity>
        <activity
            android:name="com.company.myApp.Survey_Activity"
            android:configChanges="orientation|keyboardHidden|screenSize"
            android:screenOrientation="portrait" >
        </activity>
        <activity
            android:name="com.company.myApp.GetDirection_Activity"
            android:configChanges="keyboardHidden|orientation|screenSize"
            android:screenOrientation="portrait" >
        </activity>
        <activity
            android:name="com.company.myApp.Map_FragmentActivity"
            android:configChanges="keyboardHidden|orientation|screenSize"
            android:screenOrientation="portrait" >
        </activity>
        <activity
            android:name="com.company.myApp.TabBar"
            android:configChanges="keyboardHidden|orientation|screenSize"
            android:screenOrientation="portrait" >
        </activity>
        <activity
            android:name="com.company.myApp.ShowStopList_Activity"
            android:configChanges="keyboardHidden|orientation|screenSize"
            android:screenOrientation="portrait" >
        </activity>
        <activity
            android:name="com.company.myApp.PrepActivity"
            android:configChanges="keyboardHidden|orientation|screenSize"
            android:screenOrientation="landscape" >
        </activity>
        <activity
            android:name="com.company.myApp.TransprentActivity"
            android:noHistory="true"
            android:screenOrientation="portrait"
            android:theme="@android:style/Theme.Translucent.NoTitleBar"
            android:windowSoftInputMode="stateHidden|adjustPan" >
        </activity>

        <receiver
            android:name="com.google.android.gcm.GCMBroadcastReceiver"
            android:permission="com.google.android.c2dm.permission.SEND" >
            <intent-filter>
                <action android:name="com.google.android.c2dm.intent.RECEIVE" />
                <action android:name="com.google.android.c2dm.intent.REGISTRATION" />

                <category android:name="com.company.myApp" />
            </intent-filter>
        </receiver>

        <service android:name="com.myApp.Service.SyncService" >
        </service>

        <receiver android:name="com.myApp.BrodcastReciver.NetworkStateReceiver" >
            <intent-filter>
                <action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
            </intent-filter>
        </receiver>
        <receiver android:name="com.company.myApp.RepeatingAlarmService" />
        <receiver android:name="com.company.myApp.RepeatingAlaramCommunication" />
        <receiver android:name="com.company.myApp.ReaptingAlramNewStops" />

        <service android:name="com.myApp.Service.LogoutService" >
        </service>
        <service android:name="com.myApp.Service.CallNewStop_Service" >
        </service>
        <service android:name="com.myApp.Service.CheckingGooglePlayVersionService" >
        </service>

        <receiver
            android:name="com.myApp.BrodcastReciver.DateTimeChangeReceiver"
            android:enabled="true"
            android:exported="false" >
            <intent-filter>
                <action android:name="android.intent.action.DATE_CHANGED" />
            </intent-filter>
        </receiver>

        <!-- Start the Service if applicable on boot -->
        <receiver android:name="com.myApp.BrodcastReciver.PhoneReStartReceiver" >
            <intent-filter>
                <action android:name="android.intent.action.BOOT_COMPLETED" />
            </intent-filter>
        </receiver>

        <service
            android:name="com.company.myApp.TruckLocationUpdateService"
            android:enabled="true" />
        <service
            android:name="com.company.myApp.TruckCommubicationcountService"
            android:enabled="true" />
        <service android:name="com.company.myApp.GCMIntentService" />
        <service android:name="com.company.myApp.HandleNotification" />

        <meta-data
            android:name="com.google.android.gms.version"
            android:value="@integer/google_play_services_version" />
        <meta-data
            android:name="com.google.android.maps.v2.API_KEY"
            android:value="AIzaSyB6Ae82d_eLZ1nMYIW7EaaQ3-2-Xn7duHs" />
        <!-- android:value="AIzaSyAkZzWl6FSP89yWf7VeX6ooYvd6SuRnV4E" /> -->
    </application>

    <!--<uses-permission-->
        <!--android:name="android.permission.ACCESS_MOCK_LOCATION"-->
        <!--android:required="false" />-->

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

    <uses-permission
        android:name="android.permission.FLASHLIGHT"
        android:permissionGroup="android.permission-group.HARDWARE_CONTROLS"
        android:protectionLevel="normal"
        android:required="false" />
</manifest>

有人知道这有什么问题吗?我尝试将使用权限更改为权限,但它有 C2D_ 它不起作用。

4

1 回答 1

17

你可以参考这篇文章

消除

<uses-permission android:name="${applicationId}.permission.C2D_MESSAGE"/>
<permission
    android:name="${applicationId}.permission.C2D_MESSAGE"
    android:protectionLevel="signature"/>

运行应用程序,然后permisson再次添加并运行应用程序。

当您尝试在同一设备上安装应用程序的调试版和发布版时,通常会出现此问题。

于 2017-04-19T08:57:08.817 回答