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

前端 未结 5 494
鱼传尺愫
鱼传尺愫 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条回答
  •  既然无缘
    2020-12-24 07:46

    Its not really what you want:

    private static Boolean isSignedWithDebugKey = null;
        protected boolean signedWithDebug() {
            if(isSignedWithDebugKey == null) {
                PackageManager pm = getPackageManager();
                try {
                    PackageInfo pi = pm.getPackageInfo(getPackageName(), 0);
                    isSignedWithDebugKey = (pi.applicationInfo.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0;
                }
                catch(NameNotFoundException nnfe) {
                    nnfe.printStackTrace();
                    isSignedWithDebugKey = false;
                }
            }
    
            return isSignedWithDebugKey;
        }
    

    You could then hit a dev/staging server if the app is signed with a debug key, and production with a release certificate.

提交回复
热议问题