我正在尝试建立一个只有dns的vpn。我有个问题
public void run() {
try {
//a. Configure the TUN and get the interface.
mInterface = builder.setSession("MyVPNService")
.addAddress("192.168.0.1", 24)
.addDnsServer("8.8.8.8")
.addRoute("0.0.0.0", 0)
.establish();
最后一个建立方法抛出一个异常android.os.remoteexception,如下所示
W/System.err: java.lang.SecurityException: com.example.dnschangervpn.MyVpnService does not require android.permission.BIND_VPN_SERVICE
at android.os.Parcel.createException(Parcel.java:1966)
at android.os.Parcel.readException(Parcel.java:1934)
at android.os.Parcel.readException(Parcel.java:1884)
at android.net.IConnectivityManager$Stub$Proxy.establishVpn(IConnectivityManager.java:2441)
W/System.err: at android.net.VpnService$Builder.establish(VpnService.java:993)
at com.example.dnschangervpn.MyVpnService$1.run(MyVpnService.java:34)
at java.lang.Thread.run(Thread.java:764)
Caused by: android.os.RemoteException: Remote stack trace:
at com.android.server.connectivity.Vpn.establish(Unknown Source:496)
at com.android.server.ConnectivityService.establishVpn(Unknown Source:107)
at android.net.IConnectivityManager$Stub.onTransact(IConnectivityManager.java:640)
at android.os.Binder.execTransact(Binder.java:739)
1条答案
按热度按时间zsohkypk1#
我发现我必须对我的服务给予明确的许可,所以我这样做了,并且成功了。