laomms Member Licensed User Longtime User Nov 9, 2020 #1 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 VirtualHosts.zip 409.8 KB · Views: 685 Last edited: Nov 12, 2020
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.
agraham Expert Licensed User Longtime User Nov 9, 2020 #2 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.
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.
laomms Member Licensed User Longtime User Nov 10, 2020 #3 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
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 Longtime User Nov 10, 2020 #4 Check the code you compiled the library from, it appears that there is no method startVService in the VhostsService class.
Check the code you compiled the library from, it appears that there is no method startVService in the VhostsService class.
agraham Expert Licensed User Longtime User Nov 10, 2020 #6 Ah! I just noticed it's a static method. You don't call it on an instance, Accessing third party Jar with #Additionaljar and JavaObject - Picasso 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... www.b4x.com
Ah! I just noticed it's a static method. You don't call it on an instance, Accessing third party Jar with #Additionaljar and JavaObject - Picasso 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... www.b4x.com
stevel05 Expert Licensed User Longtime User Nov 10, 2020 #7 I tried running it on a static object, still wouldn't find it.
DonManfred Expert Licensed User Longtime User Nov 10, 2020 #8 stevel05 said: still wouldn't find it. Click to expand... probably the needed manifestchanged are not applied? A service from a AAR must be added to the manifest; it does not happen automatically. Virtual-Hosts/app/src/main/AndroidManifest.xml at main · x-falcon/Virtual-Hosts hosts for android,implement by vpn mode,supports wildcard DNS records - x-falcon/Virtual-Hosts github.com
stevel05 said: still wouldn't find it. Click to expand... probably the needed manifestchanged are not applied? A service from a AAR must be added to the manifest; it does not happen automatically. Virtual-Hosts/app/src/main/AndroidManifest.xml at main · x-falcon/Virtual-Hosts hosts for android,implement by vpn mode,supports wildcard DNS records - x-falcon/Virtual-Hosts github.com
agraham Expert Licensed User Longtime User Nov 10, 2020 #9 Steve is correct. I've looked in the aar and there is no static startVService in the VhostsService class
Steve is correct. I've looked in the aar and there is no static startVService in the VhostsService class
DonManfred Expert Licensed User Longtime User Nov 10, 2020 #10 agraham said: Steve is correct. I've looked in the aar and there is no static startVService in the VhostsService class Click to expand... Virtual-Hosts/app/src/main/java/com/github/xfalcon/vhosts/vservice/VhostsService.java at main · x-falcon/Virtual-Hosts hosts for android,implement by vpn mode,supports wildcard DNS records - x-falcon/Virtual-Hosts github.com Line 215
agraham said: Steve is correct. I've looked in the aar and there is no static startVService in the VhostsService class Click to expand... Virtual-Hosts/app/src/main/java/com/github/xfalcon/vhosts/vservice/VhostsService.java at main · x-falcon/Virtual-Hosts hosts for android,implement by vpn mode,supports wildcard DNS records - x-falcon/Virtual-Hosts github.com Line 215
agraham Expert Licensed User Longtime User Nov 10, 2020 #11 DonManfred said: Line 215 Click to expand... 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 said: Line 215 Click to expand... 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 Longtime User Nov 10, 2020 #12 agraham said: What do you mean? Click to expand... Did you checked the link in my post and had a look at line 215 of the link? agraham said: I've taken the aar file in the first post attachment Click to expand... I did visit the githubpage and had a look at the Source. Check line 215 of this link Virtual-Hosts/app/src/main/java/com/github/xfalcon/vhosts/vservice/VhostsService.java at main · x-falcon/Virtual-Hosts hosts for android,implement by vpn mode,supports wildcard DNS records - x-falcon/Virtual-Hosts github.com
agraham said: What do you mean? Click to expand... Did you checked the link in my post and had a look at line 215 of the link? agraham said: I've taken the aar file in the first post attachment Click to expand... I did visit the githubpage and had a look at the Source. Check line 215 of this link Virtual-Hosts/app/src/main/java/com/github/xfalcon/vhosts/vservice/VhostsService.java at main · x-falcon/Virtual-Hosts hosts for android,implement by vpn mode,supports wildcard DNS records - x-falcon/Virtual-Hosts github.com
laomms Member Licensed User Longtime User Nov 11, 2020 #13 under android studio, I can normal import this aar, and use the startVService function normal:
agraham Expert Licensed User Longtime User Nov 11, 2020 #14 Ah! The penny's dropped, the problem is obvious but I overlooked it. The code in the aar is obfuscated! Look at my screenshot above.
Ah! The penny's dropped, the problem is obvious but I overlooked it. The code in the aar is obfuscated! Look at my screenshot above.
laomms Member Licensed User Longtime User Nov 12, 2020 #15 I found two similar github projects: https://github.com/nICEnnnnnnnLee/PureHost and https://github.com/lmgy/Redirect , It seems much simpler than this project, I will try to compile to aar and then try to import.
I found two similar github projects: https://github.com/nICEnnnnnnnLee/PureHost and https://github.com/lmgy/Redirect , It seems much simpler than this project, I will try to compile to aar and then try to import.
stevel05 Expert Licensed User Longtime User Nov 12, 2020 #16 If you try a new one or the same one, you will need to turn off obfuscation.
laomms Member Licensed User Longtime User Nov 12, 2020 #17 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.
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.
stevel05 Expert Licensed User Longtime User Nov 12, 2020 #18 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. info in this link may help you turn it off. https://stackoverflow.com/questions/57156648/how-to-add-code-obfuscation-for-my-android-application
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. info in this link may help you turn it off. https://stackoverflow.com/questions/57156648/how-to-add-code-obfuscation-for-my-android-application
laomms Member Licensed User Longtime User Nov 12, 2020 #19 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.
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.
laomms Member Licensed User Longtime User Nov 17, 2020 #20 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 PureHost_SLC_src.zip 127.4 KB · Views: 660 WrapperTest.zip WrapperTest.zip 21.3 KB · Views: 612 Last edited: Nov 18, 2020
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