Is your code running on the UI thread?
On Wed, Nov 30, 2011 at 1:14 PM, Kristian <[email protected]>wrote:
> Hello,
>
> I am experimenting with the VpnService that was added to Android in
> SDK 4.0. I have gotten as far as starting the VpnService, however, I
> am unable to create the virtual interface. My code throws an
> IllegalStateException and I am not able to figure out why.
>
> My cut down example looks like this:
>
> ParcelFileDescriptor pfd = null;
>
> VpnService.Builder b = new VpnService.Builder();
> try{
> b.addAddress("10.0.6.2", 24);
> b.setMtu(1460);
> b.setSession("TunnelTest");
> } catch(IllegalArgumentException e){
> Log.v("Service", "Address is invalid!");
> stopSelf();
> return;
> }
>
> try{
> pfd = b.establish();
> } catch (IllegalArgumentException e){
> Log.v("Service", "Interface was provided
> with an illegal
> argument");
> } catch (IllegalStateException e){
> e.printStackTrace();
> Log.v("Service", "Illegal state");
> } catch (SecurityException e){
> Log.v("Service", "Security exception
> thrown");
>
> What I try to do here is to create a virtual interface with IP
> 10.0.6.2, belonging to the 10.6.0.0/24 subnet. The exception is thrown
> by the b.establish() call.
>
> This is the full stack trace:
>
> 11-30 17:51:10.863: W/System.err(2741):
> java.lang.IllegalStateException: Cannot create interface
> 11-30 17:51:10.875: W/System.err(2741): at
> android.os.Parcel.readException(Parcel.java:1335)
> 11-30 17:51:10.875: W/System.err(2741): at
> android.os.Parcel.readException(Parcel.java:1281)
> 11-30 17:51:10.875: W/System.err(2741): at
> android.net.IConnectivityManager$Stub
> $Proxy.establishVpn(IConnectivityManager.java:1321)
> 11-30 17:51:10.875: W/System.err(2741): at
> android.net.VpnService
> $Builder.establish(VpnService.java:472)
> 11-30 17:51:10.875: W/System.err(2741): at
> no.simtel.TestVpnService
> $TestVpn.run(TestVpnService.java:37)
>
> Thanks in advance for any help.
>
> /Kristian
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
--
"I know that you believe you understand what you think I said, but I'm not
sure you realize that what you heard is not what I meant."
- Robert McCloskey
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en