Java Question Third-party VPN library import error

laomms

Member
Licensed User
I made a VirtualHosts.aar library from https://github.com/x-falcon/Virtual-Hosts, and use #AdditionalJar: VirtualHosts.aar import to b4a project.

in java project there are some codes like this :
Java:
package com.github.xfalcon.vhosts.vservice;

import ...


public class VhostsService extends VpnService {
    ...
      
     public static void startVService(Context context, int method) {
        ...
    }


in b4a I write:
B4X:
'#AdditionalRes: ..\resource
#AdditionalJar: VirtualHosts.aar

Sub Activity_Create(FirstTime As Boolean)
    Dim pm As B4XPagesManager
    pm.Initialize(Activity)
  
    'Dim ctxt As JavaObject
    'ctxt.InitializeContext
    Dim fb As JavaObject
    fb.InitializeNewInstance("com.github.xfalcon.vhosts.vservice.startVService",Array("23.101.130.247 microsoft.gointeract.io", 2))
  
    Activity.LoadLayout("mainpage")
    WebView1.LoadUrl("https://microsoft.gointeract.io/interact/index?interaction=1461173234028-3884f8602eccbe259104553afa8415434b4581-05d1&accountId=microsoft&appkey=196de13c-e946-4531-98f6-2719ec8405ce&Language=Italian&CountryCode=IT&CountryLanguage=IT&Click%20To%20Call%20Caller%20Id=+31641190689&startedFromSmsToken=QCYw2pA&sessionID=188781095&token=wXVhvi")

End Sub

It abnormal in : java.lang.ClassNotFoundException: com.github.xfalcon$vhosts$vservice$startVService , likes can not find the aar library.
 

Attachments

  • VirtualHosts.zip
    409.8 KB · Views: 95
Last edited:

laomms

Member
Licensed User
thanks agraham, I change the code as below:
B4X:
    Dim ctxt As JavaObject
    ctxt.InitializeContext
    Dim fb As JavaObject
    Dim O As JavaObject=fb.InitializeNewInstance("com.github.xfalcon.vhosts.vservice.VhostsService",Null)
    O.RunMethod ("startVService",Array(ctxt, 2))

the errors occurred with Method: startVService not found in: com.github.xfalcon.vhosts.vservice.VhostsService
 

stevel05

Expert
Licensed User
Check the code you compiled the library from, it appears that there is no method startVService in the VhostsService class.
 

laomms

Member
Licensed User
how to call this function: startVService

vhost.png
 

agraham

Expert
Licensed User
Ah! I just noticed it's a static method. You don't call it on an instance,
 

stevel05

Expert
Licensed User
I tried running it on a static object, still wouldn't find it.
 

DonManfred

Expert
Licensed User

DonManfred

Expert
Licensed User

agraham

Expert
Licensed User
What do you mean? I've taken the aar file in the first post attachment apart and as you can see from the image above there is no startVService method. If you compare my image and the source file there is other stuff missing as well. Perhaps he's got the wrong file.
 

DonManfred

Expert
Licensed User
What do you mean?
Did you checked the link in my post and had a look at line 215 of the link?
I've taken the aar file in the first post attachment
I did visit the githubpage and had a look at the Source.

Check line 215 of this link
 

stevel05

Expert
Licensed User
If you try a new one or the same one, you will need to turn off obfuscation.
 

laomms

Member
Licensed User
Change to SLC ways, I try use SLC wrapper it to b4a library, it can compiled successfully, but when import to B4A, Prompt the following error:


B4X:
java.lang.RuntimeException: Unable to start activity ComponentInfo{b4a.example/top.nicelee.purehost.MainActivity}: android.content.res.Resources$NotFoundException: Resource ID #0x7f0b001c
 

Attachments

  • PureHost_SLC_src.zip
    127.4 KB · Views: 105
  • WrapperTest.zip
    21.3 KB · Views: 89
Last edited:
Top