V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
getYourMother
V2EX  ›  Android

使用 productFlavors 打不同的包安装失败的问题

  •  
  •   getYourMother · 2019-09-05 10:44:17 +08:00 · 5836 次点击
    这是一个创建于 1666 天前的主题,其中的信息可能已经有所发展或是发生改变。
    在 build.gradle 开了两个 productFlavors 配置了不同的包名、签名文件、app 名、app icon、版本号、版本名,然后切换 Build Variant 直接安装到模拟器上的时候,安装第一个正常,安装第二个就报错了:

    09/05 10:38:07: Launching app
    Install failed.
    Installation failed
    <a href='rerun'>Rerun</a>

    另外,尝试打包成 apk 文件安装到手机上也是第一个成功,第二个失败:

    安装失败,xxx 与 xxx 不兼容,无法同时安装。

    不会覆盖安装的话说明包名是不同的,也就是说 productFlavors 的配置是生效了的,但就是无法同时安装,各位大佬知道原因吗?
    10 条回复    2019-09-05 14:27:46 +08:00
    frantic
        1
    frantic  
       2019-09-05 11:04:59 +08:00
    看看你项目的`AndroidManifest.xml` 中的`provider`的`android:authorities`包名是不是没动态替换
    getYourMother
        2
    getYourMother  
    OP
       2019-09-05 11:19:27 +08:00
    @frantic 确实没替换,不过我动态替换成不同的包名后还是安装失败..貌似跟这个也没关系?
    z42514
        3
    z42514  
       2019-09-05 11:23:26 +08:00
    用 adb install 安装,看看更详细的报错说明
    nicevar
        4
    nicevar  
       2019-09-05 11:39:57 +08:00
    基本上就是上面说的 provider 和 authorities 问题,你不替换一定不行的
    getYourMother
        5
    getYourMother  
    OP
       2019-09-05 11:43:47 +08:00
    @z42514 看到了:
    Performing Streamed Install
    adb: failed to install app-dwpd-release.apk: Failure [INSTALL_FAILED_TEST_ONLY: installPackageLI]
    frantic
        6
    frantic  
       2019-09-05 11:44:33 +08:00
    @getYourMother 你可以把 AndroidManifest 和 对应的 build.grale 脱敏后上传到 gist 上面然后让大家看看 这样解决问题更快一点
    getYourMother
        7
    getYourMother  
    OP
       2019-09-05 11:45:41 +08:00
    @nicevar 嗯,我已经 ctrl+shift+f 把找到的都替换了,就是还是失败...
    yukiww233
        8
    yukiww233  
       2019-09-05 11:48:37 +08:00
    testonly 一般是 android studio 直接运行出来的 debug 包
    打 release 包或者在 gradle 里加 android.injected.testOnly=false
    getYourMother
        9
    getYourMother  
    OP
       2019-09-05 14:16:01 +08:00
    感谢各位大佬,问题已经解决了,主要还是包名冲突的问题,我用 adb install -t 安装 apk 时告诉我在 androidmanifest 里配置的极光推送的包名有冲突,因为是用的动态的 applicationId,所以 ctrl+shift+f 时没找到...总之折腾了快两天总算解决了.感谢大家
    secretman
        10
    secretman  
       2019-09-05 14:27:46 +08:00
    一看就是包名没替换干净,问问题上代码,浪费一群老哥的好心好意~
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5193 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 09:41 · PVG 17:41 · LAX 02:41 · JFK 05:41
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.