The goal is to remove the dependency on the external “OpenVPN for Android” app and integrate the VPN connection logic directly into the current application.
User Review Required
IMPORTANT
Library Dependency: We will use the ics-openvpn library (via JitPack). This is a large library that includes native code. The build time will increase, and the APK size will grow significantly (approx +10-15MB).
WARNING
Manifest Merging: The ics-openvpn library has its own
AndroidManifest.xml. We need to ensure our minSdk and other attributes are compatible. The current minSdk is 23, which is good.
Proposed Changes
Build Configuration
[MODIFY] build.gradle
- Add
ics-openvpndependency. - Enable
multiDex(likely needed due to library size).
[MODIFY] settings.gradle
- Add
jitpack.iorepository if not present (usually in project-level, but settings.gradle is common in newer Android).
Core Logic
[MODIFY] MainActivity.java
- Remove check_openvpn_installed logic.
- Remove launch_openvpn intent logic.
- Remove “Install OpenVPN” UI prompts.
- Implement
startVpnInternal():- Parse the downloaded
.ovpnfile usingics-openvpn‘sVpnProfileparser. - Add the profile to
ProfileManager. - Start the VPN service using
VPNLaunchHelperor direct Service intent.
- Parse the downloaded
- Implement
IOpenVPNStatusCallbackto update UI (Connected/Connecting/Failed) directly from the internal service.
[MODIFY] AndroidManifest.xml
- Add
VpnServicedeclaration (if not automatically merged). - Add
BIND_VPN_SERVICEpermission.
UI Changes
[MODIFY] activity_main.xml
- (Optional) Remove the “Install OpenVPN” button/banner since it’s no longer needed.
Verification Plan
Automated Tests
- None available for VPN connectivity in this environment.
Manual Verification
- Build Check: Ensure Gradle syncs and builds (I will rely on code correctness as I cannot run Gradle).
- Code Review: Verify that MainActivity correctly imports the new classes and calls the internal service instead of
startActivity.
上面是第一次的 plan, 但其實會出錯, 因為,
@build.gradle > Could not resolve all files for configuration ':app:debugCompileClasspath'.
> Could not find com.github.schwabe:ics-openvpn:0.7.9.
Required by:
project :app
第2次 plan 如下:
Implementation Plan – Integrate Local OpenVPN Library
The goal is to remove the dependency on the external “OpenVPN for Android” app and the remote ics-openvpn artifact, instead using the local vpnLib module directly.
User Review Required
IMPORTANT
I will be modifying the build files to switch from a remote dependency to a local module. This assumes vpnLib is a complete and working copy of the OpenVPN library.
Proposed Changes
Build Configuration
[MODIFY] settings.gradle
- Ensure
:vpnLibis included in the project.
[MODIFY] app/build.gradle
- Remove
implementation 'com.github.schwabe:ics-openvpn:0.7.9'(or similar). - Add
implementation project(':vpnLib').
Code Integration
[MODIFY] MainActivity.java
- Ensure imports point to the local library packages (likely
de.blinkt.openvpn...). - Verify startVpnInternal and stopVpn use the local service correctly.
Verification Plan
Automated Tests
- Run
./gradlew assembleDebugto verify the build succeeds with the local dependency.
Manual Verification
- The user will need to run the app and verify that clicking “Connect” starts the VPN process without prompting to install an external app.