Open zhangfeifeilz opened 6 years ago
TBuildConfig tBuildConfig = appVariantContext.getAtlasExtension().getTBuildConfig();
File packageIdFile = tBuildConfig.getPackageIdFile();
File apPackageIdFile = appVariantContext.apContext.getPackageIdFile();
boolean isAutoPackageId = tBuildConfig.isAutoPackageId();
int minPackageId = tBuildConfig.getMinPackageId();
Map<String, String> autoConfigMap = new HashMap<String, String>();
if (null != apPackageIdFile && apPackageIdFile.exists()) {
autoConfigMap.putAll(loadPackageIdProperties(apPackageIdFile));
} else if (null != packageIdFile && packageIdFile.exists()) {
autoConfigMap.putAll(loadPackageIdProperties(packageIdFile));
}
AtlasDependencyTree atlasDependencyTree = AtlasBuildContext.androidDependencyTrees.get(getVariantName());
for (AwbBundle awbBundle : atlasDependencyTree.getAwbBundles()) {
String key = awbBundle.getResolvedCoordinates().getGroupId() + ":" + awbBundle.getResolvedCoordinates().getArtifactId();
if (autoConfigMap.containsKey(key)) {
continue;
}
File customPackageIDFile = new File(awbBundle.getAndroidLibrary().getFolder(), "customPackageID.txt");
String packageId = getCustomPackageId(customPackageIDFile);
if (StringUtils.isNotEmpty(packageId)) {
autoConfigMap.put(key, packageId);
} else {
autoConfigMap.put(key, "");
}
}
我前几天也遇到了 这是PreparePackageIdsTask的代码 好像需要host 中tBuildConfig.packageIdFile指向packageIdFile.properties文件 或者在bundle的customPackageID.txt中指定packageId.
不进行自动分配packageId,调整资源段 app中的build.gradle中配置如下: atlas { atlasEnabled true tBuildConfig { classInject false autoPackageId false mergeAwbJavaRes true useCustomAapt true autoStartBundles = ['com.test.advertbundle'] preLaunch = 'com.test.atlas.AppPreLaunch' } manifestOptions { replaceApplication true } }
在业务的bundle的根目录添加packageIdFile.properties文件,其中配置如下: groupId:artifactId=70 不同的业务bundle是不同的 打包编译时报错: Error:Execution failed for task ':app:prepareDebugpackageIds'.
groupId=主包名 artifactId=bundle名 Error:Execution failed for task ':app:processResAwbsDebug'.