Home > database >  Conditional Gradle dependencies based on function result
Conditional Gradle dependencies based on function result

Time:07-26

How can i import Linphone library only when built in Sip Api is not supported?

Because this library greatly affects to apk size (~100 Mb)

This is example of conditional dependency (based on variable in gradle.properties) in my :app Gradle file:

if (project.hasProperty("usesip")
{
     implementation 'org.linphone:linphone-sdk-android:5.1.2'
}

This is my function (Java), that checks support of built in Sip Library:

public static boolean checksSupportSip(Context context)
{
    return SipManager.isApiSupported(context) && SipManager.isVoipSupported(context);
}

And i don't know, how can i fix 'cannot find symbol' error, when Linphone library is not imported, here:

import org.linphone.core.*;

public class LinphoneSIPTask extends SIPTask
{
    private Core core;//linphone core

    private final CoreListenerStub listener;//linphone events listener

    private RegistrationState registrationstate = null;

    ...

}

CodePudding user response:

If you are distributing via Google Play, I think your only option is to use Feature Delivery with on-demand features. Move everything with Linphone library to a separate module and request its installation after the app start.

Outside of Google Play is seems impossible.

  • Related