Adam
Adam

Reputation: 1142

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.

EDIT: I have also tried changing the dependencies/vocsy_epub_viewer/android/build.gradle as suggested by @Sajjad to:

implementation project(':folioreader')

but got the following error:

FAILURE: Build failed with an exception.

* Where:
Build file 'C:\Users\test\Documents\Projects\waily\dependencies\vocsy_epub_viewer\android\build.gradle' line: 40

* What went wrong:
A problem occurred evaluating project ':vocsy_epub_viewer'.
> Project with path ':folioreader' could not be found in project ':vocsy_epub_viewer'.

Upvotes: 3

Views: 975

Answers (1)

Sajjad
Sajjad

Reputation: 3218

please check this way.

reference your custom vocsy_epub_viewer_android_folioreader from https://jitpack.io


step 1 : Add it in your flutterRoot > vocsy_epub_viewer > android > build.gradle at the end of repositories:

allprojects {
    repositories {
        ...
        maven { url 'https://jitpack.io' }
    }
}

Step 2. Add the dependency

dependencies {
            implementation 'com.github.vongrad:vocsy_epub_viewer_android_folioreader:master-SNAPSHOT'
    }

Upvotes: 1

Related Questions