简体   繁体   English

如何在同一套件下的Android Studio中发布两个APK?

[英]How can I release two apks in android studio under a same package?

I want to create a shopping app, where there exists seller side and customer side. 我想创建一个购物应用程序,其中存在卖方和客户方。 So I need to deploy a individual app for seller and for customers. 因此,我需要为卖方和客户部署一个单独的应用程序。 My question is how can I create those under a single package? 我的问题是如何在单个程序包下创建它们?

Since because my app needs to communicate to firebase real-time database. 因为我的应用程序需要与Firebase实时数据库进行通信。 Under firebase real-time free plan, only one app allowed for one database, maximum number of database can be created under free plan is 1. It recognizing the app on the basis of the package. 在Firebase实时免费计划下,一个数据库只允许一个应用程序,免费计划下最多可以创建1个数据库。它基于软件包识别该应用程序。 That's why I need how to create two apk under one package in android studio. 这就是为什么我需要如何在android studio中的一个程序包下创建两个apk。 Please help me out. 请帮帮我。

Currently using Android studio v3.3. 当前使用的是Android Studio v3.3。

Use sub packages for example 以子包为例

com.my.shop  //the package
com.my.shop.clients  //1st sub-package
com.my.shop.sellers  //2nd sub-package

Then write different screens for the subpackages like the first activity can allow users to choose if they are Client or Seller. 然后为子包编写不同的屏幕,例如第一个活动可以使用户选择他们是客户还是卖方。

hope it helps 希望能帮助到你

package id (app id) is needs to be unique. 包ID(应用ID)必须是唯一的。 you can't publish on google play. 您无法在Google Play上发布。

有一个简单的解决方案,使购物应用程序的客户的第一个屏幕带有卖方的隐藏按钮(位于屏幕按钮或类似的按钮),当他们单击时,将其重定向到另一个屏幕以显示“第二个” apk。

Write one app , create two sub-package inside it. 编写一个应用程序 ,在其中创建两个子包 For instance: 例如:

**com.mybrand** // Main package, general-shared codes and screens. This will be your package name and used by Google Play, Firebase etc.

*com.mybrand.customer* // Customer specific screen and codes

*com.mybrand.seller* // Seller specific screen and codes

In this way, codes and screens will be seperated in the same app. 这样,代码和屏幕将在同一应用程序中分开。 If you will decide seperate them in future, you can easily seperate and publish them without any name or package name confusion. 如果您将来决定将它们分开,则可以轻松地分离和发布它们,而不会引起任何名称或程序包名称的混淆。

You can't, package must be unique . 您不能, 包必须是唯一的 You can create packages with flavors in gradle: 您可以在gradle中创建具有风味的包:

android {
...

defaultConfig {
    minSdkVersion 8
    versionCode 10
     ...
}

flavorDimensions "flavor"

productFlavors {
    customer {
        flavorDimension "flavor"
        applicationId "com.example.customer"
    }

    seller {
        flavorDimension "flavor"
        applicationId "com.example.seller"
    }
  }

 ... 
}

or 要么

android {
...

defaultConfig {
    minSdkVersion 8
    versionCode 10
    applicationId "com.example"
}

flavorDimensions "flavor"

productFlavors {
    customer {
        flavorDimension "flavor"
        applicationIdSuffix '.customer'
    }

    seller {
        flavorDimension "flavor"
        applicationIdSuffix '.seller'
    }
  }

 ... 
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM