发布和调试的apk之间的Andr​​oid大号权限冲突 [英] Android L permission conflict between release and debug apks

查看:243
本文介绍了发布和调试的apk之间的Andr​​oid大号权限冲突的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经升级到Android L和既有公布我在谷歌玩应用程序的版本和调试版本,我们使用的开发。

I've upgraded to Android L and have both a released version of my app in "Google play" and a debug version which we use for development.

它们与不同的密钥签署。

They are signed with different keys.

我的问题是,我安装谷​​歌玩的版本,然后当我尝试安装调试版本,这是定义如下:

My problem is that I install the "Google play" version and then when I try installing the debug version, which is defined like so:

debug {
        debuggable true
        packageNameSuffix ".debug"
        buildConfigField BOOLEAN, IS_DEV, TRUE
    }

这是我收到的错误:

And this is the error I receive:

Failure [INSTALL_FAILED_DUPLICATE_PERMISSION perm=com.app.name.permission.C2D_MESSAGE pkg=com.app.name]

这是有问题的权限:

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

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

我知道(<一href="http://commonsware.com/blog/2014/08/04/custom-permission-vulnerability-l-developer-$p$pview.html">http://commonsware.com/blog/2014/08/04/custom-permission-vulnerability-l-developer-$p$pview.html)并认为这是由于安全问题产生,但我仍然需要能够与团队各有自己的调试签名密钥工作的事实。

I am aware of (http://commonsware.com/blog/2014/08/04/custom-permission-vulnerability-l-developer-preview.html) and of the fact that this was created due to a security issue, but I still need to be able to work with a team each having their own debug signing key.

我试着使用亚行卸载卸载( http://stackoverflow.com/a/27090838/2746924 )我已经试过清除设备上的所有应用程序缓存。

I've tried uninstalling using adb uninstall (http://stackoverflow.com/a/27090838/2746924) and I've tried clearing all apps cache on device.

推荐答案

我可以成功地同时拥有调试发布安装在同样采用Android 5.0的Nexus 9的同时GCM客户端应用程序的版本,通过修改清单使用占位符:

I can successfully have both debug and release editions of a GCM client app installed on the same Android 5.0 Nexus 9 at the same time, by amending the manifest to use placeholders:

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

请注意,您也应该使用 $ {的applicationID} &LT;接收器&GT; &LT;类别&GT;

Note that you should also use ${applicationId} in your <receiver> for the <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>

(坦白地说,我不服气的自定义&LT;许可&GT; 甚至需要了,因为我试图删除它,仍然可以接收GCM消息)

(frankly, I am unconvinced that the custom <permission> is even needed anymore, given that I tried removing it and can still receive GCM messages)

如果您然后定义你的 build.gradle 因为你拥有了它,用 applicationIdSuffix 为构建之一类型(例如,调试),您将结束与构建类型不同的自定义权限,您将能够让他们并排安装。

If you then define your build.gradle as you have it, with an applicationIdSuffix for one of the build types (e.g., debug), you will wind up with separate custom permissions by build type, and you will be able to have them installed side by side.

这篇关于发布和调试的apk之间的Andr​​oid大号权限冲突的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆