4
其他需要注意的事项
如果您在清单文件AndroidManifest.xml中,有那种以包名开头命名的那种。因为如果包名都改了,有些也需要动态的改变。可以用${applicationId}代替。在打包的时候,会自动替换成当前包名。
比如,类似下配置:
android:name="com.xxx.xx.permission.JPUSH_MESSAGE"
android:protectionLevel="signature"/>
android:name=".push.MyJPushMessageReceiver"
android:enabled="true"
android:exported="false">
android:name="android.support.v4.content.FileProvider"
android:authorities="com.xxx.xx.provider"
android:exported="false"
tools:replace="android:authorities"
android:grantUriPermissions="true">
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths"/>
可改为:
android:name="${applicationId}.permission.JPUSH_MESSAGE"
android:protectionLevel="signature"/>
android:name=".push.MyJPushMessageReceiver"
android:enabled="true"
android:exported="false">
android:name="android.support.v4.content.FileProvider"
android:authorities="${applicationId}.provider"
android:exported="false"
tools:replace="android:authorities"
android:grantUriPermissions="true">
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths"/>
当然值得注意的是,在代码中我们也不能把包名写死了,可通过BuildConfig得到当前包名
5
我的完整配置,供参考
有关隐私信息的都用xxx替换了
1. 项目根目录的build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
build {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0'
classpath "io.github.prototypez:save-state:0.1.7"
// NOTE:Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
maven { url "https://jitpack.io"}
maven { url 'http://oss.jfrog.org/artifactory/oss-snapshot-local/'}
flatDir {
dirs 'libs'
}
}
}
task clean( type: Delete) {
delet