How to implement AIDL on openvpn flutter project?

60 Views Asked by At

I want to convert openvpn Android app to flutter. Android project: https://github.com/schwabe/ics-openvpn. When I click on the start embedded profile button, it works on my .ovpn configuration file. However, the flutter project does not work (from https://github.com/HarshAndroid/FreeVPN-App-Flutter). So, I was trying to make similar MainActivity in flutter project like android. But it is an error that mService throws NullPointerException.

    private ServiceConnection mConnection   = new ServiceConnection() {
        public void onServiceConnected(ComponentName className,
                                       IBinder service) {
            // This is called when the connection with the service has been
            // established, giving us the service object we can use to
            // interact with the service.  We are communicating with our
            // service through an IDL interface, so get a client-side
            // representation of that from the raw service object.
            
                mService = IOpenVPNAPIService.Stub.asInterface(service);
            try {
                // Request permission to use the API
                Intent i = mService.prepare(getActivity().getPackageName());
                if (i!=null) {
                    startActivityForResult(i, ICS_OPENVPN_PERMISSION);
                }
                else
                {
                    onActivityResult(ICS_OPENVPN_PERMISSION, Activity.RESULT_OK,null);
                }

            } catch (RemoteException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }

I assume that it's reason is that there is no aidl file and APIVpnProfile.java in app unlike android remote app. But when i tried to implement and build, I get an error :

Task :app:compileDebugAidl FAILED
ERROR: C:\Users\z004x2xe\source\repos\fluttervpn\fluttervpnapplication\android\app\src\main\aidl\de\blinkt\openvpn\api\IOpenVPNAPIService.aidl: Duplicate files found for de.blinkt.openvpn.api.APIVpnProfile from:
C:\Users\z004x2xe\source\repos\fluttervpn\fluttervpnapplication\android\app\src\main\aidl\de\blinkt\openvpn\api\APIVpnProfile.aidl
C:\Users\z004x2xe\source\repos\fluttervpn\fluttervpnapplication\build\vpnLib\intermediates\aidl_parcelable\debug\out\de\blinkt\openvpn\api\APIVpnProfile.aidl
ERROR: C:\Users\z004x2xe\source\repos\fluttervpn\fluttervpnapplication\android\app\src\main\aidl\de\blinkt\openvpn\api\IOpenVPNAPIService.aidl: Couldn't find import for class de.blinkt.openvpn.api.APIVpnProfile

I don't know if it's possible to solve it this way. I'm open to new suggestions.

0

There are 0 best solutions below