我已经为我的应用构建了2个不同的APK文件,其中包含2个不同的包名com.xxx.digital
(生产版)和com.xxx.digital.staging
(暂存/测试版)
一旦我安装了2个APK中的一个,另一个的安装就失败了 怎么了?
build.gradle:
productFlavors {
staging {
applicationIdSuffix ".staging"
resValue "string", "app_name", "Staging"
}
production {
resValue "string", "app_name", "My App"
}
}
我尝试在同一台设备上安装com.xxx.digital.staging
时首先安装了com.xxx.digital
:
01-05 17:26:24.038 I/Timeline: Timeline: Activity_launch_request id:com.google.android.packageinstaller time:194533616
--------- beginning of system
01-05 17:26:24.041 I/ActivityManager: START u0 {dat=file:///data/user/0/io.crash.air/files/com.xxx.digital_350c86df94f9416190d72a69f606a36d.apk cmp=com.google.android.packageinstaller/com.android.packageinstaller.InstallAppProgress (has extras)} from uid 10043 on display 0
01-05 17:26:24.132 I/ActivityManager: Start proc 22726:com.android.defcontainer/u0a33 for service com.android.defcontainer/.DefaultContainerService
01-05 17:26:24.205 I/ActivityManager: Displayed com.google.android.packageinstaller/com.android.packageinstaller.InstallAppProgress: +144ms
01-05 17:26:24.212 E/NativeLibraryHelper: Failed to load assets verifier: 0
01-05 17:26:24.225 D/OpenGLRenderer: endAllActiveAnimators on 0x7f95f35400 (RippleDrawable) with handle 0x7f914aa4e0
01-05 17:26:24.232 I/Timeline: Timeline: Activity_idle id: android.os.BinderProxy@8f234c0 time:194533809
01-05 17:26:24.260 I/Finsky: [1] com.google.android.vending.verifier.PackageVerificationReceiver.onReceive(41): Verification requested, id = 34
01-05 17:26:24.337 W/SurfaceFlinger: couldn't log to binary event log: overflow.
01-05 17:26:24.392 I/Timeline: Timeline: Activity_windows_visible id: ActivityRecord{ca91c0e u0 com.google.android.packageinstaller/com.android.packageinstaller.InstallAppProgress t658} time:194533969
01-05 17:26:30.325 I/Finsky: [44062] com.google.android.finsky.services.ForegroundCoordinator.a(104): Task 7 requested foreground
01-05 17:26:30.328 I/Finsky: [44062] com.google.android.finsky.services.ForegroundCoordinator.a(116): Not entering foreground
01-05 17:26:31.977 I/Finsky: [1] com.google.android.vending.verifier.ar.a_(1793): Verification id=34 response=0
01-05 17:26:31.987 I/Finsky: [1] com.google.android.vending.verifier.ak.c(195): Verification complete: id=34, package_name=com.xxx.digital
01-05 17:26:31.988 I/Finsky: [1] com.google.android.vending.verifier.ak.g(17021): Verifying id=34, result=1
01-05 17:26:32.008 D/DefContainer: Copying /data/user/0/io.crash.air/files/com.xxx.digital_350c86df94f9416190d72a69f606a36d.apk to base.apk
01-05 17:26:32.607 E/NativeLibraryHelper: Failed to load assets verifier: 0
01-05 17:26:37.744 I/MSM-irqbalance: Decided to move IRQ215 from CPU3 to CPU2
01-05 17:26:37.944 I/art: Background sticky concurrent mark sweep GC freed 181035(9MB) AllocSpace objects, 29(4MB) LOS objects, 18% free, 56MB/69MB, paused 4.073ms total 129.503ms
01-05 17:26:38.023 E/NativeLibraryHelper: Failed to load assets verifier: 0
01-05 17:26:38.119 I/PackageManager.DexOptimizer: Running dexopt (dex2oat) on: /data/app/vmdl1217860958.tmp/base.apk pkg=com.xxx.digital isa=arm64 vmSafeMode=false debuggable=false oatDir = /data/app/vmdl1217860958.tmp/oat bootComplete=true
01-05 17:26:38.118 I/kworker/u16:0: type=1400 audit(0.0:140340): avc: denied { dac_override } for capability=1 scontext=u:r:kernel:s0 tcontext=u:r:kernel:s0 tclass=capability permissive=1
01-05 17:26:38.346 I/dex2oat: Starting dex2oat.
01-05 17:26:41.844 W/dex2oat: Before Android 4.1, method android.graphics.PorterDuffColorFilter android.support.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable
01-05 17:26:41.974 W/dex2oat: Before Android 4.1, method int android.support.v7.widget.ListViewCompat.lookForSelectablePosition(int, boolean) would have incorrectly overridden the package-private method in android.widget.ListView
01-05 17:26:42.736 I/MSM-irqbalance: Decided to move IRQ304 from CPU3 to CPU2
01-05 17:26:47.750 I/MSM-irqbalance: Decided to move IRQ224 from CPU3 to CPU2
01-05 17:26:47.809 I/dex2oat: Skipping compilation of void com.fasterxml.jackson.core.json.UTF8StreamJsonParser._skipString(): it contains a non natural loop
01-05 17:26:48.588 I/ActivityManager: Process com.google.android.googlequicksearchbox:search (pid 19656) has died
01-05 17:26:48.646 I/ActivityManager: Process eu.chainfire.supersu (pid 19185) has died
01-05 17:26:48.695 I/ActivityManager: Process com.instagram.android (pid 22053) has died
01-05 17:26:48.762 I/ActivityManager: Process android.process.acore (pid 20841) has died
01-05 17:26:50.121 W/dex2oat: Compilation of void com.google.android.youtube.player.internal.x.a(java.util.Map, java.lang.String) took 133.910ms
01-05 17:26:51.284 W/dex2oat: Compilation of void com.google.zxing.oned.EANManufacturerOrgSupport.initIfNeeded() took 102.399ms
01-05 17:26:51.380 I/dex2oat: Skipping compilation of boolean com.loopj.android.http.Base64$Encoder.process(byte[], int, int, boolean): it contains a non natural loop
01-05 17:26:51.980 W/dex2oat: No verified method for method calling String.<init>: void android.provider.SearchRecentSuggestions.<init>(android.content.Context, java.lang.String, int)
01-05 17:26:52.591 I/dex2oat: Skipping compilation of boolean cz.msebera.android.httpclient.extras.Base64$Encoder.process(byte[], int, int, boolean): it contains a non natural loop
01-05 17:26:52.736 I/MSM-irqbalance: Decided to move IRQ57 from CPU3 to CPU1
01-05 17:26:53.812 W/dex2oat: No verified method for method calling String.<init>: java.lang.String java.io.ByteArrayOutputStream.toString()
01-05 17:26:56.126 I/dex2oat: dex2oat took 17.849s (threads: 8) arena alloc=2MB java alloc=23MB native alloc=61MB free=4MB
01-05 17:26:56.259 E/installd: Couldn't opendir /data/data/com.xxx.digital: No such file or directory
01-05 17:26:56.282 W/PackageManager: Package couldn't be installed in /data/app/com.xxx.digital-1
com.android.server.pm.PackageManagerException: Can't install because provider name .db.MySuggestionProvider (in package com.xxx.digital) is already used by com.xxx.digital.staging
at com.android.server.pm.PackageManagerService.scanPackageDirtyLI(PackageManagerService.java:7094)
at com.android.server.pm.PackageManagerService.scanPackageLI(PackageManagerService.java:6769)
at com.android.server.pm.PackageManagerService.installNewPackageLI(PackageManagerService.java:12135)
at com.android.server.pm.PackageManagerService.installPackageLI(PackageManagerService.java:12916)
at com.android.server.pm.PackageManagerService.access$3300(PackageManagerService.java:297)
at com.android.server.pm.PackageManagerService$9.run(PackageManagerService.java:10496)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:234)
at android.os.HandlerThread.run(HandlerThread.java:61)
at com.android.server.ServiceThread.run(ServiceThread.java:46)
Manifest.xml:
<application>
<provider
android:name=".db.MySuggestionProvider"
android:authorities=".db.MySuggestionProvider"/>
</application>
MySuggestionProvider:
public class MySuggestionProvider extends SearchRecentSuggestionsProvider {
public final static String AUTHORITY = "MySuggestionProvider";
public final static int MODE = DATABASE_MODE_QUERIES;
public MySuggestionProvider() {
setupSuggestions(AUTHORITY, MODE);
}
}
答案 0 :(得分:2)
内容URI是用于标识提供商来源中的数据的URI: google.deveoper.com
您正尝试在内容提供商中使用相同的内容权限构建两个不同的APK。
我建议的解决方案是使用 BuildConfig.APPLICATION_ID 作为 AUTHORITY ,这将在所有各种风格中有所不同。
<强> MySuggestionProvider 强>
public class MySuggestionProvider extends SearchRecentSuggestionsProvider {
public final static String AUTHORITY =BuildConfig.APPLICATION_ID;
public final static int MODE = DATABASE_MODE_QUERIES;
public MySuggestionProvider() {
setupSuggestions(AUTHORITY, MODE);
}
}
答案 1 :(得分:1)
您似乎正在为应用程序使用不同的程序包名称,但内容提供程序仍具有相同的行李名称。那是不允许的。