All Projects → SgtSilvio → android-retrofix

SgtSilvio / android-retrofix

Licence: Apache-2.0 License
Backports Java 8 APIs (java.util.Optional, java.util.function, java.util.stream, java.util.concurrent.CompletableFuture, java.time) to Android below API 24 (Android 7.0 Nougat)

Programming Languages

java
68154 projects - #9 most used programming language
kotlin
9241 projects

Projects that are alternatives of or similar to android-retrofix

sonatype-publish-plugin
Gradle Plugin for publishing artifacts to Sonatype and Nexus
Stars: ✭ 17 (-66.67%)
Mutual labels:  gradle-plugin
AndroidGo
Android、Flutter 开发者帮助 APP。包含事件分发、性能分析、Google Jetpack组件、OkHttp、RxJava、Retrofit、Volley、Canvas绘制以及优秀博文代码案例等内容,帮助开发者快速上手!
Stars: ✭ 30 (-41.18%)
Mutual labels:  retrofit
Covid19Tracker
A Robinhood style COVID-19 🦠 Android tracking app for the US. Open source and built with Kotlin.
Stars: ✭ 65 (+27.45%)
Mutual labels:  retrofit
poetimizely
Generate Kotlin type safe accessors for Optimizely experiments and features
Stars: ✭ 17 (-66.67%)
Mutual labels:  gradle-plugin
MockFit
Kotlin library to mock http responses that fits into retrofit
Stars: ✭ 14 (-72.55%)
Mutual labels:  retrofit
DaMaiProject
大麦界面,实现多种方式网络访问、数据缓存
Stars: ✭ 24 (-52.94%)
Mutual labels:  retrofit
gv4j
Unofficial Google Voice API for Java.
Stars: ✭ 18 (-64.71%)
Mutual labels:  retrofit
change-tracker-plugin
A Gradle plugin to help analyse the dependency between modules and run tasks only on modules impacted by specific set of changes.
Stars: ✭ 103 (+101.96%)
Mutual labels:  gradle-plugin
GitQuery
Sync files and directories from a remote Git repo. CLI and Gradle Plugin.
Stars: ✭ 25 (-50.98%)
Mutual labels:  gradle-plugin
gradle-console-reporter
Gradle plugin to report various kinds of summaries to console.
Stars: ✭ 49 (-3.92%)
Mutual labels:  gradle-plugin
AndroidResourceTools
Android resource rename plugin.
Stars: ✭ 41 (-19.61%)
Mutual labels:  gradle-plugin
Dexter
Manage multidexing using simple annotations and gradle tasks.
Stars: ✭ 41 (-19.61%)
Mutual labels:  gradle-plugin
plugin-yml
A Gradle plugin that generates plugin.yml for Bukkit/BungeeCord/Nukkit plugins based on the Gradle project
Stars: ✭ 42 (-17.65%)
Mutual labels:  gradle-plugin
tuya-connector
tuya-connector helps you efficiently create cloud development projects regarding the OpenAPI or message subscription capabilities. You can put all the focus on business logic without taking care of server-side programming nor relational databases.
Stars: ✭ 28 (-45.1%)
Mutual labels:  retrofit
Readhub
Readhub AndroidClient
Stars: ✭ 40 (-21.57%)
Mutual labels:  retrofit
EasyRetro
An Easy to use retrofit based network/api call extention for android
Stars: ✭ 16 (-68.63%)
Mutual labels:  retrofit
gradle-libraries-plugin
No description or website provided.
Stars: ✭ 29 (-43.14%)
Mutual labels:  gradle-plugin
kotlinx-resources
Kotlin Multiplatform (KMP) library for reading resources in tests
Stars: ✭ 15 (-70.59%)
Mutual labels:  gradle-plugin
ipapi-retrofit
Android Library for Calling IP-API using Retrofit
Stars: ✭ 47 (-7.84%)
Mutual labels:  retrofit
jooq-plugin
Plugin for generating jOOQ classes using dockerized databases
Stars: ✭ 55 (+7.84%)
Mutual labels:  gradle-plugin

Android RetroFix

Gradle Plugin Portal

Seamlessly backports Java 8 APIs to Android below API 24 (Android 7.0 Nougat)

Seamless means that you use the official Java 8 APIs, or libraries that internally use the official Java 8 APIs, and the plugin replaces the official Java 8 APIs with backport libraries only in the generated artifact. When you increase the minimum Android API level to 24 or higher in the future, you will only need to remove the plugin and the backport dependencies. You do not have to change your code.

Although Android by now supports some Java 8 APIs through desugaring, some important APIs are still not possible to use on Android APIs below 24 - for example CompletableFuture.

Backport Libraries

The following sections list the backported APIs when adding the respective backport library as dependency.

android-retrostreams

Dependency:

dependencies {
    implementation("net.sourceforge.streamsupport:android-retrostreams:1.7.4")
}

Backported new types:

  • java.lang.FuncionalInterface
  • java.util.IntSummaryStatistics, java.util.DoubleSummaryStatistics, java.util.LongSummaryStatistics
  • java.util.Optional**
  • java.util.PrimitiveIterator**
  • java.util.Spliterator**
  • java.util.SplittableRandom
  • java.util.StringJoiner
  • java.util.concurrent.CountedCompleter
  • java.util.concurrent.ForkJoinPool
  • java.util.concurrent.ForkJoinTask
  • java.util.concurrent.ForkJoinWorkerTask
  • java.util.concurrent.RecursiveAction
  • java.util.concurrent.RecursiveTask
  • java.util.concurrent.ThreadLocalRandom
  • java.util.function.**
  • java.util.stream.**

Backported static/default methods of:

  • java.lang.Arrays
  • java.lang.Integer, java.lang.Double, java.lang.Long
  • java.lang.Iterable
  • java.lang.Objects
  • java.util.Collection
  • java.util.Comparator
  • java.util.Iterator
  • java.util.List
  • java.util.Map
  • java.util.Map$Entry
  • java.util.concurrent.ConcurrentMap

android-retrofuture

Dependency:

dependencies {
    implementation("net.sourceforge.streamsupport:android-retrofuture:1.7.4")
}

Backported new types:

  • java.util.concurrent.CompletableFuture
  • java.util.concurrent.CompletionException
  • java.util.concurrent.CompletionStage

threetenbp or threetenabp

Dependency:

dependencies {
    implementation("org.threeten:threetenbp:1.5.1")
    // or 
    implementation("com.jakewharton.threetenabp:threetenabp:1.3.1")
}

Backported new types:

  • java.time.**
  • java.time.chrono.**
  • java.time.format.**
  • java.time.temporal.**
  • java.time.zone.**

Backported conversion methods of:

  • java.util.Date
  • java.util.Calendar
  • java.util.GregorianCalendar
  • java.util.TimeZone
  • java.sql.Date
  • java.sql.Time
  • java.sql.Timestamp

How to Use

Configure your app/build.gradle like the following:

buildscript {
    repositories {
        google() // necessary as this plugin depends on the android gradle api
        gradlePluginPortal() // where this plugin is hosted
    }
    dependencies {
        classpath 'gradle.plugin.com.github.sgtsilvio.gradle:android-retrofix:0.4.1'
    }
}

apply plugin: 'com.android.application'
apply plugin: 'com.github.sgtsilvio.gradle.android-retrofix'
...

android {
    ...
    defaultConfig {
        ...
        minSdkVersion 21 // has to be < 24, if you have 24+ this plugin is not needed
        ...
    }
    ...
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8 // enables lambdas, method references,
        targetCompatibility JavaVersion.VERSION_1_8 //         default methods, static interface methods
    }
    ...
}

dependencies {
    implementation 'net.sourceforge.streamsupport:android-retrostreams:1.7.4' // for backporting streams
    implementation 'net.sourceforge.streamsupport:android-retrofuture:1.7.4' // for backporting future
    implementation 'org.threeten:threetenbp:1.5.1' // for backporting time
    // or implementation 'com.jakewharton.threetenabp:threetenabp:1.3.1'
    ...
}

Android Studio will still display an error "Call requires API level 24 (current min is 21)". This error is actually just a warning. Android Studio does not know that we backport the API, so it still thinks that the API can not be used with the minSdkVersion. You can build and run your app without any problems. If you want to get rid of the warning, just add @SuppressLint("NewApi") to the method or class where you use the API.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].