Skip to main content

Android SDK Setup AppSync

To integrate AppsOnAir-AppSync Android SDK to your Android native Apps with Java or Kotlin, follow the below steps

Step 1. Basic Requirements for service usage

apiKey Setup
  • Make sure to configure the API key properly. For additional information Getting started
  • Install or update Android Studio to its latest version.
  • Make sure that your project meets these requirements:
    • Targets API level 24 (NOUGAT) or higher
    • Uses Android 7.0 or higher
    • Android Gradle Plugin (AGP): Version 8.0.2 or higher
    • Requires Gradle version 8.0+
    • Uses Jetpack (AndroidX), which includes meeting these version requirements:
      • compileSdkVersion 34 or later
  • Set up a physical device or use an emulator to run your app.

Step 2. Add AppsOnAir Gradle Plugin and SDK

Newer versions of Android Studio

When creating a new project from Android Studio Artic Fox (or newer) the allprojects{...} is no longer added in the project level gradle.so need add in settings.gradle

settings.gradle

dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
...
maven { url 'https://jitpack.io' }
}
}

Docusaurus logo

gradle.properties
android.useAndroidX = true;
android.enableJetifier = true;

2.1 open your root build.gradle file, add the following

build.gradle

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

2.2 Add the following to your dependencies section.

libs.versions.toml
    [versions]
appsonairAndroidAppsync = "Tag" // latest version

[libraries]
appsonair-android-appsync = { module = "com.github.apps-on-air:AppsOnAir-Android-AppSync", version.ref = "appsonairAndroidAppsync" }
app/build.gradle
    dependencies {
implementation(libs.appsonair.android.appsync)
}

Docusaurus logo

Sync Gradle

Make sure to press "Sync Now" on the banner that pops up after saving!

2.3 Add required code

Add meta-data to the app module's AndroidManifest.xml file under the application tag

AndroidManifest.xml
    <!-- add meta-data inside application tag -->
<application>
<!-- App icon for dialog -->
<meta-data
android:name="com.appsonair.icon"
android:resource="@drawable/app_icon" />

<!-- App name for dialog -->
<meta-data
android:name="com.appsonair.name"
android:value="app_name" />
</application>

appimage

Step 3. Add the AppSync Service Initialization code and usage

To initialize the app update functionality, we recommend adding the initialization code within the onCreate method of your Main Launcher Activity (MainActivity.java).

MainActivity.java
import com.appsonair.appsync.services.AppSyncService;

public class MainActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

// Initializing AppSyncService with callback for custom UI
AppSyncService.sync(this, new java.util.HashMap<String, Object>() {{
put("showNativeUI", true);
}},new UpdateCallBack() {
@Override
public void onSuccess(String response) {
Log.d("TAG", "onSuccess: ");
}

@Override
public void onFailure(String message) {
Log.d("TAG", "onFailure: ");
}
});
}
}

Properties Information

sync(context: Context,options: Map<String, Any> = emptyMap(),callBack: UpdateCallBack? = null)
  • This method initializes the AppSync services .
  • context: The context of the activity in which the remark service is being initialized.
  • options : parameter is a Map that allows you to configure settings such as showNativeUI to control the display behavior of the UI.
  • callBack() : parameter provides methods for handling the result of the synchronization: onSuccess is called when the process completes successfully, and onFailure is invoked in case of an error.

Step 4. Run your App and Setup your app update and/or its maintenance services

Run your app by using Android Studio on Android simulators or any physical device to make sure it builds correctly.

note
Note that to check the App Update and maintenance services are only configured from AppsOnAir portal.

For more details explore the example