Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add android:networkSecurityConfig support to ApplicationAttribute #1224

Closed
alexsorokoletov opened this issue Jan 23, 2018 · 6 comments · Fixed by #1338
Closed

Add android:networkSecurityConfig support to ApplicationAttribute #1224

alexsorokoletov opened this issue Jan 23, 2018 · 6 comments · Fixed by #1338
Labels
Area: App+Library Build Issues when building Library projects or Application projects. enhancement Proposed change to current functionality.

Comments

@alexsorokoletov
Copy link

alexsorokoletov commented Jan 23, 2018

Steps to Reproduce

  1. Add [Application] attribute and try specifying networkSecurityConfig as a property
  2. Compilation fails

Expected Behavior

Should allow user to specify url/path to the networkSecurityConfig

Actual Behavior

Xamarin.Android does not support specifying this attribute in manifest through property.

Version Information

Latest master https://github.com/xamarin/xamarin-android/blob/master/src/Xamarin.Android.NamingCustomAttributes/Android.App/ApplicationAttribute.cs

Log File

N/A

Other

This attribute was included in API 24
https://developer.android.com/guide/topics/manifest/application-element.html#networkSecurityConfig

Looks like it is not yet available via C# surface

@jonpryor jonpryor added the Area: Bindings Issues in Java Library Binding projects. label Jan 24, 2018
@atsushieno atsushieno added enhancement Proposed change to current functionality. Area: xamarin-android Build Issues building the xamarin-android repo *itself*. and removed Area: Bindings Issues in Java Library Binding projects. labels Jan 26, 2018
@atsushieno
Copy link
Contributor

For future reference, there is nothing related to bindings. It is about MSBuild.

@atsushieno atsushieno added Area: App+Library Build Issues when building Library projects or Application projects. and removed Area: xamarin-android Build Issues building the xamarin-android repo *itself*. labels Feb 26, 2018
atsushieno added a commit to atsushieno/xamarin-android that referenced this issue Feb 26, 2018
This should fix dotnet#1224.

Those attributes were based on build-tools/manifest-attribute-codegen.exe
(which is not really codegen yet, but lists up all the manifest attributes
that are found from Android SDK resources).

However not all the attributes were documented. For those undocumented
attributes, the issue dotnet#1336
was created to track.
atsushieno added a commit to atsushieno/xamarin-android that referenced this issue Feb 27, 2018
This should fix dotnet#1224.

Those attributes were based on build-tools/manifest-attribute-codegen.exe
(which is not really codegen yet, but lists up all the manifest attributes
that are found from Android SDK resources).

However not all the attributes were documented. For those undocumented
attributes, the issue dotnet#1336
was created to track.
jonpryor pushed a commit that referenced this issue Feb 27, 2018
…#1338)

Fixes: #1224

Adds support for the `AndroidManifest.xml` element
`<uses-configuration/>` via `Android.App.UsesConfigurationAttribute`:

	partial class UsesConfigurationAttribute {
	  public bool     ReqFiveWayNav       { get; set; }
	  public bool     ReqHardKeyboard     { get; set; }
	  public string   ReqKeyboardType     { get; set; }
	  public string   ReqNavigation       { get; set; }
	  public string   ReqTouchScreen      { get; set; }
	}

Updates many existing custom attributes to add support for new
`AndroidManifest.xml` element attributes, including:

  * `Android.App.ActivityAttribute.ColorMode`
  * `Android.App.ActivityAttribute.MaxAspectRatio`
  * `Android.App.ActivityAttribute.ShowForAllUsers`
  * `Android.App.ApplicationAttribute.BackupInForeground`
  * `Android.App.ApplicationAttribute.FullBackupOnly`
  * `Android.App.ApplicationAttribute.NetworkSecurityConfig`
  * `Android.App.ApplicationAttribute.UsesCleartextTraffic`
  * `Android.App.InstrumentationAttribute.TargetProcesses`
  * `Android.App.UsesFeatureAttribute.Version`

Added attributes were found via
`build-tools/manifest-attribute-codegen.exe` (which is not really
codegen yet, but lists up all the manifest attributes that are found
from Android SDK resources).

However, not all the attributes which were found were documented.
Undocumented attributes are being tracked at:

	#1336
@nologinatgit
Copy link

I really need this attribute. When will it be publicly available?

@deyupopp
Copy link

Is there any documentation regarding how to use the attribute? I can see it's publicly available, but when I add it with [Application(NetworkSecurityConfig = "@xml/network_security_config")], the project does not build anymore (error is The "GenerateJavaStubs" task failed unexpectedly).
The network_security_config.xml file is under Resources/xml.

@deyupopp
Copy link

@jonpryor Can you please have a look on my previous comment?

@StevenBonePgh
Copy link

Similar concerns in this issue #2176. There is no apparent workaround to achieve desired results.

@netojoa
Copy link

netojoa commented Feb 17, 2020

For future reference. If you are working on an Android app, make sure after you add the network_security_config.xml file, you configure the Build Action to AndroidResource in the Property panel. This actually fixed the build error "resource xml/network_security_config (aka com.companyname.ut.sample:xml/network_security_config) not found. UT.Sample" for me.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Area: App+Library Build Issues when building Library projects or Application projects. enhancement Proposed change to current functionality.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants