Step 1. Add the JitPack repository to your build file
Add it in your root settings.gradle at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
Add it in your settings.gradle.kts at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url = uri("https://jitpack.io") }
}
}
Add to pom.xml
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
Add it in your build.sbt at the end of resolvers:
resolvers += "jitpack" at "https://jitpack.io"
Add it in your project.clj at the end of repositories:
:repositories [["jitpack" "https://jitpack.io"]]
Step 2. Add the dependency
dependencies {
implementation 'com.github.Scarabei:Flutter:5278588d80-2017-07-24'
}
dependencies {
implementation("com.github.Scarabei:Flutter:5278588d80-2017-07-24")
}
<dependency>
<groupId>com.github.Scarabei</groupId>
<artifactId>Flutter</artifactId>
<version>5278588d80-2017-07-24</version>
</dependency>
libraryDependencies += "com.github.Scarabei" % "Flutter" % "5278588d80-2017-07-24"
:dependencies [[com.github.Scarabei/Flutter "5278588d80-2017-07-24"]]
This is an artifact published in the JitPack repository. This is not functional and only provides stubbed implementations of the Flutter API. All methods in all classes throw a runtime exception. Because an Android app runs on a device, it will never use these libraries for execution, but the API compatibility allows an app to be compiled as if it was the real library.
That would be useful if you are trying to build a java part of your flutter plugin implementation.
Add it in your root build.gradle at the end of repositories:
ext {
flutterAPIversion = "5278588d80-2017-07-24"
}
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
For the latest flutterAPIversion
value see the builds section: https://github.com/Scarabei/Flutter/releases
dependencies {
compile "com.github.Scarabei.Flutter:flutter-api:$flutterAPIversion"
}
Now you can develop/compile your java library aganst the Flutter API without Android and Flutter frameworks. Also you can publish it on a Maven repo.
This part is on you. Should look something like:
dependencies {
compile "com.your.flutter.java-plugin"
}
That would be necessary if you fail to compile your Android app with errors like:
Error:Execution failed for task :app:transformClassesWithDexForDebug.
Error:Error converting bytecode to dex
or similar.
Edit your gradle settings:
android {
defaultConfig {
minSdkVersion ...
targetSdkVersion ...
...
multiDexEnabled = true
}
dexOptions {
javaMaxHeapSize "4g" //specify the heap size for the dex process
}
See the link for details: https://developer.android.com/studio/build/multidex.html
android {
...
configurations {
all*.exclude group: "com.github.Scarabei.Flutter", module: "flutter-api"
}
}
By this we tell AbdroidStudio to discard the stub jar to use the real Flutter API on a device.