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 SDK的Maven仓地址)
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 SDK的Maven仓地址)
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" > 注释掉
改
lineSpacing
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控件报错 2022年9月28日 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 && 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 离线推送 v 4.9.0 版本配置 end
libs目录下放aar
6.1百度定位功能最新配置
"baiduMapSDK-Location" : "com.baidu.lbsyun:BaiduMapSDK_Location:9.2.9",
百度定位隐私权限设置: LocationClient . setAgreePrivacy ( true ); // 同意百度隐私协议
同时抽出定位功能工具类: LoactionUtil (参考联拓宝整改版本)
7.極光推送解決自启问题配置
android:name="cn.jpush.android.service.PushReceiver"
android:enabled="true"
android:exported="false"
tools:node="replace">
android:name="cn.jpush.android.service.AlarmReceiver"
tools:node="remove" />
android:name=" com.xiaomi.push.service.receivers.NetworkStatusReceiver"
android:exported="true"
tools:node="remove">
7.極光推送官网api文档
极光文档
以上代码,待设置androidx后,异常报错引用,直接全部项目查询替换后面androidx路径即可。