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.
startVService
is a method so you can't create an instance of it. You need an instance of com.github.xfalcon.vhosts.vservice.VhostsService and then call startVService by RunMethod. Even then it may not work, but you can only try.
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
The #AdditionalJar module attribute (introduced in B4A v3.80) allows us to reference external jars. With the help of JavaObject it is now possible to integrate third party jars without a wrapper. This solution is good for "simple" libraries. If the API is complicated with many interfaces then...
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.
yes, I have comment out ‘minifyEnabled true’ and ‘shrinkResources true’ when compiling aar library file , It seems enable shrinkResources when compiling the com.android.library file will report an exception.
It's a long time since I used android studio, and that was only playing with it. I don't know if there is more than one tool that could be used, but Proguard seems to be referenced in the threads I've looked at.
thanks stevel05, after comment out all obfuscation items in build.gradle, it can be called successfully. But there are a lot of things to be resolved. I can only give up it.
Hope B4X will support the VpnService library in the future or publish some similar libraries.
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