Blog Infos
Author
Published
Topics
Published
Topics
What is library compatibility?

 

Library compatibility [made with canva]

 

1. Backward Compatibility
2. Forward Compatibility
Source Compatibility and Binary Compatibility
Source Compatibility (API- Application Programming Interface Compatibility)
Binary Compatibility (ABI- Application Binary Interface Compatibility)

Android compilation process[made with canva]

Version Scheme in Library
Binary Compatibility Validator Plugin- Public API management tool

Binary compatibility validator workflow [made with canva]

Steps to include the binary compatibility validator
1 . Add gradle dependency at the Project level
 plugins {

    id 'org.jetbrains.kotlinx.binary-compatibility-validator' version '0.12.1' apply false
}
apiValidation {

    ignoredPackages.add("com/example/myapplication/ui/theme")
    ignoredClasses.add("com/example/myapplication/BuildConfig")
    ignoredProjects += ["example3", "subproject2"]
    nonPublicMarkers.add("my.package.MyInternalApiAnnotation")
    validationDisabled = false
}

 

Job Offers

Job Offers

There are currently no vacancies.

OUR VIDEO RECOMMENDATION

,

REST in Peace: A Journey Through API Protection

Isn’t Droidcon a Mobile Developer’s conference? So, why would I care about protecting REST APIs? Well, think twice! API protection starts in the app, as the protection level of the API will be only as…
Watch Video

REST in Peace: A Journey Through API Protection

Andreas Luca & Marc Obrador Sureda
Head of Solution Integration & CTO , Co-founder
Build38

REST in Peace: A Journey Through API Protection

Andreas Luca & Mar ...
Head of Solution Int ...
Build38

REST in Peace: A Journey Through API Protection

Andreas Luca & M ...
Head of Solution Integrat ...
Build38

Jobs

2 . Perform tasks
* How it works
fun square(x: Int): Int{
    return x * x
}

@PublishedApi
internal fun sample2() {
   val num: Double = 3.16
}
— apiDumb(First task)
path > ./gradlew apiDump
public final class com/example/myapplication/MainActivityKt {
 public static final fun sample2 ()V
 public static final fun square (I)I
}
* Overview of Public API
//Added new interface sample
interface Sample { 
    var hello: String
    fun print()
}
//Changed name of function sample2() to sample()

@PublishedApi
internal fun sample() {
   val num: Double = 3.16
}
//implemted interface in mainActivity Class
class MainActivity(override var hello: String) : Sample {
    override fun print() {
        TODO("Not yet implemented")
    }
}
 apiCheck(Second Task)
path > ./gradlew apiCheck
path> ./gradlew apiCheck
> Task :app:compileReleaseKotlin
w: path\com\example\myapplication\MainActivity.kt: (10, 8): Variable 'num' is never used
> Task :app:apiCheck FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:apiCheck'.
> API check failed for project app.
 - - D:\MyApplication\app\api\app.api
 +++ D:\MyApplication\app\build\api\app.api
 @@ -1,6 +1,20 @@
 +public final class com/example/myapplication/MainActivity : com/example/myapplication/Sample {
 + public static final field $stable I
 + public fun <init> (Ljava/lang/String;)V
 + public fun getHello ()Ljava/lang/String;
 + public fun print ()V
 + public fun setHello (Ljava/lang/String;)V
 +}
 +
 public final class com/example/myapplication/MainActivityKt {
 - public static final fun sample2 ()V
 + public static final fun sample ()V
 public static final fun square (I)I
 }
+public abstract interface class com/example/myapplication/Sample {
 + public abstract fun getHello ()Ljava/lang/String;
 + public abstract fun print ()V
 + public abstract fun setHello (Ljava/lang/String;)V
 +}
+
You can run :app:apiDump task to overwrite API declarations

So to fix this we should execute the first task (apiDumb) one more time which will produce a new Public Api.

path > ./gradlew apiDump
public final class com/example/myapplication/MainActivity : com/example/myapplication/Sample {
   public static final field $stable I
   public fun <init> (Ljava/lang/String;)V
   public fun getHello ()Ljava/lang/String;
   public fun print ()V
   public fun setHello (Ljava/lang/String;)V
}

public final class com/example/myapplication/MainActivityKt {
   public static final fun sample ()V
   public static final fun square (I)I
}

public abstract interface class com/example/myapplication/Sample {
   public abstract fun getHello ()Ljava/lang/String;
   public abstract fun print ()V
   public abstract fun setHello (Ljava/lang/String;)V
}

This article was originally published on proandroiddev.com

YOU MAY BE INTERESTED IN

YOU MAY BE INTERESTED IN

blog
This tutorial is the second part of the series. It’ll be focussed on developing…
READ MORE
blog
We recently faced a problem with our application getting updated and reaching slowly to…
READ MORE
blog
A few weeks ago I started with a simple question — how to work…
READ MORE
blog
One of the main functions of a mobile phone was to store contacts information.…
READ MORE

Leave a Reply

Your email address will not be published. Required fields are marked *

Fill out this field
Fill out this field
Please enter a valid email address.

Menu