Android SDK Integration Guide

Last updated:2026-08-27
Expand all
Android SDK Integration Guide

Usage tips

This article is JPush Android SDK Standard integration guide document. for guidance SDK By default, readers are already familiar with the usage of IDE(Eclipse or Android Studio), as well as having certain Android Basic programming knowledge.

This guide matches JPush Android SDK The version is:3.0.0 and later versions.

  • Completed in three minutes Demo experience (Android): If you want to quickly test and feelJPushFor the effect, please refer to this article to run through it in a few minutes. Demo。
  • JPush Documentation website Up, there isJPushAll related guides,API, tutorials and all other documents. Updated versions, including those of this document, will be posted to this website in a timely manner.
  • If you see this document but haven't downloaded it yet Android SDK, please visit Assemble SDK Serve and download.

Product function description

JPush is an end-to-end push service that delivers server-side messages to users' devices in a timely manner. It helps developers stay connected with users, improve user engagement, and increase app retention. The JPush client supports Android, iOS, HarmonyOS, and QuickApp.

The Android SDK enables developers to quickly add JPush capabilities to Android apps.

Main functions

  • Maintain a long connection with the server so that messages can be pushed to the client instantly
  • Receive notifications and custom messages, and send them to developers App convey relevant information

Main features

  • The client maintains a connection that takes up less resources and consumes less power.
  • SDK Rich interface, customizable notification bar prompt style
  • The server has large capacity and is stable

SDK supported Android System version

  • Starting from JPush Android SDK v6.0.3, the minimum supported version is Android 5.0 (API 21). When integrating v6.0.3 or later, the application's minSdkVersion must be at least 21. Rich media feeds and in-app messages are subject to the same minimum system version.
  • For earlier versions, refer to the integration package and release notes for that SDK version, and also meet the system version requirements of the corresponding JCore and vendor channel SDKs.

When using JPush Android SDK v6.0.3 or later, configure the minimum system version in the app module's build.gradle, for example:

android { defaultConfig { minSdkVersion 21 } }
          android {
    defaultConfig {
        minSdkVersion 21
    }
}

        
This code block is shown in the floating window

With Gradle automatic integration, you do not need to manually add SDK JAR or SO files. Gradle resolves and downloads SDK dependencies, and the Android build tools merge the Manifest from the AAR. You must still configure the AppKey, callback components, and other settings described below.

If you need to process the received message, use 3.0.7 Version supports new interfaces for aliases and tags,AndroidManifest Custom broadcast receivers in still need to be manually configured by developers, refer to SDK in compressed package AndroidManifest.xml Sample files.

Modify component properties

To modify component properties, define the component with the same name in the local AndroidManifest, configure the required properties, and use xmlns:tools to let the local definition override the component in the SDK AAR. Example:

<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.android.tests.flavorlib.app" xmlns:tools="http://schemas.android.com/tools"> <application android:icon="@drawable/icon" android:name="com.example.jpushdemo.ExampleApplication" android:label="@string/app_name" > </application> </manifest>
          <manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.android.tests.flavorlib.app"
    xmlns:tools="http://schemas.android.com/tools">

    <application
        android:icon="@drawable/icon"
        android:name="com.example.jpushdemo.ExampleApplication"
        android:label="@string/app_name" >

  </application>

</manifest>

        
This code block is shown in the floating window

Configure the SDK Dependency Repository

Add the official Jiguang SDK Maven repository to the project's dependency repository configuration. No download account is required. Keep the existing SDK group ID, artifact ID, and dependency declarations unchanged, and specify a published version as described in the next section. Retain google() and mavenCentral() so that other project dependencies can still be resolved.

If the project centrally manages dependency repositories in settings.gradle or settings.gradle.kts, add the following Maven configuration to the existing dependencyResolutionManagement.repositories block. Do not create a duplicate block. This syntax applies to both file types; retain the project's existing repositoriesMode setting.

dependencyResolutionManagement { repositories { google() maven { url = uri("https://maven.jiguang.cn/nexus/content/repositories/releases/") } mavenCentral() } }
          dependencyResolutionManagement {
    repositories {
        google()
        maven {
            url = uri("https://maven.jiguang.cn/nexus/content/repositories/releases/")
        }
        mavenCentral()
    }
}

        
This code block is shown in the floating window

For an older project that still manages dependency repositories through allprojects.repositories in the root build.gradle, add:

allprojects { repositories { google() maven { url = uri("https://maven.jiguang.cn/nexus/content/repositories/releases/") } mavenCentral() } }
          allprojects {
    repositories {
        google()
        maven {
            url = uri("https://maven.jiguang.cn/nexus/content/repositories/releases/")
        }
        mavenCentral()
    }
}

        
This code block is shown in the floating window

Use only the configuration that matches the project's existing repository management location. Do not configure both. The SDK repository is used for dependency resolution, so do not add it only to buildscript.repositories; the existing plugin repository configuration does not need to be changed.

Configure dependencies and substitution variables

exist module of gradle Add dependencies and AndroidManifest replacement variable.

android { ...... defaultConfig { applicationId "com.xxx.xxx" //JPush 上注册的包名. ...... ndk { //选择要添加的对应 cpu 类型的 .so 库。 abiFilters 'armeabi', 'armeabi-v7a', 'arm64-v8a' // 还可以添加 'x86', 'x86_64', 'mips', 'mips64' } manifestPlaceholders = [ JPUSH_PKGNAME : applicationId, JPUSH_APPKEY : "你的 Appkey ", //JPush 上注册的包名对应的 Appkey. JPUSH_CHANNEL : "developer-default", //暂时填写默认值即可. ] ...... } ...... } dependencies { ...... implementation 'cn.jiguang.sdk:jpush:5.8.0' // 必选,此处以JPush 5.8.0 版本为例,注意:5.0.0 版本开始可以自动拉取 JCore 包,无需另外配置 implementation 'cn.jiguang.sdk:joperate:2.0.2' // 可选,集成极光分析SDK后,即可支持行为触发推送消息、推送转化率统计,用户行为分析和用户标签等功能 }
          android {
    ......
    defaultConfig {
    applicationId "com.xxx.xxx" //JPush 上注册的包名.
    ......

    ndk {
        //选择要添加的对应 cpu 类型的 .so 库。
        abiFilters 'armeabi', 'armeabi-v7a', 'arm64-v8a'
        // 还可以添加 'x86', 'x86_64', 'mips', 'mips64'
    }

    manifestPlaceholders = [
        JPUSH_PKGNAME : applicationId,
        JPUSH_APPKEY : "你的 Appkey ", //JPush 上注册的包名对应的 Appkey.
        JPUSH_CHANNEL : "developer-default", //暂时填写默认值即可.
    ]
    ......
}
......
}

dependencies {
......

implementation 'cn.jiguang.sdk:jpush:5.8.0'        // 必选,此处以JPush 5.8.0 版本为例,注意:5.0.0 版本开始可以自动拉取 JCore 包,无需另外配置
implementation 'cn.jiguang.sdk:joperate:2.0.2'     // 可选,集成极光分析SDK后,即可支持行为触发推送消息、推送转化率统计,用户行为分析和用户标签等功能

}

        
This code block is shown in the floating window

JiguanganalyzeSDKmore features andAPISee detailsJiguanganalyzeSDKIntegration Guide

  • If you need to use a specific version JCore, you can use the following command to no longer automatically pull the latest versionjcore

    implementation ('cn.jiguang.sdk:jpush:5.8.0'){ exclude group: 'cn.jiguang.sdk', module: 'jcore' //不再使用自动拉取的最新版 JCore } implementation 'cn.jiguang.sdk:jcore:5.x.x' //使用指定的 JCore 版本
              implementation ('cn.jiguang.sdk:jpush:5.8.0'){
         exclude group: 'cn.jiguang.sdk', module: 'jcore'   //不再使用自动拉取的最新版 JCore
    }
    implementation 'cn.jiguang.sdk:jcore:5.x.x'               //使用指定的 JCore 版本
    
            
    This code block is shown in the floating window
  • when used JPush ≥ 5.0.0 and JCore < 4.2.0When, you need to add the following configuration in the manifest file:

<provider tools:node="remove" android:exported="false" android:authorities="${applicationId}.jiguang.InitProvider" android:name="cn.jpush.android.service.InitProvider"></provider>
          <provider tools:node="remove"
            android:exported="false"
            android:authorities="${applicationId}.jiguang.InitProvider"
            android:name="cn.jpush.android.service.InitProvider"></provider>

        
This code block is shown in the floating window
  • If used JPush < 5.0.0 version, configuration is required JCore rely:
implementation 'cn.jiguang.sdk:jpush:4.x.x' implementation 'cn.jiguang.sdk:jcore:4.x.x'
          implementation 'cn.jiguang.sdk:jpush:4.x.x'
implementation 'cn.jiguang.sdk:jcore:4.x.x'

        
This code block is shown in the floating window

Google Play Version

If you wish to use Google Play version, you need to select it when automatically integrating Google Play Version correspondence SDK

  • 5.0.0 Version can be automatically pulled at the beginning JCore Package, no additional configuration is required, the configuration is as follows:
dependencies { ...... implementation 'cn.jiguang.sdk:jpush-google:5.8.0' // 此处以JPush 5.8.0 Google Play 版本为例, }
          dependencies {
......

implementation 'cn.jiguang.sdk:jpush-google:5.8.0'  // 此处以JPush 5.8.0 Google Play 版本为例,

}

        
This code block is shown in the floating window
  • If you want to eliminate JPush automatically dependent JCore, you can use the following methods:
implementation ('cn.jiguang.sdk:jpush-google:5.8.0'){ exclude group: 'cn.jiguang.sdk', module: 'jcore-google'//会自动把 JCore 剔除 }
          
implementation ('cn.jiguang.sdk:jpush-google:5.8.0'){
       exclude group: 'cn.jiguang.sdk', module: 'jcore-google'//会自动把 JCore 剔除
}

        
This code block is shown in the floating window
  • NOTE: When usingJPush 5.0.0 and above, the user removedJPushautomatically dependentJCoreversion, and use your own dependentJCoreother versions asJCoreversion< 4.2.0When, you need to add the following configuration in the manifest file:
<provider tools:node="remove" android:exported="false" android:authorities="${applicationId}.jiguang.InitProvider" android:name="cn.jpush.android.service.InitProvider"></provider>
          <provider tools:node="remove"
            android:exported="false"
            android:authorities="${applicationId}.jiguang.InitProvider"
            android:name="cn.jpush.android.service.InitProvider"></provider>

        
This code block is shown in the floating window
  • If using JPush 5.0.0 and below versions, configuration is required JCore rely:
implementation 'cn.jiguang.sdk:jpush-google:4.x.x' implementation 'cn.jiguang.sdk:jcore-google:4.x.x'
          implementation 'cn.jiguang.sdk:jpush-google:4.x.x'
implementation 'cn.jiguang.sdk:jcore-google:4.x.x'

        
This code block is shown in the floating window

Configuration Service

If you use JCore yes 2.0.0 and above versions require additional Androidmanifest Configure one in Service, to obtain more stable support on more mobile phone platforms, examples are as follows. (JCore1.x Version is not required)

<!-- Since JCore2.0.0 Required SDK核心功能--> <!-- 可配置android:process参数将Service放在其他进程中;android:enabled属性不能是false --> <!-- 这个是自定义Service,要继承极光JCommonService,可以在更多手机平台上使得推送通道保持的更稳定 --> <service android:name="xx.xx.XService" android:enabled="true" android:exported="false" android:process=":pushcore"> <intent-filter> <action android:name="cn.jiguang.user.service.action" /> </intent-filter> </service>
           <!-- Since JCore2.0.0 Required SDK核心功能-->
 <!-- 可配置android:process参数将Service放在其他进程中;android:enabled属性不能是false -->
 <!-- 这个是自定义Service,要继承极光JCommonService,可以在更多手机平台上使得推送通道保持的更稳定 -->
 <service android:name="xx.xx.XService"
         android:enabled="true"
         android:exported="false"
         android:process=":pushcore">
         <intent-filter>
             <action android:name="cn.jiguang.user.service.action" />
         </intent-filter>
 </service>

        
This code block is shown in the floating window

Configuration Receiver

from JPush3.0.7 To start, you need to configure inheritance JPushMessageReceiver broadcast, it turns out that if it is equipped with MyReceiver It can now be deprecated. Examples are as follows.

<!-- Required since 3.0.7 --> <!-- 新的 tag/alias 接口结果返回需要开发者配置一个自定的广播 --> <!-- 3.3.0开始所有事件将通过该类回调 --> <!-- 该广播需要继承 JPush 提供的 JPushMessageReceiver 类, 并如下新增一个 Intent-Filter --> <receiver android:name="自定义 Receiver" android:enabled="true" android:exported="false" > <intent-filter> <!-- 从 JPush v5.4.0 版本开始,请特别注意 RECEIVER_MESSAGE 写法, 如配置错误则无法找到回调类 --> <action android:name="cn.jpush.android.intent.RECEIVER_MESSAGE" /> <category android:name="您应用的包名" /> </intent-filter> </receiver>
           <!-- Required since 3.0.7 -->
 <!-- 新的 tag/alias 接口结果返回需要开发者配置一个自定的广播 -->
 <!-- 3.3.0开始所有事件将通过该类回调 -->
 <!-- 该广播需要继承 JPush 提供的 JPushMessageReceiver 类, 并如下新增一个 Intent-Filter -->
 <receiver
       android:name="自定义 Receiver"
       android:enabled="true"
       android:exported="false" >
       <intent-filter>
            <!-- 从 JPush v5.4.0 版本开始,请特别注意 RECEIVER_MESSAGE 写法, 如配置错误则无法找到回调类 -->
            <action android:name="cn.jpush.android.intent.RECEIVER_MESSAGE" />
            <category android:name="您应用的包名" />
       </intent-filter>
 </receiver>

        
This code block is shown in the floating window

Note:SDKCallback method description

  • SDKVersion:3.0.7<= x < 5.2.0 and 5.4.0and above usereceiver Way
  • SDKVersion:5.2.0<= x <=5.3.1 useservice Way

Note: If adding the above abiFilter After configuration android Studio The following prompt appears:

NDK integration is deprecated in the current plugin. Consider trying the new experimental plugin
          NDK integration is deprecated in the current plugin. Consider trying the new experimental plugin

        
This code block is shown in the floating window

then in Project root directory gradle.properties Add to the file:

android.useDeprecatedNdk=true
          android.useDeprecatedNdk=true

        
This code block is shown in the floating window

Note: Use NDK r17 time, maybe Android Studio The following prompt will appear:

A problem occurred starting process ‘command ‘/Users/xxx/Library/Android/sdk/ndk-bundle/toolchains/mips64el-linux-android-4.9/prebuilt /darwin-x86_64/bin/mips64el-linux-android-strip” 系统找不到指定的文件
          A problem occurred starting process ‘command
‘/Users/xxx/Library/Android/sdk/ndk-bundle/toolchains/mips64el-linux-android-4.9/prebuilt
/darwin-x86_64/bin/mips64el-linux-android-strip”

系统找不到指定的文件

        
This code block is shown in the floating window

This is because NDK r17 No longer supported later mips platform, on build.gradle Add the following configuration to solve the problem

android { defaultConfig { ..... } packagingOptions { doNotStrip '*/mips/*.so' doNotStrip '*/mips64/*.so' } }
          android {

    defaultConfig {
        .....
    }

    packagingOptions {
        doNotStrip '*/mips/*.so'
        doNotStrip '*/mips64/*.so'
    }
}

        
This code block is shown in the floating window

If not res/drawable-xxxx/jpush_notification_icon This resource uses the app icon for notifications by default icon,exist 5.0 The above system uses the application icon as statusbar icon May display abnormally, user can define without shadow and gradient color icon Replace this file without changing the file name.

Configuration and code description

Required permission description

Permissions use
You Package.permission.JPUSH_MESSAGE Officially defined permissions that allow applications to receive JPush Broadcast message sent by internal code.
INTERNET Allows the application to access the network.
ACCESS_NETWORK_STATE Allows the application to obtain network information status, such as whether the current network connection is valid.

integrated JPush Android SDK confusion

  • Please download 4.x and above versions proguard.jar, and replace your Android SDK "tools\proguard\lib\proguard.jar"

  • Please add the following configuration to the obfuscation file of the project:

-dontoptimize -dontpreverify -dontwarn cn.jpush.** -keep class cn.jpush.** { *; } -keep class * extends cn.jpush.android.service.JPushMessageReceiver { *; } -dontwarn cn.jiguang.** -keep class cn.jiguang.** { *; }
              -dontoptimize
    -dontpreverify

    -dontwarn cn.jpush.**
    -keep class cn.jpush.** { *; }
    -keep class * extends cn.jpush.android.service.JPushMessageReceiver { *; }

    -dontwarn cn.jiguang.**
    -keep class cn.jiguang.** { *; }

        
This code block is shown in the floating window
  • 2.0.5 ~ 2.1.7 The version has been introduced gson and protobuf, add configuration to eliminate confusion. (2.1.8 Version does not need to be configured)
#==================gson && protobuf========================== -dontwarn com.google.** -keep class com.google.gson.** {*;} -keep class com.google.protobuf.** {*;}
                  #==================gson && protobuf==========================
        -dontwarn com.google.**
        -keep class com.google.gson.** {*;}
        -keep class com.google.protobuf.** {*;}

        
This code block is shown in the floating window

About resource confusion

Jiguang SDK Resources cannot be confused. If there is resource confusion, you need to add the following whitelist:

andResGuard { ... whiteList = [ "R.xml.jpush*", "R.drawable.jpush*", "R.layout.jpush*", "R.layout.push*", "R.string.jg*", "R.style.MyDialogStyle", "R.style.JPushTheme" ] ... }
          andResGuard {
   ...
    whiteList = [
        "R.xml.jpush*",
        "R.drawable.jpush*",
        "R.layout.jpush*",
        "R.layout.push*",
        "R.string.jg*",
        "R.style.MyDialogStyle",
        "R.style.JPushTheme"
    ]
    ...
}

        
This code block is shown in the floating window

add code

JPush SDK provided API Interfaces are mainly concentrated on cn.jpush.android.api.JPushInterface In the category.

Base API

  • init initialization SDK and enable push service API

Special reminder:
1. consider APP For online compliance, developers must beAPPThe user agrees to the privacy policy and the developer identifies asAppAfter the user starts to provide push services, call this interface to enable the push business function for use.JiguangServe.
2. About APP Privacy policy suggestions and instructions, please refer to JPushSDKCompliance Guidelines。

public static void init(Context context, JPushConfig config);
          public static void init(Context context, JPushConfig config);

        
This code block is shown in the floating window
  • setDebugMode Set debug mode

Note: This interface needs to be in init Call before the interface to avoid the situation where some logs are not printed. In the case of multi-process, it is recommended to use customized Application middle onCreate call in.

// You can enable debug mode in developing state. You should close debug mode when release. public static void setDebugMode(boolean debugEnalbed)
          // You can enable debug mode in developing state. You should close debug mode when release.
public static void setDebugMode(boolean debugEnalbed)

        
This code block is shown in the floating window

Add statistics code

Call the sample code (reference example project)

  • init This only needs to be called once when the application starts API That’s it.

  • The following code customizes this application Application kind. need to be in AndoridManifest.xml configuration. Please refer to the above AndroidManifest.xml fragment, or example project.

public class ExampleApplication extends Application { @Override public void onCreate() { super.onCreate(); JPushInterface.setDebugMode(true); // 调整点一:调用启用推送业务功能代码前增加setAuth调用 boolean isPrivacyReady; // app根据是否已弹窗获取隐私授权来赋值 if(!isPrivacyReady){ // JCore 5.0.4之前版本需要显式设置false if (JCoreInterface.getJCoreSDKVersionInt() < 504) { // 5.0.4版本号对应504 JCollectionAuth.setAuth(context, false); } // 所有版本在未授权时都不应初始化SDK return; } JPushInterface.init(this); // 调整点二:App用户同意了隐私政策授权,并且开发者确定要开启推送服务后调用 // JCore 5.0.4+会自动处理授权状态,可不需要显式设置true JCollectionAuth.setAuth(context, true); } }
          public class ExampleApplication extends Application {
    @Override
    public void onCreate() {
        super.onCreate();
        JPushInterface.setDebugMode(true);

      // 调整点一:调用启用推送业务功能代码前增加setAuth调用
      boolean isPrivacyReady; // app根据是否已弹窗获取隐私授权来赋值
      if(!isPrivacyReady){
        // JCore 5.0.4之前版本需要显式设置false
        if (JCoreInterface.getJCoreSDKVersionInt() < 504) { // 5.0.4版本号对应504
          JCollectionAuth.setAuth(context, false);
        }
        // 所有版本在未授权时都不应初始化SDK
        return;
      }
      JPushInterface.init(this);


      // 调整点二:App用户同意了隐私政策授权,并且开发者确定要开启推送服务后调用
      // JCore 5.0.4+会自动处理授权状态,可不需要显式设置true
      JCollectionAuth.setAuth(context, true);
      
    }
}

        
This code block is shown in the floating window

Test confirmation

  • Confirm that the required permissions have been added. If the necessary permissions are not added, the log will prompt an error.
  • confirm AppKey(exist Portal generated on) has been written correctly Androidmanifest.xml 。
  • Confirm that it is called when the program starts init(context)interface
  • Confirm that the test phone (or simulator) has successfully connected to the network
    • Client call init Soon after, if everything is normal, there should be log information indicating successful login.
  • Start the application in Portal Send a custom message or notification bar prompt to the application. For details, please refer to Create push。
  • Within a few seconds, the client should receive the delivered notification or definition message. If SDK If the operation is normal, the log information will be as follows:
[JPushInterface] action:init ....... [ConnectingHelper] Login succeed
          [JPushInterface] action:init
.......
[ConnectingHelper] Login succeed

        
This code block is shown in the floating window

As shown in the figure, client startup is divided into 4 steps:

  • examine metadata of appKey and channel, if it does not exist, the startup fails
  • initialization JPush SDK,examine JNI Wait for the validity of the library file. If the library file is invalid, the startup will fail.
  • examine Androidmanifest.xml, if there is Required If the permission does not exist, the startup will fail.
  • Connect to the server to log in. If there is a network problem, the login fails, or there is a problem with the first three steps and it will not start. JPush SDK

Advanced functions

get Registration ID interaction suggestions

becauseJPushAll forms of push will eventually be converted into Registration ID push, so you need to provide it when troubleshooting customer problems Registration ID. In order to facilitate online customers to accurately provide information and reduce communication costs, we recommend that you complete SDK After integration, in App Display customer information in less commonly used UIs such as [About], [Feedback], [My] and so on. Registration ID 。

Sample code:

JPushInterface.getRegistrationID(getContext());
          JPushInterface.getRegistrationID(getContext());

        
This code block is shown in the floating window

The effect is as shown in the figure:

Other functions

Please refer to:

API:Android

Other integration methods

Assembly service integration method

The assembly service encapsulates manual SDK integration by combining the SDK into a separate jiguang module. It hides common manual-integration configuration so developers can focus on application-specific settings, reducing integration steps.

To use the JPush assembly service, select JPush on the assembly page and assemble the SDK. jpush_android_3m

jiguang_sdk.zip Integrated compressed package content description

  • jiguang
    • JIGUANG SDK assembly module.
    • The JPush AAR is included under the module's libs/. SDK components and resources are merged automatically, so dependencies do not need to be copied manually.
  • jiguang-demo
    • A complete Android demo project showing the basic usage of the assembly service.
    • It is built from the services you select, and preset configuration is included in the demo.

import JIGUANG SDK

Import the SDK into the project as a module using Android Studio.

Import steps:AndroidStudio -> File -> New -> Import Module -> Select jiguang import

Configuration JIGUANG SDK

settings.gradle Configuration added:

include ':jiguang'
          include ':jiguang'

        
This code block is shown in the floating window

Add the SDK dependency to the app's Gradle configuration:

android { ...... defaultConfig { applicationId "com.xxx.xxx" //JPush 上注册的包名. ...... manifestPlaceholders = [ JPUSH_PKGNAME : applicationId, JPUSH_APPKEY : "你的 Appkey ", //JPush 上注册的包名对应的 Appkey. JPUSH_CHANNEL : "developer-default", //暂时填写默认值即可. ] ...... } ...... } dependencies { ...... implementation project(':jiguang') ...... }
          android {
    ......
    defaultConfig {
        applicationId "com.xxx.xxx" //JPush 上注册的包名.
        ......

        manifestPlaceholders = [
            JPUSH_PKGNAME : applicationId,
            JPUSH_APPKEY : "你的 Appkey ", //JPush 上注册的包名对应的 Appkey.
            JPUSH_CHANNEL : "developer-default", //暂时填写默认值即可.
        ]
        ......
    }
    ......
}

dependencies {
    ......

    implementation project(':jiguang')
    ......
}

        
This code block is shown in the floating window

Configure the following two application-specific components in AndroidManifest. SDK-owned components are merged from the AAR:

<!-- Since JCore2.0.0 Required SDK核心功能--> <!-- 可配置android:process参数将Service放在其他进程中;android:enabled属性不能是false --> <!-- 这个是自定义Service,要继承极光JCommonService,可以在更多手机平台上使得推送通道保持的更稳定 --> <service android:name="xx.xx.XService" android:enabled="true" android:exported="false" android:process=":pushcore"> <intent-filter> <action android:name="cn.jiguang.user.service.action" /> </intent-filter> </service> <!-- Required since 3.0.7 --> <!-- 新的 tag/alias 接口结果返回需要开发者配置一个自定的广播 --> <!-- 3.3.0开始所有事件将通过该类回调 --> <!-- 该广播需要继承 JPush 提供的 JPushMessageReceiver 类, 并如下新增一个 Intent-Filter --> <receiver android:name="Custom Receiver" android:enabled="true" android:exported="false" > <intent-filter> <action android:name="cn.jpush.android.intent.RECEIVER_MESSAGE" /> <category android:name="您应用的包名" /> </intent-filter> </receiver>
          <!-- Since JCore2.0.0 Required SDK核心功能-->
<!-- 可配置android:process参数将Service放在其他进程中;android:enabled属性不能是false -->
<!-- 这个是自定义Service,要继承极光JCommonService,可以在更多手机平台上使得推送通道保持的更稳定 -->
<service android:name="xx.xx.XService"
        android:enabled="true"
        android:exported="false"
        android:process=":pushcore">
        <intent-filter>
            <action android:name="cn.jiguang.user.service.action" />
        </intent-filter>
</service>

 <!-- Required since 3.0.7 -->
 <!-- 新的 tag/alias 接口结果返回需要开发者配置一个自定的广播 -->
 <!-- 3.3.0开始所有事件将通过该类回调 -->
 <!-- 该广播需要继承 JPush 提供的 JPushMessageReceiver 类, 并如下新增一个 Intent-Filter -->
 <receiver
       android:name="Custom Receiver"
       android:enabled="true"
       android:exported="false" >
       <intent-filter>
            <action android:name="cn.jpush.android.intent.RECEIVER_MESSAGE" />
            <category android:name="您应用的包名" />
       </intent-filter>
 </receiver>

        
This code block is shown in the floating window

Manual integration method

The following package description and AndroidManifest example apply to JPush Android SDK v6.3.0 and later, whose offline package uses AAR files. For earlier versions, use the configuration in the corresponding integration package. JPush Android SDK v6.0.3 and later require Android 5.0 (API 21), so the application's minSdkVersion must be at least 21.

Manually integrated compressed package download link:Go to download

Starting from v6.3.0, the offline integration package contains the same SDK AAR published to Maven Central. The AAR includes SDK AndroidManifest components, res resources, and consumer ProGuard rules. Integrators only need to add the AAR and configure the AppKey.

Contents of jpush-android-6.x.x-release.zip

  • AndroidManifest.xml
    • Reference configuration containing only permissions, AppKey/Channel settings, and components developers must customize. SDK-owned components are already merged from the AAR.
  • libs/jpush-android-6.x.x.aar
    • JPush SDK package containing obfuscated classes, SDK AndroidManifest declarations, res resources, and consumer ProGuard rules.
  • res/
    • A copy of the resources in the AAR, provided only for reference when customizing notification styles such as jpush_notification_icon or rich media pages. Do not copy it when no customization is required.
  • example/
    • Complete Android example project. example/demo/libs/ also integrates the SDK as an AAR.
  • README.txt and ChangeLog.txt

The JCore core package is not included. Download jcore-android-x.x.x-release.zip separately; it contains jcore-android-x.x.x.aar. JPush v6.3.0 requires JCore v5.6.0 or later.

SDK File migration

  1. Unzip jpush-android-6.x.x-release.zip.
  2. Copy libs/jpush-android-6.x.x.aar to the project's libs/ directory.
  3. Copy jcore-android-x.x.x.aar from the JCore package to the project's libs/ directory.
  4. Add the AAR files under libs in the app module's build.gradle:
dependencies { ...... implementation fileTree(include: ['*.jar', '*.aar'], dir: 'libs') ...... }
          dependencies {
    ......
    implementation fileTree(include: ['*.jar', '*.aar'], dir: 'libs')
    ......
}

        
This code block is shown in the floating window

Note 1: The AAR already contains SDK resources, so do not copy res/ into the project. To customize the notification icon, add a resource with the same name, jpush_notification_icon, under the project's res/drawable-xxxx/; it overrides the default AAR resource. Keep the filename unchanged and use an icon without shadows or gradients.

Note 2: JCore native libraries are packaged in jcore-android-x.x.x.aar. Do not copy .so files manually or configure jniLibs.srcDirs.

Note 3: The AAR includes consumer ProGuard rules that AGP applies automatically. If the project has additional obfuscation constraints, see the "Obfuscation for JPush Android SDK" section on this page.

Configuration AndroidManifest.xml

Configure the application's AndroidManifest.xml based on the sample file included in the SDK package.

The main steps are:

  • Copy the permissions marked as "Required".
  • Configure the JPUSH_APPKEY and JPUSH_CHANNEL meta-data entries. Set JPUSH_APPKEY to the AppKey shown for the application created in the Portal, for example, 9fed5bcb7b9b87413678c407.
  • Declare a custom receiver that extends cn.jpush.android.service.JPushMessageReceiver to receive tag/alias results and push event callbacks.
  • Declare a custom service that extends cn.jpush.android.service.JCommonService and runs in the :pushcore process to help keep the push channel stable on more device platforms.

The following SDK components are automatically merged from the AAR's AndroidManifest.xml and must not be declared in the application's manifest: PushService, DataProvider, PushReceiver, PushActivity, PopWinActivity, AlarmReceiver, SchedulerReceiver, JNotifyActivity, JLocalNotifyActivity, JLocalNotifyReceiver, JTransitActivity, AsusPushMessageReceiver, and InitProvider.

To customize one of these components, such as moving PushService to another process, declare the same component in the application's manifest and override the required attributes with tools:replace or tools:node:

<manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools"> <application> <service android:name="cn.jpush.android.service.PushService" android:process=":mypush" tools:replace="android:process" /> </application> </manifest>
          <manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools">
    <application>
        <service
            android:name="cn.jpush.android.service.PushService"
            android:process=":mypush"
            tools:replace="android:process" />
    </application>
</manifest>

        
This code block is shown in the floating window

If you use Android Studio, define the application ID and manifest placeholders under the defaultConfig node in build.gradle:

defaultConfig { applicationId "cn.jpush.example" // Your application's package name ...... manifestPlaceholders = [ JPUSH_APPKEY : "Your AppKey", JPUSH_CHANNEL : "developer-default", ] }
          defaultConfig {
    applicationId "cn.jpush.example" // Your application's package name
    ......
    manifestPlaceholders = [
        JPUSH_APPKEY : "Your AppKey",
        JPUSH_CHANNEL : "developer-default",
    ]
}

        
This code block is shown in the floating window

Use ${applicationId} in AndroidManifest.xml to reference the package name defined by Gradle.

AndroidManifest example

<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" package="Your application's package name"> <!-- Required --> <permission android:name="${applicationId}.permission.JPUSH_MESSAGE" android:protectionLevel="signature" /> <uses-permission android:name="${applicationId}.permission.JPUSH_MESSAGE" /> <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <!-- Required to display notifications on Android 13 or later --> <uses-permission android:name="android.permission.POST_NOTIFICATIONS" /> <!-- Optional. Recommended to improve unique-user identification and delivery accuracy --> <uses-permission android:name="android.permission.READ_PHONE_STATE" /> <uses-permission android:name="android.permission.QUERY_ALL_PACKAGES" /> <uses-permission android:name="android.permission.GET_TASKS" /> <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> <!-- Optional. Recommended when using geofencing --> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" /> <!-- Optional. Recommended for the corresponding notification capabilities --> <uses-permission android:name="com.huawei.android.launcher.permission.CHANGE_BADGE" /><!-- Huawei badge --> <uses-permission android:name="com.vivo.notification.permission.BADGE_ICON" /><!-- vivo badge --> <uses-permission android:name="com.hihonor.android.launcher.permission.CHANGE_BADGE" /><!-- Honor badge --> <uses-permission android:name="com.oplus.notification.permission.BADGE_DIGITAL" /><!-- OPPO ColorOS 16+ numeric badge, since 6.3.0 --> <uses-permission android:name="android.permission.VIBRATE" /><!-- Vibration; required for Xiaomi Push --> <!-- Optional reserved permission --> <permission android:name="${applicationId}.permission.JOPERATE_MESSAGE" android:protectionLevel="signature" /> <uses-permission android:name="${applicationId}.permission.JOPERATE_MESSAGE" /> <application android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:name="Your Application Name"> <!-- Since JCore 2.0.0. The custom service must extend JCommonService. --> <service android:name="xx.xx.XService" android:enabled="true" android:exported="false" android:process=":pushcore"> <intent-filter> <action android:name="cn.jiguang.user.service.action" /> </intent-filter> </service> <!-- Required since 3.0.7. The custom receiver must extend JPushMessageReceiver. --> <receiver android:name="Your custom receiver" android:enabled="true" android:exported="false"> <intent-filter> <action android:name="cn.jpush.android.intent.RECEIVER_MESSAGE" /> <category android:name="${applicationId}" /> </intent-filter> </receiver> <!-- JPush core components are automatically merged from the AAR manifest. Do not declare them again. Use tools:replace or tools:node only when customization is required. --> <!-- Required. AppKey copied from the Portal --> <meta-data android:name="JPUSH_APPKEY" android:value="${JPUSH_APPKEY}" /> <!-- Required. Use the default value unless you need channel statistics --> <meta-data android:name="JPUSH_CHANNEL" android:value="${JPUSH_CHANNEL}" /> </application> </manifest>
          <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="Your application's package name">

    <!-- Required -->
    <permission
        android:name="${applicationId}.permission.JPUSH_MESSAGE"
        android:protectionLevel="signature" />
    <uses-permission android:name="${applicationId}.permission.JPUSH_MESSAGE" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <!-- Required to display notifications on Android 13 or later -->
    <uses-permission android:name="android.permission.POST_NOTIFICATIONS" />

    <!-- Optional. Recommended to improve unique-user identification and delivery accuracy -->
    <uses-permission android:name="android.permission.READ_PHONE_STATE" />
    <uses-permission android:name="android.permission.QUERY_ALL_PACKAGES" />
    <uses-permission android:name="android.permission.GET_TASKS" />
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />

    <!-- Optional. Recommended when using geofencing -->
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />

    <!-- Optional. Recommended for the corresponding notification capabilities -->
    <uses-permission android:name="com.huawei.android.launcher.permission.CHANGE_BADGE" /><!-- Huawei badge -->
    <uses-permission android:name="com.vivo.notification.permission.BADGE_ICON" /><!-- vivo badge -->
    <uses-permission android:name="com.hihonor.android.launcher.permission.CHANGE_BADGE" /><!-- Honor badge -->
    <uses-permission android:name="com.oplus.notification.permission.BADGE_DIGITAL" /><!-- OPPO ColorOS 16+ numeric badge, since 6.3.0 -->
    <uses-permission android:name="android.permission.VIBRATE" /><!-- Vibration; required for Xiaomi Push -->

    <!-- Optional reserved permission -->
    <permission android:name="${applicationId}.permission.JOPERATE_MESSAGE" android:protectionLevel="signature" />
    <uses-permission android:name="${applicationId}.permission.JOPERATE_MESSAGE" />

    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:name="Your Application Name">

        <!-- Since JCore 2.0.0. The custom service must extend JCommonService. -->
        <service
            android:name="xx.xx.XService"
            android:enabled="true"
            android:exported="false"
            android:process=":pushcore">
            <intent-filter>
                <action android:name="cn.jiguang.user.service.action" />
            </intent-filter>
        </service>

        <!-- Required since 3.0.7. The custom receiver must extend JPushMessageReceiver. -->
        <receiver
            android:name="Your custom receiver"
            android:enabled="true"
            android:exported="false">
            <intent-filter>
                <action android:name="cn.jpush.android.intent.RECEIVER_MESSAGE" />
                <category android:name="${applicationId}" />
            </intent-filter>
        </receiver>

        <!-- JPush core components are automatically merged from the AAR manifest.
             Do not declare them again. Use tools:replace or tools:node only when customization is required. -->

        <!-- Required. AppKey copied from the Portal -->
        <meta-data android:name="JPUSH_APPKEY" android:value="${JPUSH_APPKEY}" />
        <!-- Required. Use the default value unless you need channel statistics -->
        <meta-data android:name="JPUSH_CHANNEL" android:value="${JPUSH_CHANNEL}" />
    </application>
</manifest>

        
This code block is shown in the floating window

Technical support

When something goes wrong:

  • Please read carefully Android FAQ Document to see if anything is missing.
  • you can arriveJiguangCommunity search for similar questions
  • for us support Send email support@jiguang.cn

In order to solve the problem more quickly, please provide the following information when asking for help:

  • The product you need to consult is JPush, whether used simultaneouslyJiguangOther products
  • what are you calling API, the parameters passed, the complete error message, and the time point when the exception occurred.
  • If you cannot receive the message, provide the application's Appkey, news Message ID, of the device registration ID information
  • in the case of SDK Please provide corresponding questions SDK Version and complete log records, log information please use TXT File upload
  • The abnormal device is Android, list specific models and systems
Was this document helpful?

Copyright 2011-2026, jiguang.cn, All Rights Reserved. 粤ICP备12056275号-13 Shenzhen Hexun Huagu Information Technology Co., Ltd.

Open in Docs Center