项目作者: Scarabei

项目描述 :
Flutter API stub artifact
高级语言: Java
项目地址: git://github.com/Scarabei/Flutter.git
创建时间: 2017-07-28T09:07:13Z
项目社区:https://github.com/Scarabei/Flutter

开源协议:

下载


Flutter API

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.

Repo

Usage

In your library

Step 1. Add the JitPack repository to your build file

Add it in your root build.gradle at the end of repositories:

  1. ext {
  2. flutterAPIversion = "5278588d80-2017-07-24"
  3. }
  4. allprojects {
  5. repositories {
  6. ...
  7. maven { url 'https://jitpack.io' }
  8. }
  9. }

For the latest flutterAPIversion value see the builds section: https://github.com/Scarabei/Flutter/releases

Step 2. Add the dependency

  1. dependencies {
  2. compile "com.github.Scarabei.Flutter:flutter-api:$flutterAPIversion"
  3. }

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.

In your Android app project

Step 4. Import your library.

This part is on you. Should look something like:

  1. dependencies {
  2. compile "com.your.flutter.java-plugin"
  3. }

Step 5 (Optional). Enable multidex.

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:

  1. android {
  2. defaultConfig {
  3. minSdkVersion ...
  4. targetSdkVersion ...
  5. ...
  6. multiDexEnabled = true
  7. }
  8. dexOptions {
  9. javaMaxHeapSize "4g" //specify the heap size for the dex process
  10. }

See the link for details: https://developer.android.com/studio/build/multidex.html

Step 6. Exclude the Flutter API stub.

  1. android {
  2. ...
  3. configurations {
  4. all*.exclude group: "com.github.Scarabei.Flutter", module: "flutter-api"
  5. }
  6. }

By this we tell AbdroidStudio to discard the stub jar to use the real Flutter API on a device.