ashraf789 / Cake-VPN

Android VPN app based on OpenVPN library.
GNU General Public License v2.0
382 stars 141 forks source link

How did you add ics-openvpn to your project? #67

Closed houmie closed 3 years ago

houmie commented 3 years ago

Hello Ashraf,

Your project is an amazing example how to utilise ics-openvpn. Thanks for the great work!

I don't understand how you have added vpnLib as a submodule to your project though.

I have done this in my project: 1) Cloned the ics-openvpn repo 2) Created a new empty project 3) Clicked File -> New -> import module and selected main folder from ics-openvpn. I named it vpnLib 4) Built the project 5) Went to build.gradle for openvpn module and changed the following : id("com.android.application") to id("com.android.library") 6) Copied this snippet that exists in build.gradle for the library and pasted it in my build.gradle inside android script:

flavorDimensions("implementation")

    productFlavors {
        create("ui") {
            setDimension("implementation")
            buildConfigField("boolean", "openvpn3", "true")
        }
        create("skeleton") {
            setDimension("implementation")
            buildConfigField("boolean", "openvpn3", "false")
        }
    }

7) Added the module in the dependency in my build.gradle : implementation project(path: ':vpnLib')

Now when I build the project it says:

e: /Users/houmie/projects/myApp/vpnLib/build.gradle.kts:152:9: Unresolved reference: applicationVariants

Code issue in build.gradle.kts is applicationVariants. Why is it red?

android.applicationVariants.all(object : Action<ApplicationVariant> {
    override fun execute(variant: ApplicationVariant) {
        val sourceDir = registerGenTask(variant.name, variant.baseName.replace("-", "/"))
        val task = tasks.named("generateOpenVPN3Swig${variant.name}").get()

        variant.registerJavaGeneratingTask(task, sourceDir)
    }
})

I really hope you can help me. Thank you @ashraf789

ashraf789 commented 3 years ago

Hello, I followed the same process that you did. I have developed this project in 2016 that time ICS open VPN only had java code and later I have updated it according to their new commit.

Currently, ICS VPN added kotlin and their build.gradle also changed a lot. Some contributors updated the current cake VPN library. it may help you https://github.com/ashraf789/Cake-VPN/issues/34

Wish you all the best.

houmie commented 3 years ago

Hello @ashraf789

Thank you for your reply. I have looked at that discussion. But that has resulted into a PR that is merged in by now. That won't really help me. My issue is that I don't know how to import ics-openvpn as a module to a new empty project and get it compiled.

I was hoping to see if you could guide me. Do you think you could try for 2 min to see if you can import it on a new empty project? Maybe you can see anything obvious that I might be missing? It's a shame there is so little documentation about it. :-( I'm not sure where to get help...

ashraf789 commented 3 years ago

Hello, Sorry, I am no longer working with android and I didn't get in touch with kotlin yet so the problem is the same for me. Next time when I get time to update the current project library i will try to write a documentation.

Thanks.

houmie commented 3 years ago

No problem. Thank you. :)