Gradle Task to get Android App Bundle Manifest - android

There are multiple manifests generated when we build an android project. Here is the screenshot of:
Build Directory of my application
Here if see, we can observe 3 directories, i.e.
bundle_manifest
instant_app_manifest
merged_manifests
Now I observed that when build Android App Bundle, it uses bundle_manifest. In the case of APK, it uses merged_manifests. I have a code that I am injecting in my manifest through a task in build. Gradle file. Now I can use manifestOutputDirectory to get manifest directory path(i.e. merged_manifests). But I am not able to find a similar Gradle task to locate Manifest present in bundle_manifest directory.
Can someone help me with how to get a path for bundle_manifest directory?

For example:
def manifestOutputDirectory = rootProject.getProjectDir().getAbsolutePath() +
"/${project.name}/build/intermediates/bundle_manifest/release/processReleaseManifest/bundle-manifest"
But "I have a code that I am injecting in my manifest through a task" sounds pretty strange to me.
The proper way to do it might rather be using manifest placeholders.

Very old, but for somebody coming here for an answer, using:
bundleManifestOutputDirectory
gave me the path to the bundle_manifest directory referred to by OP

Related

Unity android build - unable to merge manifest files

I am trying to create an android build from unity game. The build worked fine on Unity 5.5. Ever since I upgraded to 2017.2, the build fails and gives me error that its unable to merge android manifest files due to some conflict with a plugin manifest.
Following are the things I have tried
Deleting either of the manifest files and build
Deleting both the manifest files and build
Remove conflicting nodes in xml and build
Change value of conflicting nodes in xml to the same value
Every time I build, the files get written by conflicted values and it fails to build. Anyone good with unity android build, please suggest a solution.
It is most likely because the two android manifest files conflict with each other. For example, a few weeks ago I got the same error when my minimum android API was 22 for one file and 24 for the other. So I would suggest comparing the two files line by line and looking for conflicting pieces of information. This may not work but it's worth trying anyway.
Open all manifest files and check
“minSdkVersion” and “targetSdkVersion”
All manifest should have same values of these variables

Gradle Android library cant find resources of main project

I'm using gradle system to build an Android app.
I got some libraries that refer resources like #strings/app_name in their manifests. When trying to build gradle cant find that resources. Thats somehow understanable because I think the main resource file is generated at the end and dosent exist yet. But I can be sure that #strings/app_name will be there.
How to tell gradle that? Dont I basically just need to ignore that error?
Do you have the string in your resources?
Check at: res -> values -> strings.xml
Even if you are not using it, It should be there!

Unity3D Command line Build not accessing libraries and updating Android Manifest

I have a unity project with multiple android plugins.
The plugins are placed in the recommended folders /Assets/Plugins/Android/NameOfPlugin and each have their own AndroidManifest.xml and .project file.
I also have an AndroidManifest.xml in /Assets/Plugins/Android
When building out a .apk from any of the dev machines in studio, the AndroidManifest is correctly compiled into a single .xml file containing all required activities.
However, when building on a Mac Mini via commandline this does not happen. The AndroidManifest.xml is missing required code and the app doesn't work.
I have done fresh installs of everything, tried different configurations, loads of things but to no avail. Anyone have any ideas as to what might be going wrong?
One of Dan's colleagues here, and after doing a straight up text diff on the two "Editor.log" files of Unity's editor, there was one glaring line that was missing from the broken builder,
DisplayProgressbar: Android Library Support
Googling that lead me to http://answers.unity3d.com/questions/792979/android-library-support-build-issue.html who had already discovered the answer, which was damn near exactly the same as what we had suffered,
It appears having a "." in the name of a directory on the build path results in failure of the android-libraries to be correctly found and added to the StagingArea.
Moving our repository on the Autobuilder from ~/.jenkins/workspace/game_project to ~/game_project fixed the issue.
We've just done the same ourselves, and it's solved the issue.

Android Studio: “Execution failed for task ':app:mergeDebugResources'” if project is created on drive C:

I added Google Play services as a dependency in my current project.
If I save the project on the C: drive,
I get the following error while syncing up the project:
Error: Execution failed for task ':app:mergeDebugResources'.
> Error: Failed to run command:
C:\Program Files (x86)\Android\android-studio\sdk\build-tools\android-4.4.2\aapt.exe s -i C:\Users\ashokp\Desktop\Studio\AndroidV2SDK_AndroidStudioFormat\Google Play
Services\SampleApplication\AndroidV2SDKSampleApp_GooglePlayServices\app\build\exploded-aar\com.google.android.gms\play-services\4.3.23\res\drawable-hdpi\common_signin_btn_text_focus_light.9.png -o
C:\Users\ashokp\Desktop\Studio\AndroidV2SDK_AndroidStudioFormat\Google Play
Services\SampleApplication\AndroidV2SDKSampleApp_GooglePlayServices\app\build\res\all\debug\drawable-hdpi\common_signin_btn_text_focus_light.9.png
Error Code:
42
This only happens if the project is saved on the C: drive.
If I save it to some other drive, it works perfectly.
Does anyone else face this issue?
What causes this?
How can I fix/circumvent this?
This is caused by the path length restriction.
I think it's 256 characters maximum.
Relocate your project and the build will succeed.
I had the same problem. Try to go to Build - Rebuild project. I didn't get that problem again and my app successfully started.
For developers who live in Iran, Just rebuild while offline. You're done! (it's related to sanctions!)
I have a similar problem with Error:Execution failed for task ':app:mergeDebugResources. And at last I found the reason is the pictures resource error which use the incorrect ".9.png".
add this in module's build.gradle.
android{
aaptOptions.cruncherEnabled = false
aaptOptions.useNewCruncher = false
}
In drawable assets there was an image format which was an unsupported image. When i removed the image every thing started working fine.
In my case
I Followed This answer
Changed the location of project.
Tried another android device [Build and success install]
Tried on my android device [Build and success install * Uninstall any previous version of same app on device]
Edit-
Again it happend
I had this error message and lot of others like
x-version is deprecated and use y-version instead and it'll be removed in 2019
and all of my project started giving same error messages suddenly.
Android studio was giving warnings about my antivirus program. I tried configuring it but didn't work.
Finally I uninstalled QuickHeal antivirus from my system and all is well now
I was facing this issue after i updated to Android-Studio 3.6 the only way that worked for me was downgrading project build.gradle setting by changing
from
dependencies {
classpath 'com.android.tools.build:gradle:3.6.0'
}
to
dependencies {
classpath 'com.android.tools.build:gradle:3.3.0'
}
In my case, I created a folder audio in res directory. That caused the problem! Deleting the folder fixed it. Hope it might help someone.
I encountered the same error.
In the end, the problem was that I used an image in res/drawable that I copied in there and saved it as .png although the original file was .jpg .
I deleted the file (there's a warning message if there are still usages for the item in your code, but you can ignore it) and pasted it in with the original .jpg ending.
After a cleanup and gradle syncronization the error disappeared.
In Android Studio 1.4 with buildToolsVersion '22.0.1' the approach of fvasquezc23 worked for me with a restart and cache invalidation.
So, after you change the location of your project folder – copy/paste the folder onto disk D: (or somewhere else with no big ‘folder in folder’ structure), just
go to “File” -> “Invalidate Caches/Restart” (below “Synchronize”)
select first option “Invalidate and Restart”
Remove any capital letters or other not allowed symbols in resource file name.
Example: activity_parkingList --> activity_parking_list
Update your gradle build tools in project level gradle , and it will show you the exact resource that is causing the error.
Dont make name with capital letters . Always use lowercase for naming . This will work fine .
like companyLogo.png will raise error but company_logo.png will work fine.
If you are using ionic
in config.xml update widget tag with "xmlns:android="http://schemas.android.com/apk/res/android"
<widget id="io.ionic.starter" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:android="http://schemas.android.com/apk/res/android" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<widget/>
Adding the right repository in Project build.gradle solved the issue.
In my case Google Maven Repository was needed and was added as below in the build.gradle
repositories {
google()
}
refer to this link for declaring repositories:
https://docs.gradle.org/current/userguide/declaring_repositories.html
If you are working on PC of a company that uses a proxy you must turn on your VPN
when we add some new thing in out project, in that case some times resources might get duplicate that time it will give the error while run the app, in my case also get same issue I had face, while I had added the kotlin activity in java project, in it gives me error
Execution failed for task ':app:mergeDebugResources'.
...\themes.xml: Error: Duplicate resources
so in this case please check the local history and remove the duplicate resources from res folder, so simply revert that changes
I just found out that I had defined some color in colors.xml twice and after commenting one of them out, it solved the issue. and now i'm furious
I encountered this error and by process of elimination I discovered the problem to be a single apostrophe (') in a string resource. (Specifically, a string array item.) Replacing the apostrophe with the ' entity didn't work either. Escaping it with \' however, did work and my project built. I discovered the proper escape code through Android Studio's string resource editor. The build error message was completely unhelpful.
In my case, the problem was caused by having a button with an angle bracket inside android:text field:
<Button
...
android:text="<-"
/>
Changing it to android:text="back" fixed everything.
While having "<-" as a hardcoded text on a button isn't the best practice, it's a shame people have to spend so much time on finding solutions to these kind of issues without getting any informative hints from gradle on what is wrong.
I encountered this issue while working on a Flutter Application. I solved it by going to Tools > Flutter > Flutter Clean.
I my case, I had duplicated properties in the xml file. The 'android:layout_height' was in my layout tag and also in one of his child.
Check if all the files in the values folder are correct. In my case it was the strings.xml where I forgot to escape single quotes.
In my case this error was due to character in string.xml file.
from
<string name="machine_coords">MACHINE\nCOORD'S</string>
to
<string name="machine_coords">MACHINE\nCOORD"'"S</string>
In my case the problem was with the recent change in color XML i failed to insert '#' into the XML file. Please check ur recent changes that can be a cause for concern for this error.
This caused the problem for me: I put an ' character on my "strings.xml" file and it crashed everything.
After deleting that ' character it works...
You have " ' " symbol in your strings or arrays somewhere ... erase it !!!
I have LET'S DOI IT , after erasing " ' " and LET'S was LETS , problem disapered
I had rebased on master branch that had a new module addition.
and i had "offline mode" ON for gradle. turned it on and rebuilt the project.
it worked for me.
happy coding.
Cleaning the project worked for me, Build > clean project.

Multiple dex files define Lcom/amazon/ags/BuildConfig when using GameCircleSDK in Android Studio

I recently imported my Android project from Eclipse into AndroidStudio. Everything went fairly well, and I was able to resolve most issues, except when it came down to the GameCircleSDK library module. I kept getting the following error:
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Lcom/amazon/ags/BuildConfig;
As it turns out, the com.amazon.ags.BuildConfig.class was indeed contained in two jars: classes.jar (which got generated during the build) and GameCircleSDK/libs/gamecirclesdk.jar.
The only way I could solve the issue was to unzip the gamecirclesdk.jar, remove the BuildConfig.class, and zip it back up again. I searched the internets for a solution, and I tried just about everything listed here, but nothing seemed to resolve my situation. Am I missing something?
The problem is that GameCricleSDK.jar contains BuildConfig file with package name "com.amazon.ags" and the whole module is also generating BuildConfig file with the same package name as declared in Manifest. I changed the package name in module Manifest file and problem went away.
SOLUTION:
Take the GameCircleSDK library, open it's AndroidManifest.xml and change the packageName from "com.amazon.ags" to sth else no matter what. I changed it to "com.amazon.ags.lib".
I ran into the same problem using a different library project though(WeiboSDK). You may also need to change the applicationId in the library's build.gradle file to the same value in the library's AndroidManifest.xml.

Categories

Resources