发布和调试apks之间的Android L权限冲突

JY2*_*Y2k 14 android google-cloud-messaging android-gradle-plugin

我已经升级到Android L并在"Google Play"中发布了我的应用程序的发布版本以及我们用于开发的调试版本.

它们使用不同的密钥签名.

我的问题是我安装了"Google play"版本,然后当我尝试安装调试版本时,其定义如下:

debug {
        debuggable true
        packageNameSuffix ".debug"
        buildConfigField BOOLEAN, IS_DEV, TRUE
    }
Run Code Online (Sandbox Code Playgroud)

这是我收到的错误:

Failure [INSTALL_FAILED_DUPLICATE_PERMISSION perm=com.app.name.permission.C2D_MESSAGE pkg=com.app.name]
Run Code Online (Sandbox Code Playgroud)

这是有问题的许可:

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

<uses-permission android:name="com.app.name.permission.C2D_MESSAGE"/>
Run Code Online (Sandbox Code Playgroud)

我知道(http://commonsware.com/blog/2014/08/04/custom-permission-vulnerability-l-developer-preview.html)以及这是由于安全问题而创建的事实,但是我仍然需要能够与每个拥有自己的调试签名密钥的团队合作.

我尝试使用adb uninstall卸载(/sf/answers/1896358691/),我尝试清除设备上的所有应用缓存.

Com*_*are 25

通过修改清单以使用占位符,我可以同时在同一个Android 5.0 Nexus 9上成功安装GCM客户端应用程序debugrelease版本:

<permission
  android:name="${applicationId}.permission.C2D_MESSAGE"
  android:protectionLevel="signature" />
<uses-permission
  android:name="${applicationId}.permission.C2D_MESSAGE" />
Run Code Online (Sandbox Code Playgroud)

请注意,你也应该用${applicationId}在你<receiver><category>:

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

            <category android:name="${applicationId}" />
        </intent-filter>
    </receiver>
Run Code Online (Sandbox Code Playgroud)

(坦率地说,我不相信<permission>甚至需要自定义,因为我尝试删除它并且仍然可以接收GCM消息)

如果您随后build.gradle使用applicationIdSuffix其中一种构建类型(例如,debug)定义了您的内容,那么您将通过构建类型获得单独的自定义权限,并且您可以将它们并排安装.