From 6198e9cc56b3d4d716164b7293d01e84e0c62368 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BD=99=E7=91=9E=E9=93=B6?= Date: Tue, 11 Jun 2019 00:50:49 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BF=81=E7=A7=BB=E5=88=B0AndroidX=EF=BC=8C?= =?UTF-8?q?=E5=90=8C=E6=97=B6=EF=BC=8Cdemo=E5=A2=9E=E5=8A=A0release?= =?UTF-8?q?=E6=89=93=E5=8C=85=E5=92=8C=E6=B7=B7=E6=B7=86=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 24 +++++++++ appbarlayoutbehavior/build.gradle | 18 +++---- .../ExampleInstrumentedTest.java | 4 +- .../AppBarLayoutBehavior.java | 4 +- build.gradle | 22 ++++----- gradle.properties | 2 + gradle/wrapper/gradle-wrapper.properties | 4 +- sample/android.keystore | Bin 0 -> 2237 bytes sample/build.gradle | 46 ++++++++++++++---- sample/proguard-rules.pro | 17 +++++++ .../sample/ExampleInstrumentedTest.java | 4 +- .../com/yuruiyin/sample/MainActivity.java | 10 ++-- .../com/yuruiyin/sample/MyListFragment.java | 10 ++-- .../adapter/CustomIndicatorAdapter.java | 2 +- .../sample/adapter/RecyclerViewAdapter.java | 4 +- .../sample/divider/ItemSmallDecoration.java | 4 +- sample/src/main/res/layout/activity_main.xml | 14 +++--- sample/src/main/res/layout/fragment_list.xml | 2 +- 18 files changed, 131 insertions(+), 60 deletions(-) create mode 100644 sample/android.keystore diff --git a/README.md b/README.md index 15653cb..26bf13a 100644 --- a/README.md +++ b/README.md @@ -39,5 +39,29 @@ dependencies { ``` + +### 混淆 +若使用support库,则需要保证support库中的代码不被混淆,请在proguard-rules.pro中添加如下配置: +```proguard +# 保留support下的所有类及内部类 +-keep class android.support.**{*;} +-dontwarn android.support.v4.** +# 保留继承support库的类 +-keep public class * extends android.support.v4.** +-keep public class * extends android.support.v7.** +-keep public class * extends android.support.annotation.** +``` + +若已迁移到androidx,则需要添加如下配置: +```proguard +-keep class com.google.android.material.** {*;} +-keep class androidx.** {*;} +-keep public class * extends androidx.** +-keep interface androidx.** {*;} +-dontwarn com.google.android.material.** +-dontnote com.google.android.material.** +-dontwarn androidx.** +``` + ## 参考 https://blog.csdn.net/vite_s/article/details/78901767 diff --git a/appbarlayoutbehavior/build.gradle b/appbarlayoutbehavior/build.gradle index 1d0a34c..a8aebb0 100644 --- a/appbarlayoutbehavior/build.gradle +++ b/appbarlayoutbehavior/build.gradle @@ -4,16 +4,16 @@ apply plugin: 'com.github.dcendents.android-maven' group='com.github.yuruiyin' android { - compileSdkVersion 27 + compileSdkVersion rootProject.ext.compileSdkVersion defaultConfig { - minSdkVersion 15 - targetSdkVersion 27 - buildToolsVersion '27.0.3' + minSdkVersion rootProject.ext.minSdkVersion + buildToolsVersion rootProject.ext.buildToolsVersion + targetSdkVersion rootProject.ext.targetSdkVersion versionCode 1 versionName "1.0" - testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } @@ -29,9 +29,9 @@ android { dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) - implementation 'com.android.support:appcompat-v7:27.1.1' - implementation 'com.android.support:design:27.1.1' + implementation 'androidx.appcompat:appcompat:1.0.2' + implementation 'com.google.android.material:material:1.0.0' testImplementation 'junit:junit:4.12' - androidTestImplementation 'com.android.support.test:runner:1.0.2' - androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' + androidTestImplementation 'androidx.test:runner:1.2.0' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' } diff --git a/appbarlayoutbehavior/src/androidTest/java/com/yuruiyin/appbarlayoutbehavior/ExampleInstrumentedTest.java b/appbarlayoutbehavior/src/androidTest/java/com/yuruiyin/appbarlayoutbehavior/ExampleInstrumentedTest.java index 9852f91..9512e02 100644 --- a/appbarlayoutbehavior/src/androidTest/java/com/yuruiyin/appbarlayoutbehavior/ExampleInstrumentedTest.java +++ b/appbarlayoutbehavior/src/androidTest/java/com/yuruiyin/appbarlayoutbehavior/ExampleInstrumentedTest.java @@ -1,8 +1,8 @@ package com.yuruiyin.appbarlayoutbehavior; import android.content.Context; -import android.support.test.InstrumentationRegistry; -import android.support.test.runner.AndroidJUnit4; +import androidx.test.InstrumentationRegistry; +import androidx.test.runner.AndroidJUnit4; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/appbarlayoutbehavior/src/main/java/com/yuruiyin/appbarlayoutbehavior/AppBarLayoutBehavior.java b/appbarlayoutbehavior/src/main/java/com/yuruiyin/appbarlayoutbehavior/AppBarLayoutBehavior.java index f7605a3..8316f04 100644 --- a/appbarlayoutbehavior/src/main/java/com/yuruiyin/appbarlayoutbehavior/AppBarLayoutBehavior.java +++ b/appbarlayoutbehavior/src/main/java/com/yuruiyin/appbarlayoutbehavior/AppBarLayoutBehavior.java @@ -1,8 +1,8 @@ package com.yuruiyin.appbarlayoutbehavior; import android.content.Context; -import android.support.design.widget.AppBarLayout; -import android.support.design.widget.CoordinatorLayout; +import com.google.android.material.appbar.AppBarLayout; +import androidx.coordinatorlayout.widget.CoordinatorLayout; import android.util.AttributeSet; import android.view.MotionEvent; import android.view.View; diff --git a/build.gradle b/build.gradle index 960a85d..28d34d1 100644 --- a/build.gradle +++ b/build.gradle @@ -7,7 +7,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:3.1.4' + classpath 'com.android.tools.build:gradle:3.4.1' classpath 'com.github.dcendents:android-maven-gradle-plugin:2.0' @@ -38,14 +38,14 @@ ext { androidSupportVersion = "28.0.0" } -subprojects { - project.configurations.all { - resolutionStrategy.eachDependency { details -> - if (details.requested.group == 'com.android.support' - && !details.requested.name.contains('multidex') ) { - details.useVersion androidSupportVersion - } - } - } -} +//subprojects { +// project.configurations.all { +// resolutionStrategy.eachDependency { details -> +// if (details.requested.group == 'com.android.support' +// && !details.requested.name.contains('multidex') ) { +// details.useVersion androidSupportVersion +// } +// } +// } +//} diff --git a/gradle.properties b/gradle.properties index 743d692..8de5058 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,6 +6,8 @@ # http://www.gradle.org/docs/current/userguide/build_environment.html # Specifies the JVM arguments used for the daemon process. # The setting is particularly useful for tweaking memory settings. +android.enableJetifier=true +android.useAndroidX=true org.gradle.jvmargs=-Xmx1536m # When configured, Gradle will run in incubating parallel mode. # This option should only be used with decoupled projects. More details, visit diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 38f3922..eda709a 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Fri Jul 13 17:23:18 CST 2018 +#Mon Jun 10 23:58:55 CST 2019 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip diff --git a/sample/android.keystore b/sample/android.keystore new file mode 100644 index 0000000000000000000000000000000000000000..6cc7d0b64057411986680745e5dfe245bc83244d GIT binary patch literal 2237 zcmcgt=|7YW7oK|-lWi#0R9FKJ|x5w9~y{{ z3?^Ll^zp@C^9v3=35|p zh1wmbe_4OysFokT<}`x(a~ghpOKor5s9807bxmKf;93Y_%1CQU0I&~r$v&YiScpHUXthj|R5mcCgZ+~Sx+7FQRZnI|yp!fx=1?%~PJvG{;v14mE^ z7Y`|gN&Ew&6U3F(_e6^NROLb;k=mlN zRcV#Y>H6P6Ciix!u;(WrK?#*^DEJAWAgJ@+4`$?dUCM7^L6GVBF1^6W^H z!c^7j2&)*|i2K>+k+>QuzZLMa>5Ts1JsWEij0~FW^m^m|BFmiCTFykyv*f4C2b^nG zWl+Ppsm0zqwxe~e3v6O3Ggmcv@^JLGK4oX@yb~*S68n`l-2#`$4L)UA*{V|3B0k&f zFE#e8uLvr?At)#uhJ zDE}a-*1s3oMWte`jdO%vL*pMi-ki9}v#{yygFC91Wku$$r10^co=<#+`?I(y9>TPR zXm?d8oExdIAXp=Z`RU&L=u92^Foe#&PYjWw_=i|w9lgQ2PI$U@aWBZ^$UC0-HygZ& z8l0JH@AKIQ8?5K@cCtpzKiq8Z^32(F&O1^Wx0>NOKQ!PXfIVvAQ@^qgJrKZnkp(s) zltxENq||iAMlKWfNVmV~8kzLBO_p`hQh(Zgog$b6iOyxZE@P9@ub5p@o|-(jYkRtGL*>$IZWibIar2m;*0VlwBlGZ0$ls+;D60=`22k) z5za~&5DS68E`dat7f6I!l)#_>6bjeh5MG7jFy)XRK{H(>`1|35{wpAV3sJto1Qj-r<#z@P8g?=2e~k6tj2qYxUw_8YyMy_bmI=)J)P=b8w*;{ ztJ=jho#-_px3!bHYW+~xCoElI{6x%+8V^(D;lHe{LvMx9clj?-F9f6yhtYxeHexnR zY#cwzgFD=vre#>B+Dr=Uxm*Gm^yKVv?#2?C;dP47{6&g>2&KI9_> zNEx{?UVIq2=ArU;zQ|j`?#*$6y;Uz;lI5Aww3kB!Z9lCb2bBvmx#jqK=hgMN;2jrw zves*}W3c(UyAS2h~P`f*#>o``P&sPEDv*V^7ZmX0t{7eQ zaT*i`K!7rFP!tq7oSz5^&Ijjl8+>zjfwGXRu1rC^t&cuJbukJ5r-_IAb7&#}Athx% z$|A&?{56r9Gxn;F#S?xixj zNpkkM{>QTB1ATVS-OZP$A#UO3T1qat48KZAhlq6ZC!0s@ieM?58(Zc@8nHr9@?=|LYP_;^+D4>Znp_SCvW;^x&Q&<T*d80g`F>6`QEwQf)t#`<#bHVI<~XIk`Za^?U+J3qc?f9wG>^eUe{)$ z-xMBOLiSQy$m(W}ig_p(b2Fk- - - - - + - + - - \ No newline at end of file + \ No newline at end of file diff --git a/sample/src/main/res/layout/fragment_list.xml b/sample/src/main/res/layout/fragment_list.xml index 1fd9f34..03c87de 100644 --- a/sample/src/main/res/layout/fragment_list.xml +++ b/sample/src/main/res/layout/fragment_list.xml @@ -1,5 +1,5 @@ -