Error during creation of signed apk - android

I am working in an app which is already in live.Now i have added new features in it.I am trying to create a signed apk after adding the new features but it shows error on the existing modules,But the existing modules work good in live While creating signed apk getting errors from old modules what is the reason for the errors and i Need to know how to create a signed apk for my modified project
E:\updated one\Wed Studio\app\src\main\AndroidManifest.xml:842: Error: The <activity> element must be a direct child of the <application> element [WrongManifestParent]
<activity
^
E:\updated one\Wed Studio\app\src\main\AndroidManifest.xml:845: Error: The <activity> element must be a direct child of the <application> element [WrongManifestParent]
<activity
^
Explanation for issues of type "WrongManifestParent":
The <uses-library> element should be defined as a direct child of the
<application> tag, not the <manifest> tag or an <activity> tag. Similarly,
a <uses-sdk> tag much be declared at the root level, and so on. This check
looks for incorrect declaration locations in the manifest, and complains if
an element is found in the wrong place.

Well, While asking a question in SOF you should be more specific. As per the communication over comments, in your project you don't have any compile time / run time error's in your project but still your unable to export a signed apk for your project.
This is a wired situation discussed here Android Export aborted This may be because of the lint errors in your project you can check in "Problems" view, or the "Lint Warnings" view.
If it is the case, To solve issue:
Project -> properties,
find Android Lint Preferences, in top to right click configure
workspace settings... -> unclick "Run full error check when exporting
app", apply done.
or
Window>Preferences>Android>Lint Error Checking
uncheck Run full error check when exporting app

Related

After cleaning gradle, androidx-test.core module throws merged-manifest errors

In a react-native project, ive recently updated to v66.4 from v63.2
after some dependency conflict troubleshooting, i ultimately get a merged manifest error, that indicates suggestions for 3 locations
initially this was 4 locations
i added android:exported="true" to the main projects manifest xml
now 1/4 issues resolved
3 remain, and theyre all the same issue
they indicate a problem with the manifest file for the test:core:1.3.0
ok, so i add the android:exported="true" flag to each of the activities in that manifest
i then build the debug apk, it compiles successfully, installs, and runs
but if i run ./gradlew clean and then try to build the apk again, it gives me the same error with the 3 activities from test:core:1.3.0
heres an example of the errors:
how can i resolve this permanently?
Head over to your AndroidManifest.xml file for the main flavour.
Go to the merged Manifest tab
And take a look at your merged manifest there and see what is causing problem. If I'm not mistaken you can override some of other manifests properties by specifying the correct one in main manifest since they have priority over those from 3rd party libraries.
Fot your case it's probably adding android:exported="true" for the activities that have intent filters specified inside them.

Specifying the element uses-sdk in AndroidManifest makes the manifest unparsable at runtime, when AAPT is used

I observe a real weird problem: I build .apk package using base tools as aapt, d8 and so on.
The manifest file has the following line:
<uses-sdk android:minSdkVersion="24" android:targetSdkVersion="32"/>
If I try to deploy the .apk , then the following problem reported by the packageinstaller:
2022-05-07 11:45:07.491 5998-5998/com.google.android.packageinstaller W/PackageInstaller: Parse error when parsing manifest. Discontinuing installation
And a user see the following message:
But if I remove the element "uses-sdk" from the manifest, then the app gets installed without a problem and works. But it looks like it considers a very low target number. What did I do wrong?
Note: the build procedure doesn't use Gradle, it uses 7Bee. I can provide github link to the app, if you are interested in.
When I looked in an addressing the issue, I found the following:
AAPT is discontinued
AAPT2 has to be used now
AAPT2 a gets version information as parameters of a run
AAPT2 produced result has to be signed using the apksigner SDK tool
APK has to be prepared by the ApkBuilderMain SDK tool
The ApkBuilderMain needs to be patched because not allows META-INF directory in APK content
After addressing all these items, APK got normally packaged and works.

manifest merger failed when the same library is imported in 2 feature modules

I am running into a build issue where gradle complains about "getMergedManifest failed manifest merger failed"
the error in the log shows lines like:
WARN - .tools.idea.model.ManifestInfo - getMergedManifest failed Manifest merger failed : Attribute provider#com.google.firebase.provider.FirebaseInitProvider#authorities value=(com.xxxxxxxxxx.feature_team.firebaseinitprovider) from AndroidManifest.xml:10:13-72
is also present at AndroidManifest.xml:36:559-633 value=(com.xxxxxxxxx.base.firebaseinitprovider).
Suggestion: add 'tools:replace="android:authorities"' to <provider> element at AndroidManifest.xml:8:9-12:39 to override.
What am i suppose to do here?
I don't have any authorities section in any of my manifest files.
The error arrives when in 2 feature modules the same shared library is imported which in result is depending on some google libs. I am sure that all versions of external libs are the same.
Anyone knows how to solve this?
------- edit. Still got errors ------.
......./base/src/main/AndroidManifest.xml:70:13-46 Error:
Attribute activity#com.facebook.LoginActivity#splitName value=(feature_match) from [:feature_match] AndroidManifest.xml:70:13-46
is also present at [:feature_topvoters] AndroidManifest.xml:73:13-50 value=(feature_topvoters).
Suggestion: add 'tools:replace="android:splitName"' to <activity>
element at AndroidManifest.xml:68:9-71:75 to override.
......./base/src/main/AndroidManifest.xml:74:13-46 Error:
Attribute activity#com.github.gorbin.asne.core.OAuthActivity#splitName value=(feature_match) from [:feature_match] AndroidManifest.xml:74:13-46
is also present at [:feature_topvoters] AndroidManifest.xml:77:13-50 value=(feature_topvoters).
Suggestion: add 'tools:replace="android:splitName"' to <activity> element at AndroidManifest.xml:72:9-75:80 to override.
So basically the issue appears when i try to add the same library in both 2 feature modules. What do i need to tell the manifest to prevent this merge conflict.
Both manifest files from the feature modules are empty. It must be the thirdparty manifest files causing the issue.
I thought the multiple feature/module structure would increase the architecture. But by now i really think it is way easier to have one big module. There are just too many issues in the whole gradle build model.
Ok after 10 hours of trying to find a solution i came up with the following:
I cloned the library causing the issue (Facebook).
Instead of compiling against maven i created a new library and put the complete source of the facebook SDK inside.
Inside the manifest.xml from that facebook SDK, there is an activity defined:
<activity
tools:replace="android:theme"
android:name="com.facebook.LoginActivity"
android:theme="#android:style/Theme.Translucent.NoTitleBar"
/>
I removed the activity from the manifest.xml and moved the activity definition into the main app manifest.xml
In this way the manifest merger will not try to merge two of the same activity definitions, but uses the one defined in the main app.
Works. But it is a shitty solution of course.
Not sure if this a bug in the build process. I have spend over 20 hours trying to fix this. Cannot find a way.
Multi module applications are not easy to construct.

Android studio - how to find which library is using dangerous permission?

I am trying to upload a apk to the google play store but its saying to my surprise that i am using the following permission:
Your APK is using permissions that require a privacy policy: (android.permission.RECORD_AUDIO).
so i searched the entire IDE for "android.permission.RECORD_AUDIO" but i cant find it. How can i find out which 3rd party is requesting this ? There should be a way to view in the manifest merger process all the manifest but when i hit shift twice and search manifest only the local manifest are showing up. The other is bit code and i cant view it.
In project build directory, there is a manifest merger report.
In my case, it is located under [ProjectRoot]/app/build/outputs/logs/manifest-merger-debug-report.txt
From this file, your can find where the permission is added. For example:
uses-permission#android.permission.RECORD_AUDIO
ADDED from /home/jack/AndroidProject/ApiDemos/app/src/main/AndroidManifest.xml:45:5-71
android:name
ADDED from /home/jack/AndroidProject/ApiDemos/app/src/main/AndroidManifest.xml:45:22-68
uses-permission#android.permission.CAMERA
ADDED from /home/jack/AndroidProject/ApiDemos/app/src/main/AndroidManifest.xml:49:5-65
android:name
ADDED from /home/jack/AndroidProject/ApiDemos/app/src/main/AndroidManifest.xml:49:22-62
You can use Merged Manifest[About] feature
Open AndroidManifest.xml -> Merged Manifest
If the library is open source you can check their source code for the permissions they have used.
They usually list the permission on their Read.me files.
Even if they are proprietary libs they will list the permissions they will be using otherwise their security is questionable.

Android studio debug-specific AndroidManifest.xml for ACCESS_MOCK_LOCATIONS

While importing project from Eclipse to Android Studio it has reported following error:
What may cause the problem? Any idea how to deal with this?
Regards
What may cause the problem?
Apparently, you have that <uses-permission> element in a manifest that would be used for a production app, and they now have a Lint rule to block that.
Any idea how to deal with this?
Create a src/debug/AndroidManifest.xml file, with a root <manifest> element holding onto your <uses-permission> element, and remove that <uses-permission> element from where you are getting the error (presumably src/main/AndroidManifest.xml).
This lint error currently does limit use of the permission to debug specific manifests in AndroidStudio 1.0.+ but the lint guidelines are being adjusted to allow the permission to also work in test specific manifests in an up coming version of AndroidStudio.

Categories

Resources