getYourMother
V2EX  ›  Android

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

  •  
  •   getYourMother · Sep 5, 2019 · 14736 views
    This topic created in 2445 days ago, the information mentioned may be changed or developed.
    在 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 replies    2019-09-05 14:27:46 +08:00
    frantic
        1
    frantic  
       Sep 5, 2019
    看看你项目的`AndroidManifest.xml` 中的`provider`的`android:authorities`包名是不是没动态替换
    getYourMother
        2
    getYourMother  
    OP
       Sep 5, 2019
    @frantic 确实没替换,不过我动态替换成不同的包名后还是安装失败..貌似跟这个也没关系?
    z42514
        3
    z42514  
       Sep 5, 2019
    用 adb install 安装,看看更详细的报错说明
    nicevar
        4
    nicevar  
       Sep 5, 2019
    基本上就是上面说的 provider 和 authorities 问题,你不替换一定不行的
    getYourMother
        5
    getYourMother  
    OP
       Sep 5, 2019
    @z42514 看到了:
    Performing Streamed Install
    adb: failed to install app-dwpd-release.apk: Failure [INSTALL_FAILED_TEST_ONLY: installPackageLI]
    frantic
        6
    frantic  
       Sep 5, 2019
    @getYourMother 你可以把 AndroidManifest 和 对应的 build.grale 脱敏后上传到 gist 上面然后让大家看看 这样解决问题更快一点
    getYourMother
        7
    getYourMother  
    OP
       Sep 5, 2019
    @nicevar 嗯,我已经 ctrl+shift+f 把找到的都替换了,就是还是失败...
    yukiww233
        8
    yukiww233  
       Sep 5, 2019
    testonly 一般是 android studio 直接运行出来的 debug 包
    打 release 包或者在 gradle 里加 android.injected.testOnly=false
    getYourMother
        9
    getYourMother  
    OP
       Sep 5, 2019
    感谢各位大佬,问题已经解决了,主要还是包名冲突的问题,我用 adb install -t 安装 apk 时告诉我在 androidmanifest 里配置的极光推送的包名有冲突,因为是用的动态的 applicationId,所以 ctrl+shift+f 时没找到...总之折腾了快两天总算解决了.感谢大家
    secretman
        10
    secretman  
       Sep 5, 2019
    一看就是包名没替换干净,问问题上代码,浪费一群老哥的好心好意~
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3046 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 36ms · UTC 14:03 · PVG 22:03 · LAX 07:03 · JFK 10:03
    ♥ Do have faith in what you're doing.