Estimote / Xamarin-Bindings

Examples of how to bind Estimote SDKs to Xamarin
Apache License 2.0
17 stars 12 forks source link

Android.Indoor: No resource found (@style/AppTheme) #17

Open MatthewGerber opened 5 years ago

MatthewGerber commented 5 years ago

@heypiotr I just added the indoor location bindings for Android to my project, and when I recompiled I got an error pointing to an invalid AndroidManifest.xml file that had been added to the obj directory. Please see the attached screen shot:

screen shot 2019-01-03 at 2 14 48 pm

Do you have any ideas why this manifest is being added to the output? For example, was it accidentally included in the NuGet? Any other ideas?

MatthewGerber commented 5 years ago

@heypiotr Some additional information: There are other AndroidManifest.xml files in the obj directory. The difference is that these other files do not include the <application android:theme="@style/AppTheme"></application> element, which is present in the above screenshot. I suspect, then, that you just need to remove this element from the package's AndroidManifest.xml file. Can you try this?

MatthewGerber commented 5 years ago

@heypiotr I was able to resolve the issue above by declaring a theme named AppTheme in my style.xml so as to match the one shown in the manifest above, which is generated for the bindings package. My style.xml now looks like this:

<resources>
  <style name="SensusTheme" parent="SensusTheme.Base">
  </style>
  <style name="SensusTheme.Base" parent="Theme.AppCompat.NoActionBar">    
  </style>
  <style name="AppTheme" parent="Theme.AppCompat.NoActionBar">    
  </style>
</resources>

This seems to work, but I am still wondering whether you could prevent this theme from appearing in the manifest. I've seen other packages that do not include such a theme.

Now I am encountering a new issue: The Proximity and Indoor binding NuGet packages include duplicate libraries (e.g., kotlin-stdlib), and our project uses both NuGets. Compiling gives the following error:

/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(3,3): Error: java.lang.IllegalArgumentException: already added :  Lkotlin/ArrayIntrinsicsKt;

The error appears to result from duplicate Kotlin types being included. You can reproduce this error by adding the Estimote Proximity NuGet to the Example.Android.Indoor project.

Any thoughts on how we can proceed such that both Proximity and Indoor NuGets can be included? For example, can we pull out the common JARs into a separate NuGet that is referenced from both Proximity and Indoor bindings?

heypiotr commented 5 years ago

I think I recall running into the same problem when building these bindings. I can see I have the same "solution" in my example app:

https://github.com/Estimote/Xamarin-Bindings/blob/master/ExampleApps/Example.Android.Indoor/Resources/values/Styles.xml#L3

… that is, I went ahead and defined the @style/AppTheme that the compiler says is missing.

It was a few months ago, but I think I concluded that the native Android Indoor SDK for some reason depends on this value—most likely by mistake. (And we never found out about this, because Android Studio generates this value by default. Whereas Visual Studio does not.)

The proper solution here would be to remove this from the native Android Indoor SDK, I'll see if we can do that.

(For comparison, my Android Proximity bindings example doesn't even have the styles.xml file: https://github.com/Estimote/Xamarin-Bindings/tree/master/ExampleApps/Example.Android.Proximity/Resources/values)

MatthewGerber commented 5 years ago

@heypiotr That makes sense. Any thoughts on how we can support the inclusion of both Proximity and Indoor NuGets, per my other comments above? We do not intend to use them concurrently in the app at runtime, but we need to have the option to run one or the other.

MatthewGerber commented 5 years ago

@heypiotr I believe I've figured this out. I'll post here in a bit with a potential solution.