一、版本配置

编译正常配置:
buildToolsVersion       : "27.1.1",
minSdkVersion           : 19,
classpath 'com.android.tools.build:gradle:3.3.2'
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip
classpath 'com.android.tools.build:gradle:4.2.2'
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip
"cn.jiguang.sdk:jpush:4.4.0",
"cn.jiguang.sdk:jcore:3.0.0-release",
/***********************编译异常配置:***************************/
"cn.jiguang.sdk:jpush:4.9.0",
"cn.jiguang.sdk:jcore:4.1.0",
异常报错:
AndroidManifest.xml:42: AAPT: error: unexpected element <queries> found in <manifest>.
华为配置HMS:
1.Hms升级到6.1.0.300集成失败报错 · BDS技术支持组
6.1.0.300(2021-09-13)
Android版本:com.huawei.hms:push:6.1.0.300
修改特性
预置<queries>元素,解决您的应用在Android11上无法正常访问HMS Core(APK)的问题。您的开发环境需要满足:Android Studio 3.6.1或更高版本、Android Gradle插件 3.5.4或更高版本。
解决方案
1.升级AndroidStudio到 3.6.1或更高版本、Gradle插件3.5.4或更高版本(建议)
2.降级hms SDK到com.huawei.hms:push:5.3.0.304
华为HMS配置版本说明:
1.文档中心
2. OPPO新版本有这个要求,1、单独OPPO使用低版本 2、同步升级andriodx。
二、android替换更新androidx配置
1.控件引用配置修改
android.support.v7.widget.NestedScrollView=androidx.core.widget.NestedScrollView
android.support.v7.widget.CardView=androidx.cardview.widget.CardView
android.support.constraint.ConstraintLayout=androidx.constraintlayout.widget.ConstraintLayout
<android.support.v4.view.ViewPager=<androidx.viewpager.widget.ViewPager
android.support.v4.view.ViewPager=androidx.viewpager.widget.ViewPager
android.support.v7.widget.RecyclerView=androidx.recyclerview.widget.RecyclerView
android.support.v7.widget.Toolbar=androidx.appcompat.widget.Toolbar
android.support.v7.widget.AppCompatTextView=androidx.appcompat.widget.AppCompatTextView
android.support.v7.widget.AppCompatImageView=androidx.appcompat.widget.AppCompatImageView
android.support.v4.view.PagerAdapter=androidx.viewpager.widget.PagerAdapter
android.support.annotation.NonNull=androidx.annotation.NonNull
android.arch.lifecycle.LifecycleOwner=androidx.lifecycle.LifecycleOwner
android.support.v4.app.NotificationCompat=androidx.core.app.NotificationCompat
android.support.v4.app.Fragment=androidx.fragment.app.Fragment
android.support.v4.app.ActivityCompat=androidx.core.app.ActivityCompat
android.support.v7.app.AlertDialog=androidx.appcompat.app.AlertDialog
android.support.annotation=androidx.annotation
android.support.v4.content.FileProvider=androidx.core.content.FileProvider
android.support.v4.content.ContextCompat=androidx.core.content.ContextCompat
android.support.v7.widget.GridLayoutManager=androidx.recyclerview.widget.GridLayoutManager
android.support.v4.widget.ViewDragHelper=androidx.customview.widget.ViewDragHelper
android.support.v4.util.SparseArrayCompat=androidx.collection.SparseArrayCompat
android.support.v7.app.AppCompatActivity=androidx.appcompat.app.AppCompatActivity
android.support.v4.app.NotificationManagerCompat=androidx.core.app.NotificationManagerCompat
android.support.v7.widget.DefaultItemAnimator=androidx.recyclerview.widget.DefaultItemAnimator
android.support.v7.widget.LinearLayoutManager=androidx.recyclerview.widget.LinearLayoutManager
android.support.v7.widget.StaggeredGridLayoutManager=androidx.recyclerview.widget.StaggeredGridLayoutManager
android.arch.lifecycle.Lifecycle=androidx.lifecycle.Lifecycle
android.support.v7.app.ActionBar=androidx.appcompat.app.ActionBar
android.support.v4.util.ArrayMap=androidx.collection.ArrayMap
android.support.v7.widget.LinearSnapHelper=androidx.recyclerview.widget.LinearSnapHelper
android.support.v7.widget.AppCompatEditText=androidx.appcompat.widget.AppCompatEditText
android.support.v4.view.NestedScrollingChild=androidx.core.view.NestedScrollingChild
android.support.v4.view.ViewCompat=androidx.core.view.ViewCompat
android.support.design.widget.TabLayout=com.google.android.material.tabs.TabLayout
android.support.design.widget.AppBarLayout=com.google.android.material.appbar.AppBarLayout
android.support.design.internal.BottomNavigationItemView=com.google.android.material.bottomnavigation.BottomNavigationItemView
android.support.design.internal.BottomNavigationMenuView=com.google.android.material.bottomnavigation.BottomNavigationMenuView
android.support.design.widget.BottomNavigationView=com.google.android.material.bottomnavigation.BottomNavigationView
android.support.design.widget.CoordinatorLayout=androidx.coordinatorlayout.widget.CoordinatorLayout
android.support.multidex.MultiDex=androidx.multidex.MultiDex
android.support.v4.view.MotionEventCompat=androidx.core.view.MotionEventCompat
android.support.v4.graphics.drawable.DrawableCompat=androidx.core.graphics.drawable.DrawableCompat
android.support.v4.content.LocalBroadcastManager=androidx.localbroadcastmanager.content.LocalBroadcastManager
android.support.v7.widget.OrientationHelper=androidx.recyclerview.widget.OrientationHelper
android.support.v7.widget.DividerItemDecoration=androidx.recyclerview.widget.DividerItemDecoration
android.support.v7.widget.LinearSmoothScroller=androidx.recyclerview.widget.LinearSmoothScroller
android.support.v4.app.DialogFragment=androidx.fragment.app.DialogFragment
android.support.design.widget.FloatingActionButton=com.google.android.material.floatingactionbutton.FloatingActionButton
android.support.design.widget.CollapsingToolbarLayout=com.google.android.material.appbar.CollapsingToolbarLayout
android.support.design.R.attr=com.google.android.material.R.attr
android.support.design.R.styleable=com.google.android.material.R.styleable
android.support.design.R.style=com.google.android.material.R.style
android.support.design.R.dimen=com.google.android.material.R.dimen
android.support.v4.widget.Space=androidx.legacy.widget.Space
android.support.v7.widget.SearchView=androidx.appcompat.widget.SearchView
android.support.v4.widget.SwipeRefreshLayout=androidx.swiperefreshlayout.widget.SwipeRefreshLayout
android.support.v4.app.FragmentActivity=androidx.fragment.app.FragmentActivity
android.support.v4.app.FragmentManager=androidx.fragment.app.FragmentManager
android.support.v4.app.FragmentStatePagerAdapter=androidx.fragment.app.FragmentStatePagerAdapter
android.support.v4.app.FragmentPagerAdapter=androidx.fragment.app.FragmentPagerAdapter
android.support.constraint.Guideline=androidx.constraintlayout.widget.Guideline
canvas.save(Canvas.ALL_SAVE_FLAG)=canvas.save()
android.support.v4.widget.NestedScrollView=androidx.core.widget.NestedScrollView
butterknifeSdkVersion   : "8.8.1", = butterknifeSdkVersion   : "10.0.0",
//proguard-rules.pro混淆部分
android.support.v7.widget=androidx.recyclerview.widget
#-ignorewarning                   # 忽略警告
2.引入配置修改:
1.build.gradle:classpath 'com.android.tools.build:gradle:3.3.2' = classpath 'com.android.tools.build:gradle:4.2.2'
2.gradle-wrapper.properties:distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip(原版本4.10.1-all.zip)
3.build.gradle:repositories--> http://developer.huawei.com/repo/=https://developer.huawei.com/repo/
4.File > Settings > 搜索 Gradle > 选择我们需要的版本 > Apply jdk改11 JDK:11 version
3.极光版本配置修改
build.gradle极光配置android版本:(极光文档)
//极光推送:jpush4.6.0,全部通过Intent跳转OpenClickActivity处理
"jpush"                        : "cn.jiguang.sdk:jpush:4.6.0",
"jcore"                        : "cn.jiguang.sdk:jcore:3.1.2",
//华为推送
"hms"                          : "com.huawei.hms:push:5.3.0.301",
"huawei"                       : "cn.jiguang.sdk.plugin:huawei:4.4.0",
"agconnect-core"               : "com.huawei.agconnect:agconnect-core:1.4.1.300",
//小米推送
"xiaomi"                       : "cn.jiguang.sdk.plugin:xiaomi:4.4.0",
//oppo推送
"oppo"                         : "cn.jiguang.sdk.plugin:oppo:4.4.0",
//vivo推送
"vivo"                         : "cn.jiguang.sdk.plugin:vivo:4.4.0",
build.gradle极光配置androidx版本:
//极光推送:jpush4.9.0,全部通过Intent跳转OpenClickActivity处理
"jpush"                        : "cn.jiguang.sdk:jpush:4.9.0",
"jcore"                        : "cn.jiguang.sdk:jcore:4.1.0",
//华为推送
"hms"                          : "com.huawei.hms:push:6.5.0.300",
"huawei"                       : "cn.jiguang.sdk.plugin:huawei:4.9.0",
"agconnect-core"               : "com.huawei.agconnect:agconnect-core:1.6.0.300",
//小米推送
"xiaomi"                       : "cn.jiguang.sdk.plugin:xiaomi:4.9.0",
//oppo推送
"oppo"                         : "cn.jiguang.sdk.plugin:oppo:4.9.0",
"oppo-commons"       : "commons-codec:commons-codec:1.6",
"oppo-annotation"     : "androidx.annotation:annotation:1.1.0",
implementation(name: 'com.heytap.msp_3.1.0', ext: 'aar')
//vivo推送
"vivo"                           : "cn.jiguang.sdk.plugin:vivo:4.9.0",
//荣耀
//"honor"                         : "cn.jiguang.sdk.plugin:honor:4.9.0",
特别注意:极光推送隐私协议配置
(1)在启动页initview中设置,一定要在隐私政策弹窗之前设置
//TODO 不同意隐私协议setAuth(context,false)同意隐私协议.setAuth(context,true)
JCollectionAuth.setAuth(mContext,false);
(2)隐私政策弹窗之后设置
/**
* @TODO 初始化极光推送sdk
*/
private void initJPushSDK() {
   //TODO 不同意隐私协议setAuth(context,false)同意隐私协议.setAuth(context,true)
   JCollectionAuth.setAuth(mContext,true);
   //初始化极光推送
   JPushInterface.setDebugMode(false); // 设置开启日志,发布时请关闭日志
   JPushUPSManager.registerToken(this, getResources().getString(R.string.lib_jpush_key), null, null, tokenResult -> {//需要java8 才支持的语法
   LogUtils.d("tokenresult=" + tokenResult.toString());//token就是regID
   });
   //TODO 极光SDK初始化完成之后再去清除Badge角标
   JPushInterface.setBadgeNumber(this,0);
}
4.android sdk config.gradle版本和华为等手机厂商配置
compileSdkVersion : 27,
buildToolsVersion : "27.1.1",
minSdkVersion : 19,
targetSdkVersion : 27,
compileSdkVersion : 28,
buildToolsVersion : "28.0.2",
minSdkVersion : 19,
targetSdkVersion : 28,
主项目build.gradle:
(1)安卓插件版本:
classpath 'com.android.tools.build:gradle:3.3.2' 
classpath 'com.android.tools.build:gradle:4.2.2'
(2)华为推送配置
华为官网配置:文档中心
/****************************************************************/
repositories:
//华为推送用的
mavenCentral()
maven { url 'http://developer.huawei.com/repo/' }
//华为推送用的(配置HMS Core SDKMaven仓地址)
mavenCentral()
maven { url 'https://developer.huawei.com/repo/' }
/****************************************************************/
buildscript > repositories:
classpath 'com.huawei.agconnect:agcp:1.4.1.300' 
classpath 'com.huawei.agconnect:agcp:1.6.0.300'
/****************************************************************/
allprojects > repositories:
//华为推送用的
mavenCentral()
maven { url 'http://developer.huawei.com/repo/' }
//华为推送用的(配置HMS Core SDKMaven仓地址)
mavenCentral()
maven { url 'https://developer.huawei.com/repo/' }
/****************************************************************/
(3)gradle-->gradle-wrapper.properties
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip 
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip
(4)gradle.properties添加
android.useAndroidX=true
android.enableJetifier=true
(5)GroupedRecyclerViewAdapter控件引用更新
"GroupedRecyclerViewAdapter" : "com.github.donkingliang:GroupedRecyclerViewAdapter:1.2.2",
"GroupedRecyclerViewAdapter" : "com.github.donkingliang:GroupedRecyclerViewAdapter:2.4.3",
(6)添加google控件比如tabLayout引用(再添加此配置)
implementation 'com.google.android.exoplayer:exoplayer:2.8.1'
implementation 'com.google.android.exoplayer:exoplayer-core:2.8.1'
(7)添加google控件BottomNavigationView
"BottomNavigationView" : "com.google.android.material:material:1.0.0",
文字显示配置
app:labelVisibilityMode="labeled"
三、配置过程中报错问题修改记录
1.文件修改
(1)attrs.xml <declare-styleable name="MyTextView"> <!--解决文字和数字换行不整齐-->注释掉<!--<attr name="lineSpacing" format="integer" />-->
lineSpacing
<attr name="lineSpacingExtra" format="integer" />
lineSpace = typedArray.getInteger(R.styleable.MyTextView_lineSpacing, 20);
lineSpace = typedArray.getInteger(R.styleable.MyTextView_lineSpacingExtra, 20);
(2)SlidingTabLayout > SlidingTabLayout()新增@SuppressLint("ResourceType")
2.首页banner广告图片加载异常IndexSaleAdvAdapter
"bumptech" : "com.github.bumptech.glide:glide:4.9.0",
在res文件夹下创建一个xml文件夹,然后创建一个network_security_config.xml文件,然后在AndroidManifest.xml中引用
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<base-config cleartextTrafficPermitted="true" />
</network-security-config>
<application
android:name=".App"
android:allowBackup="false"
android:icon="@mipmap/appicon"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/TranslucentTheme"
android:networkSecurityConfig="@xml/network_security_config"
tools:ignore="GoogleAppIndexingWarning"
3.升级butterknife版本到butterknifeSdkVersion   : "10.0.0",太低版本不兼容androidx注解
config.gradle > android = [
butterknifeSdkVersion : "10.0.0",
]
// butterknife注解框架
"butterknife" : "com.jakewharton:butterknife:${android["butterknifeSdkVersion"]}",
"butterknife-apt" : "com.jakewharton:butterknife-compiler:${android["butterknifeSdkVersion"]}",
注意:引用注意点
implementation rootProject.ext.dependencies["butterknife"]
//TODO 注意这个注解插件引用annotationProcessor不能改成implementation,否则@BindView控件报错 2022928 17:01:37 liangan
annotationProcessor rootProject.ext.dependencies["butterknife-apt"] 
4.微信分享工具
api 'com.tencent.mm.opensdk:wechat-sdk-android-without-mta:+'
api 'com.tencent.mm.opensdk:wechat-sdk-android-without-mta:5.4.0'
5.银盛宝、盛钱包、盛POS、钢刷保存小票图片兼容android sdk版本>28更新图库失败修复
TicketActivity > saveTicketImage方法修改,使用(config.gradle)
//保存图片同步图库更新
"utilcodex" : 'com.blankj:utilcodex:1.30.5',
    private void saveTicketImage() {
        showProgressDialog("正在保存中...");
        try {
            new Thread(new Runnable() {
                @Override
                public void run() {
                    Bitmap bitmap = getBitmapByView(scrollView);
                    //TODO 保存图片同步图库更新
                    File file = ImageUtils.save2Album(bitmap, Bitmap.CompressFormat.JPEG, 100, true);
                    if (file != null) {
                        showToast("保存成功");
                    } else {
                        showToast("保存失败");
                    }
                    dismissProgressDialog();
                }
            }).start();
        } catch (Exception e) {
            e.printStackTrace();
            showToast("保存失败");
            dismissProgressDialog();
        }
    }
5.离线推送配置混淆代码
#----------------------集成 JPush Android SDK 的混淆----------------------
-dontoptimize
-dontpreverify
-dontwarn cn.jpush.**
-keep class cn.jpush.** { *; }
-keep class * extends cn.jpush.android.service.JPushMessageReceiver { *; }
-dontwarn cn.jiguang.**
-keep class cn.jiguang.** { *; }
#2.0.5 ~ 2.1.7 版本有引入 gson protobuf,增加排除混淆的配置。(2.1.8 版本不需配置)
#==================gson &amp;&amp; protobuf==========================
-dontwarn com.google.**
-keep class com.google.gson.** {*;}
-keep class com.google.protobuf.** {*;}
-dontwarn com.xiaomi.push.**
-keep class com.xiaomi.push.** { *; }
6.OPPO aar文件配置
//config.gradle oppo推送、离线添加(name: 'com.heytap.msp_3.1.0', ext: 'aar')配置推送
"oppo" : "cn.jiguang.sdk.plugin:oppo:4.9.0",
"oppo-commons" : "commons-codec:commons-codec:1.6",
"oppo-annotation" : "androidx.annotation:annotation:1.1.0",
//TODO build.gradle oppo离线推送v4.9.0版本配置 begin
implementation rootProject.ext.dependencies["oppo"]
implementation rootProject.ext.dependencies["oppo-commons"]
implementation rootProject.ext.dependencies["oppo-annotation"]
implementation(name: 'com.heytap.msp_3.1.0', ext: 'aar')
//TODO oppo离线推送v4.9.0版本配置 end
libs目录下放aar
6.1百度定位功能最新配置
"baiduMapSDK-Location"         : "com.baidu.lbsyun:BaiduMapSDK_Location:9.2.9",
百度定位隐私权限设置:LocationClient.setAgreePrivacy(true);//同意百度隐私协议
同时抽出定位功能工具类:LoactionUtil (参考联拓宝整改版本)
7.極光推送解決自启问题配置
<!--        解决极光自启动问题         start-->
<receiver
android:name="cn.jpush.android.service.PushReceiver"
android:enabled="true"
android:exported="false"
tools:node="replace">
<intent-filter android:priority="1000">
<action android:name="cn.jpush.android.intent.NOTIFICATION_RECEIVED_PROXY" />
<category android:name="${applicationId}" />
</intent-filter>
</receiver>
<receiver
android:name="cn.jpush.android.service.AlarmReceiver"
tools:node="remove" />
<receiver
android:name="com.xiaomi.push.service.receivers.NetworkStatusReceiver"
android:exported="true"
tools:node="remove">
<intent-filter>
<action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</receiver>
<!--        解决极光自启动问题         end-->
7.極光推送官网api文档
极光文档

以上代码,待设置androidx后,异常报错引用,直接全部项目查询替换后面androidx路径即可。

android迁移androidx、极光推送(v4.9.0)配置相关推荐

  1. 极光推送 android 最新,Android——快速集成极光推送-Go语言中文社区

    集成极光推送 1,首先肯定是注册,添加应用 2,开始自动集成比手动集成简单第一步 在 build.gradle defaultConfig { multiDexEnabledtrue applicat ...

  2. .net平台借助第三方推送服务在推送Android消息(极光推送) 转

    分类: .net外部工具接口(3) .net知识精华(29) 版权声明:本文为博主原创文章,未经博主允许不得转载. 最近做的.net项目(Windows Service)需要向Android手机发送推 ...

  3. Android之集成极光推送消息

    极光推送是为 App 提供第三方推送服务的平台之一,它提供四种消息形式: 通知 自定义消息 富媒体 本地通知 1.通知 Push Notification,即指在手机的通知栏(状态栏)上会显示的一条通 ...

  4. Android之集成极光推送

    安卓端集成极光推送是很常见的,极光推送的简单高效性适合很多想要集成推送的APP,如果你要自己装逼,也可以自己写推送,只要想做都是可以的. 第一步.Gradle配置(Module的build.gradl ...

  5. Java中集成极光推送实现给Android提送消息通知(附代码下载)

    场景 Android中集成极光推送实现推送消息通知与根据别名指定推送附示例代码下载: https://blog.csdn.net/BADAO_LIUMANG_QIZHI/article/details ...

  6. android 使用极光推送实现单点登录

    本章将为大家讲解android如何使用极光推送实现单点登录功能 1.准备工作 去极光推送官网注册账号,创建运用.这里就不在讲解,不会的看我的上一篇博客:https://blog.csdn.net/k5 ...

  7. android极光推送成功率,记一次调用极光推送的惨痛经历

    我从事iOS开发有3年了,从第一年的时候开始用极光推送,每次使用极光推送的时候都觉得特别简单,因为按照极光推送的文档配置一遍,测试一下推送通知和自定义消息,然后设置别名(alias)以此标识不同的用户 ...

  8. 极光推送 请检查参数合法性_极光小课堂 | 极光推送在人脸识别终端管理系统中的应用...

    项目背景 最近开发的一款人脸识别终端管理系统,主要包括运营平台.企业后台管理系统.APP 端.智能人脸识别终端模块. 下图是系统的架构图: 其中各个模块之间都需要即时通讯,比如: APP 端用户注册完 ...

  9. vmei-day04-Jcenter方式集成极光推送

    今天主要写了一个小demo来集成极光推送的功能到项目 第一步,先看proj_gradle配置: buildscript {repositories {jcenter()}dependencies {c ...

最新文章

  1. [物理学与PDEs]第2章习题13 将 $p$ - 方程组化为守恒律形式的一阶拟线性对称双曲组...
  2. Scala学习笔记-5
  3. mysql mongodb 集群_MySQL与MongoDB
  4. python柱状图分析代码
  5. 工预-Typora(A)
  6. 一、后台首页index.php【dedecms后台源码分析】
  7. 什么是Docker?看这一篇文章就够了
  8. 10天确定Python,运行环境(超详细步骤)
  9. 已在页面完全加载前强制排版_公众号写作排版指南v2.0(适配Dark Mode)
  10. [序列化] SerializeHelper--序列化操作帮助类 (转载)
  11. python元组排序_python元组怎么排序
  12. 搭建mqtt服务器apollo
  13. 从零开发HarmonyOS(鸿蒙)运动手表小游戏——数字华容道
  14. Namenode处于安全模式时,对hadoop进行查看操作,edits_inprogress_txid中没有事物事件的增加,txid没有增加?
  15. php学好要多久,零基础php自学要多久
  16. 2019.3 计算机考试资料大放送
  17. Python中 {:.0f} 格式化输出,{0:^30}什么意思 . format(name))
  18. Linux驱动之等待队列
  19. SpringMVC控制器内请求转发关键字forward无效原因
  20. 冷门但实用的Word技巧

热门文章

  1. Java servlet视频教程,完整体系课程-动力节点
  2. 编译器O2优化下,分块矩阵乘法的TLB分析猜想
  3. Codeforces Round #668 (Div. 2)E. Fixed Point Removal
  4. 通达信交易dll接口协议
  5. NR 5G 无线协议架构
  6. 13 种文章投稿后状态,你的文章在哪个阶段?(转载)
  7. [UML] 流程图介绍 —— 程序员(灵魂画手)必备画图技能之一
  8. zookeeper安装步骤
  9. 黑客攻防技术宝典(十二)
  10. showModalDialog