When I build my AAB I am getting an error:
Android resource linking failed
/.../mobile/src/main/res/xml/network_security_config.xml:9: AAPT: error: resource raw/dev_cert (aka com.xxx.yyy:raw/dev_cert) not found.
I have a raw/dev_cert file. It shows up as:
I keep wondering if it's the .cer at the end but when I try to refactor it looks correct:
My network config references it:
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<domain-config cleartextTrafficPermitted="true">
<domain includeSubdomains="true">10.x.x.x</domain>
</domain-config>
<debug-overrides>
<trust-anchors>
<certificates src="@raw/dev_cert"/>
<certificates src="system"/>
<certificates src="user" />
</trust-anchors>
</debug-overrides>
</network-security-config>
I saw this post, but it did not seem to be the same issue.
UPDATE
when I generate a signed bundle in debug it works, but not in release. I don't think I need it in release, which is why it's debug-overrides
, I think. I read this documentation and it seems like I have the right configuration. I don't know why it's being included on a release build.
The file itself is in:
/Users/xxx/Projects/xxxxx/xxx/mobile/src/debug/res/raw
The error is referencing
AAPT: error: resource raw/dev_cert (aka com.xxx.xxx:raw/dev_cert) not found.
And building debug is working, so why is the release build using the debug-overrides
statement in the network-security-config
?
YET ANOTHER UPDATE
The error specifically is:
/Users/xxx/Projects/xxx/xxx/mobile/src/main/res/xml/network_security_config.xml:9: AAPT: error: resource raw/dev_cert (aka com.xxx.xxx:raw/dev_cert) not found.
but dev_cert
is in /Users/xxx/Projects/xxxxx/xxx/mobile/src/debug/res/raw
as mentioned before.
I was hoping it would not even run this when build/signing the release because it is within the <debug-overrides>
tags of the network_security_config.xml
This post seems to have a different problem, where the network_security_config file is in the res/raw folder vs the debug/res/raw folder.
This specific part of the android documentation references configuring CAs for debugging, which is what I am doing, and this section mentions,
android:debuggable is "false", then this section is completely ignored.
Which makes me wonder how I check that. It's possible debuggable is not "false" during my release build and therefore it is not ignoring the section and also not finding the file because of that.
I explicitly set debuggable to false. I don't know why it's calling the section. Here is the error:
> Task :mobile:bundleReleaseResources FAILED
AGPBI: {"kind":"error","text":"Android resource linking failed","sources":[{"file":"/Users/zzzz/Projects/xxxx/yyyy/mobile/src/main/res/xml/network_security_config.xml","position":{"startLine":8}}],"original":"/Users/zzzz/Projects/xxxx/yyyy/mobile/src/main/res/xml/network_security_config.xml:9: AAPT: error: resource raw/dev_cert (aka com.xxxx.yyyy:raw/dev_cert) not found.\n ","tool":"AAPT"}
FAILURE: Build completed with 2 failures.
1: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':mobile:processReleaseResources'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> Android resource linking failed
/Users/zzzz/Projects/xxxx/yyyy/mobile/src/main/res/xml/network_security_config.xml:9: AAPT: error: resource raw/dev_cert (aka com.xxxx.yyyy:raw/dev_cert) not found.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
==============================================================================
2: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':mobile:bundleReleaseResources'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> Android resource linking failed
/Users/zzzz/Projects/xxxx/yyyy/mobile/src/main/res/xml/network_security_config.xml:9: AAPT: error: resource raw/dev_cert (aka com.xxxx.yyyy:raw/dev_cert) not found.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
==============================================================================
* Get more help at https://help.gradle.org
BUILD FAILED in 2s
67 actionable tasks: 2 executed, 65 up-to-date