-
Hello! First, I would love to express my appreciation for this library and its convenience. Without it, my app would have taken so much longer to make. Finding this library is the best thing that's happened to me since my kid was born! But then I stumbled upon an issue, built apps using my program conflict with other apps built using my program, since the authority for my file provider stays the same, even though the package is different. This is the part of my AndroidManifest that causes the conflict: <provider
android:authorities="my.catgame.fileProvider"
android:name="androidx.core.content.FileProvider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths" /> This is my code: public class Manifest
{
public static void change( File apk_file, String package_name, String app_name, String version, String version_code) throws IOException, ApkFormatException
{
ApkModule apk = ApkModule.loadApkFile(apk_file);
AndroidManifestBlock manifest = apk.getAndroidManifest();
manifest.setPackageName( package_name);
manifest.setApplicationLabel( app_name);
manifest.setVersionName( version);
manifest.setVersionCode( Integer.parseInt( version_code));;
apk.setManifest( manifest);
apk.writeApk( apk_file);
}
}
And the conflict is when you try to install the app(using adb shell running pm install), it says So I wandering (or wondering?), how do I edit that? My first thought was to convert the file to string, and then .replace('android:authorities="my.catgame.fileProvider"', 'android:authorities=" + package_name + ''.fileProvider"'), but trying that only gave me <manifest android:versionCode="97"
android:versionName="1.3.0"
android:installLocation="0"
android:compileSdkVersion="34"
android:compileSdkVersionCodename="14"
package="my.catgame"
platformBuildVersionCode="34"
platformBuildVersionName="14" xmlns:android="http://schemas.android.com/apk/res/android" /> Which doesn't include most stuff from the AndroidManifest UPDATE: I figured it out, but not really... This is my code: Iterator<ResXmlAttribute> attributes = manifest.recursiveAttributes();
ResXmlAttribute attribute = attributes.next();
while(attributes.hasNext())
{
if(attribute.getName().equals(AndroidManifest.NAME_authorities) && attribute.getValueAsString().equals("my.catgame.fileprovider"))
{
attribute.setValueAsString(package_name + ".fileprovider");
Log.d("Manifest", "Changed authorities to: " + package_name + ".fileprovider");
}
attribute = attributes.next();
} I'm just unsure how to write the updated attribute to the manifest |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Apparently, it updates automatically... |
Beta Was this translation helpful? Give feedback.
Apparently, it updates automatically...