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

installreferrer bindings #556

Merged
merged 73 commits into from
Aug 15, 2022
Merged

installreferrer bindings #556

merged 73 commits into from
Aug 15, 2022

Conversation

moljac
Copy link
Member

@moljac moljac commented May 18, 2022

Does this change any of the generated binding API's?

Yes - new bindings.

extracted from: #468

Describe your contribution

  • bound
    • com.android.installreferrer:installreferrer - -> 1.0

@moljac moljac requested a review from jpobst May 19, 2022 07:05
config.json Outdated Show resolved Hide resolved
@moljac
Copy link
Member Author

moljac commented May 24, 2022

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

config.json Outdated
"artifactId": "installreferrer",
"version": "1.0",
"nugetVersion": "1.0.0",
"nugetId": "Xamarin.Google.Android.Installreferrer",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Capitalization: InstallReferrer

@@ -0,0 +1,27 @@
<metadata>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With #555 committed, this file should be deleted, and replaced with the following lines in Directory.Build.props:

<AndroidNamespaceReplacement Include='com.android.' Replacement='Xamarin.Android' />

com.google.android.finsky.externalreferrer -> Xamarin.Google.Android.Finsky.ExternalReferrer - This one is a little more difficult because our other libraries do not append Xamarin before Google for the `com.google.android' namespace. For example:

  • Google.Android.Material.Animation

If we want to use Xamarin.Google.Android, we will need to add:

<AndroidNamespaceReplacement Include='com.google.android.' Replacement='Xamarin.Google.Android' />

It will need to be added before this existing line so that it is run first:

<AndroidNamespaceReplacement Include='com.google.' Replacement='Google' />

I can support it either way:

  • Google.Android.Finsky.ExternalReferrer to be consistent with Material
  • Xamarin.Google.Android.Finsky.ExternalReferrer because we really should have Xamarin in our namespaces so it doesn't conflict with anyone else's packages

🤷

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Am I not allowed to change namespaces "old way" (with metadata)?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general, the new way is less work. It would require no work in most new cases. This particular one requires 2 lines the way as opposed to 4 lines the old way.

The new way also runs faster in generator, making builds faster.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now, just for changing namespaces we have 2 ways of doing it

  1. XPath/XML
  2. MSBuild

In a spirit of "growth mindset" let us further grow number of options to fix namespaces with:

  1. Roslyn analyzers
  2. Source generators

Just to make bindings more approachable for users and technology acceptance. Bindings are trivial and everybody does it just for fun and users are thrilled with alternatives. The more options the better and users will benefit by being forced to learn, just they don't know that. Options never raise questions and express freedom and inclusiveness.

Pro argument for MsBuild approach I recently heard: "new (MSBuild )way is centrally managed".

We have central metadata files in both AX and GPS-FB-MLKit which could be used for central management of namespaces.

Now, performance. I accept that MsBuild approach might be faster than XPath, but we have other problems, like hundreds if not thousands of matched no node which slow down builds, etc etc.

For the record:

dotnet/java-interop#727 (comment)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As you said here: xamarin/GooglePlayServicesComponents#636 (comment):

Options do not hurt.

😉

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A little bit if the PR is not approved for using "other way" or "old way".




Apache License
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This library does not appear to be licensed under Apache 2.0: https://maven.google.com/web/index.html?q=g#com.android.installreferrer:installreferrer:2.2

It appears to be licensed under the Android Software Development Kit License. I suspect that this license does not allow us to redistribute the .aar file, and we will need to use Xamarin.Build.Download for this package:

Except to the extent required by applicable third party licenses, you may not copy (except for backup purposes), modify, adapt, redistribute, decompile, reverse engineer, disassemble, or create derivative works of the SDK or any part of the SDK.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

version 1.0 is under Apache.

They changed it in version 1.1.

Let us bind and release version 1.0, so Facebook components are unblocked.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ran over this issue (license varying across versions) during cgmanifest.json generation. I came up with some sort of solution, but writing tons of if-then-else will be nearly manual job, which is also not desireable.

@@ -0,0 +1,15 @@
**Xamarin is not responsible for, nor does it grant any licenses to, third-party packages. Some packages may require or install dependencies which are governed by additional licenses.**

Note: This component depends on [com.android.installreferrer:installrefererrer](https://maven.google.com/web/index.html?q=installreferrer#com.android.installreferrer:installreferrer), which is subject to the [Apache 2.0](https://developer.android.com/google/play/installreferrer/)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

!Apache 2.0

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

templates/installreferrer/Project.cshtml Outdated Show resolved Hide resolved
<Authors>Microsoft</Authors>
<Owners>Microsoft</Owners>
<Copyright>© Microsoft Corporation. All rights reserved.</Copyright>
<PackageProjectUrl>https://go.microsoft.com/fwlink/?linkid=2091414</PackageProjectUrl>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed

</ItemGroup>

<ItemGroup>
<None Include="..\..\templates\auto-value\License.md" Pack="true" PackagePath="License.md" />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

!auto-value

utilities.cake Outdated
@@ -214,6 +214,7 @@ Task ("spell-check")
"J2Objc",
"CheckerFramework",
"CheckerQual",
"Installreferrer",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Capitalization: InstallReferrer.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@moljac
Copy link
Member Author

moljac commented Jul 22, 2022

This PR needs to only contain changes related to InstallReferrer bindings. Currently, this seems to include changes from many other open PRs. (155 files changed.)

well not anymore - 16

@moljac
Copy link
Member Author

moljac commented Jul 22, 2022

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@moljac
Copy link
Member Author

moljac commented Jul 23, 2022

samples build error ACW generation (note net6 only):

obj/Release/net6.0-android/android/src/mono/com/android/installreferrer/api/InstallReferrerStateListenerImplementor.java(8,34): javac error JAVAC0000:  error: package com.android.installreferrer.api does not exist [./samples/dotnet/BuildAllDotNet/BuildAllDotNet.csproj]
obj/Release/net6.0-android/android/src/mono/com/android/installreferrer/api/InstallReferrerStateListenerImplementor.java(8,34): javac error JAVAC0000: 		com.android.installreferrer.api.InstallReferrerStateListener [./samples/dotnet/BuildAllDotNet/BuildAllDotNet.csproj]
obj/Release/net6.0-android/android/src/mono/com/android/installreferrer/api/InstallReferrerStateListenerImplementor.java(8,34): javac error JAVAC0000:  [./samples/dotnet/BuildAllDotNet/BuildAllDotNet.csproj]
 ll ./generated/com.android.installreferrer.installreferrer/obj/Debug/monoandroid12.0/generated/src

api.xml

    <interface abstract="true" deprecated="not deprecated" final="false" name="InstallReferrerStateListener" static="false" visibility="public" jni-signature="Lcom/android/installreferrer/api/InstallReferrerStateListener;">
      <method abstract="true" deprecated="not deprecated" final="false" name="onInstallReferrerServiceDisconnected" jni-signature="()V" bridge="false" native="false" return="void" jni-return="V" static="false" synchronized="false" synthetic="false" visibility="public" />
      <method abstract="true" deprecated="not deprecated" final="false" name="onInstallReferrerSetupFinished" jni-signature="(I)V" bridge="false" native="false" return="void" jni-return="V" static="false" synchronized="false" synthetic="false" visibility="public">
        <parameter name="p0" type="int" jni-type="I" />
      </method>
    </interface>

MCWs:

total 224
drwxr-xr-x  13  wheel    416 Jul 23 09:35 .
drwxr-xr-x   7  wheel    224 Jul 23 09:35 ..
-rw-r--r--   1  wheel   3865 Jul 23 09:35 Java.Interop.__TypeRegistrations.cs
-rw-r--r--   1  wheel   8680 Jul 23 09:35 Xamarin.Android.InstallReferrer.Api.IInstallReferrerStateListener.cs
-rw-r--r--   1  wheel  24503 Jul 23 09:35 Xamarin.Android.InstallReferrer.Api.InstallReferrerClient.cs
-rw-r--r--   1  wheel   6764 Jul 23 09:35 Xamarin.Android.InstallReferrer.Api.ReferrerDetails.cs
-rw-r--r--   1  wheel   3835 Jul 23 09:35 Xamarin.Android.InstallReferrer.BuildConfig.cs
-rw-r--r--   1  wheel   4488 Jul 23 09:35 Xamarin.Android.InstallReferrer.Commons.InstallReferrerCommons.cs
-rw-r--r--   1  wheel  17783 Jul 23 09:35 Xamarin.Google.Android.Finsky.ExternalReferrer.IGetInstallReferrerService.cs
-rw-r--r--   1  wheel   1489 Jul 23 09:35 Xamarin.Google.Android.InstallReferrer.projitems
-rw-r--r--   1  wheel   1840 Jul 23 09:35 __NamespaceMapping__.cs
-rw-r--r--   1  wheel      0 Jul 23 09:35 enumlist
-rw-r--r--   1  wheel  22208 Jul 23 09:34 generator.rsp

Binlog:

samples-dotnet-dotnet-msbuild-BuildAllDotNet.binlog.zip

@moljac
Copy link
Member Author

moljac commented Jul 23, 2022

proguard rules do not help:

-dontshrink
-dontoptimize
-dontpreverify

-keep class com.android.installreferrer.api.** { *; }
-keep interface com.android.installreferrer.api.** { *; }

If it's failing on javac, then proguard rules won't help, that is later on.

XamarinDotNetWorkloadSource: https://aka.ms/dotnet/maui/rc.3.json
XamarinDotNetWorkloadSource: https://aka.ms/dotnet/maui/6.0.400.json
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to use the local file below? But can you update .NET & workloads in a separate PR? Just to make sure that doesn't break anything on its own.

workloads.json Outdated Show resolved Hide resolved
@moljac moljac merged commit de330c5 into main Aug 15, 2022
@moljac moljac deleted the mu-20220518-installreferrer branch August 15, 2022 14:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants