Build multiple (test/prod) versions of Android APKs in Eclipse

前端 未结 5 497
鱼传尺愫
鱼传尺愫 2020-12-24 07:38

I\'m looking to optimize generating of slightly different APKs of the same Android app, the only difference being the http API server it\'s using (dev/staging/prod).

5条回答
  •  萌比男神i
    2020-12-24 07:58

    Move all you code to a library project see http://developer.android.com/guide/developing/projects/projects-eclipse.html#SettingUpLibraryProject

    Then create separate projects in eclipse for test and production each with a unique package name. You can then use the package name to distinguish between versions.

    Something like:

    public static boolean isProductionVersion(){
      return context.getPackageName().toLowerCase().contains("production");
    }
    

    This may seem like overkill for managing different http end points but it will make the code more manageable. You can also do useful things like:

    • flag the test version with a different application icon
    • run test and production versions side by side on one device

    This can all be done in eclipse without using and third party tools.

提交回复
热议问题