javaandroidvisual-studiocordovataco

TACO Java Dependencies


I have a Cordova project created using Visual Studio 2015's Tools for Apache Cordova. We're trying to create a plugin that uses an external library, and that library depends on various things such as Google's location services. I've found that they go in a .gradle file, but have no idea how to get them in that file using TACO. I can do it manually, but VS regenerates the .gradle file every time the project's built.

I'm new to TACO, so it may be I'm missing something.


Solution

  • Very common problem when starting out with Cordova Plugins. I've struggled with this in the past. Start by reading this. You need to add some entries to your plugin.xml file. In that file you should have a section for each platform you support. You should also not be modifying the platform/android/build.gradle file directly. Make a separate one which will eventually get it's contents appended to your platform/android/build.gradle using <framework>.

    <platform name="android">
    
    </platform>
    

    In platforms add something similar to match your features:

    Permissions docs

    <config-file target="AndroidManifest.xml" parent="/*">
        <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
        ....
    </config-file>
    

    External Libs docs

    <framework src="src/android/build.gradle" custom="true" type="gradleReference" />
    <source-file src="lib/android/sample-android-sdk/sample.jar" custom="true" target-dir="lib" />