Wednesday, 25 January 2023

Import Android project into a Flutter package

I am developing a Flutter app that uses my own fork of a Flutter package called vocsy_epub_viewer (https://github.com/vongrad/vocsy_epub_viewer) as I need to make some changes in it.

I have included the plugin in pubspec.yaml and this part is working well:

dev_dependencies:
  vocsy_epub_viewer:
    path: dependencies/vocsy_epub_viewer

The vocsy_epub_viewer package contains a Flutter plugin acting as a bridge to call some platform specific code - for Android it is using vocsy_epub_viewer_android_folioreader. I have made a fork of this Android package as well (https://github.com/vongrad/vocsy_epub_viewer_android_folioreader) since I need to make changes in it.

In the Flutter package's dependencies/vocsy_epub_viewer/android/build.gradle file, the Android package was referenced as:

dependencies {
    implementation 'com.github.kaushikgodhani:vocsy_epub_viewer_android_folioreader:V3'
}

I however need to make it such that it is referenced from a local folder where it was cloned (./vocsy_epub_viewer_android_folioreader).

The project structure looks as following:

flutter project root
    dependencies
        vocsy_epub_viewer
            android
                settings.gradle
                build.gradle
                
    android
        settings.gradle
        build.gradle
    ios
    lib
    ...
    
vocsy_epub_viewer_android_folioreader  <--- this plugin needs to be included within vocsy_epub_viewer/android
    folioreader
        settings.gradle
        build.gradle
    settings.gradle
    build.gradle

I have tried to include it as following:

dependencies/vocsy_epub_viewer/android/settings.gradle

include ':folioreader'
project(':folioreader').projectDir = file('C:\\Users\\test\\Documents\\Projects\\vocsy_epub_viewer_android_folioreader')

dependencies/vocsy_epub_viewer/android/build.gradle

dependencies {
    implementation "com.folioreader:folioreader" <-- attempt to import the package from a local folder
    // implementation 'com.github.kaushikgodhani:vocsy_epub_viewer_android_folioreader:V3' <-- original import
}

But it does not seem to work. I would greatly appreciate if I could get an advice as of how to do this.



from Import Android project into a Flutter package

No comments:

Post a Comment