microsoft / appcenter-sdk-android

Development repository for the App Center SDK for Android
Other
277 stars 134 forks source link

customize app version read by appcenter #1597

Closed vvb2060 closed 2 years ago

vvb2060 commented 2 years ago

Is your feature request related to a problem? Please describe.

https://developer.android.com/studio/build/configure-apk-splits#configure-APK-versions

We have 5 different versions (arm64 arm x86 x86_64 universal) for each release. We want to merge the 5 versions of the data and can upload mapping only once.

Describe the solution you'd like We want to be able to customize the version read by appcenter.

Describe alternatives you've considered Currently we use reflection to add Channel listener.

   static Channel.Listener patchDeviceListener = new AbstractChannelListener() {
        @Override
        public void onPreparedLog(Log log, String groupName, int flags) {
            var d = log.getDevice();
            d.setAppVersion(BuildConfig.VERSION_NAME);
            d.setAppBuild(String.valueOf(BuildConfig.VERSION_CODE));
        }
    };

    static void addPatchDeviceListener() {
        try {
            var channel = AppCenter.class.getDeclaredField("mChannel");
            channel.setAccessible(true);
            ((Channel) channel.get(AppCenter.getInstance())).addListener(patchDeviceListener);
        } catch (Throwable e) {
            Log.e(App.TAG, "add listener", e);
        }
    }

    static void patchDevice() throws Throwable {
        var handle = AppCenter.class.getDeclaredField("mHandler");
        handle.setAccessible(true);
        ((Handler) handle.get(AppCenter.getInstance())).post(Telemetry::addPatchDeviceListener);
    }
AnastasiaKubova commented 2 years ago

Hi! Thanks for getting in touch with us! We already have a similar feature request for another platform in our main repository. Let's track the progress of this feature here. Community contributions are always welcome.