我已经为 android 项目创建了风格。以下是我在 gradle 文件中实现的更改。
android {
compileSdkVersion 28
buildToolsVersion '28.0.3'
defaultConfig {
applicationId "com.collegemobile.free.free"
minSdkVersion 19
targetSdkVersion 28
versionCode 5
versionName "2.1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
renderscriptTargetApi 23
renderscriptSupportModeEnabled true
}
configurations.all {
resolutionStrategy.force 'com.google.code.findbugs:jsr305:1.3.9'
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
flavorDimensions"default"
productFlavors{
paid{
buildConfigField("String","paid","paid")
applicationId 'com.collegemobile.paid.paid'
dimension "default"
}
free{
buildConfigField("String", "free", "free")
applicationId 'com.collegemobile.free.free'
dimension "default"
}
}
它工作正常,但现在它显示内容提供商的问题。我在 Manifest.xml 文件中做了以下更改。在 android:authorities="${applicationId} 我添加了 $ applicationid.
<provider
android:name="android.support.v4.content.FileProvider"
android:authorities="${applicationId}.fileprovider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths" />
</provider>
<provider
android:name=".models.DataProvider"
android:authorities="${applicationId}"
android:exported="false"
android:syncable="true"></provider>
但它给了我以下例外。
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.collegemobile.paid.paid, PID: 29652
java.lang.RuntimeException: Unable to create application com.collegemobile.free.free: java.lang.SecurityException: Permission Denial: opening provider com.collegemobile.free.free.DataProvider from ProcessRecord{25cd8f9 29652:com.collegemobile.paid.paid.bbfg/u0a106} (pid=29652, uid=10106) that is not exported from UID 10103
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5876)
at android.app.ActivityThread.access$1100(ActivityThread.java:199)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1650)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Caused by: java.lang.SecurityException: Permission Denial: opening provider com.collegemobile.itracks.bbfg.models.DataProvider from ProcessRecord{25cd8f9 29652:com.collegemobile.massmutual.bbfg/u0a106} (pid=29652, uid=10106) that is not exported from UID 10103
at android.os.Parcel.createException(Parcel.java:1942)
at android.os.Parcel.readException(Parcel.java:1910)
at android.os.Parcel.readException(Parcel.java:1860)
at android.app.IActivityManager$Stub$Proxy.getContentProvider(IActivityManager.java:4181)
at android.app.ActivityThread.acquireProvider(ActivityThread.java:5970)
at android.app.ContextImpl$ApplicationContentResolver.acquireUnstableProvider(ContextImpl.java:2592)
at android.content.ContentResolver.acquireUnstableProvider(ContentResolver.java:1828)
at android.content.ContentResolver.query(ContentResolver.java:786)
at android.content.ContentResolver.query(ContentResolver.java:752)
at android.content.ContentResolver.query(ContentResolver.java:710)
at com.collegemobile.itracks.bbfg.BBFG.initOfflineMsgQueue(BBFG.java:342)
at com.collegemobile.itracks.bbfg.BBFG.onCreate(BBFG.java:332)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1154)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5871)
at android.app.ActivityThread.access$1100(ActivityThread.java:199)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1650)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Caused by: android.os.RemoteException: Remote stack trace:
at com.android.server.am.ActivityManagerService.getContentProviderImpl(ActivityManagerService.java:12188)
at com.android.server.am.ActivityManagerService.getContentProvider(ActivityManagerService.java:12585)
at android.app.IActivityManager$Stub.onTransact(IActivityManager.java:357)
at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:3291)
at android.os.Binder.execTransact(Binder.java:731)