我在Azure上部署了一个虚拟机。我已经安装了Visual Studio 2015,Xamarin和其他移动开发工具。我在本地计算机上进行了相同的设置,以便从Visual Studio在我的设备上测试我的应用程序
唯一的区别是安装Android SDK。在我的本地机器上,我没有图像系统。
我在我的虚拟机上开发了一个应用程序。编译期间我没有错误。我使用Android.Support.Design,Android.Support.V4,Android.Support.V7.AppCompat,Android.Support.V7.RecyclerView(来自NuGet的最新版本)及其MvvmCross实现。
我想继续在我的本地计算机上开发应用程序。 NuGet包正确恢复。
当我构建应用程序时,我有一些错误:
Error Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light.DarkActionBar'. Novatech.Droid D:\Sources\Novatech\Novatech.Droid\Resources\values\styles.xml
Error Error retrieving parent for item: No resource found that matches the given name 'Base.Widget.AppCompat.Button'. Novatech.Droid D:\Sources\Novatech\Novatech.Droid\Resources\values\styles.xml
Error No resource found that matches the given name: attr 'buttonStyle'. Novatech.Droid D:\Sources\Novatech\Novatech.Droid\Resources\values\styles.xml
Error No resource found that matches the given name: attr 'colorAccent'. Novatech.Droid D:\Sources\Novatech\Novatech.Droid\Resources\values\styles.xml
Error No resource found that matches the given name: attr 'colorPrimary'. Novatech.Droid D:\Sources\Novatech\Novatech.Droid\Resources\values\styles.xml
Error No resource found that matches the given name: attr 'colorPrimaryDark'. Novatech.Droid D:\Sources\Novatech\Novatech.Droid\Resources\values\styles.xml
Error No resource found that matches the given name: attr 'windowActionBar'. Novatech.Droid D:\Sources\Novatech\Novatech.Droid\Resources\values\styles.xml
Error No resource found that matches the given name: attr 'windowNoTitle'. Novatech.Droid D:\Sources\Novatech\Novatech.Droid\Resources\values\styles.xml
Error No resource found that matches the given name: attr 'windowNoTitle'. Novatech.Droid D:\Sources\Novatech\Novatech.Droid\Resources\values\styles.xml
我试过了
target=android-19
将target=android-21
改为C:\Program Files (x86)\Android\android-sdk\extras\android\support\v7\appcompat\project.properties
有人可以向我解释一下这是什么问题吗?我放弃了相同的操作系统,相同的工具,相同的SDK,相同的JDK,
在虚拟机上使用不带Visual Studio的MSBuild时,我遇到了类似的问题。我正在尝试构建一个Xamarin Android项目。它一直在崩溃,消息'错误检索项目theme.appcompat.light.darkactionbar的父项。'我能够通过添加参数/ t:restore来解决它 - 例如
msbuild /t:SignAndroidPackage /t:restore /p:Configuration=Release <project path>
请注意我第一次使用restore参数运行它仍然失败,但是当我尝试再次构建它时它工作了。希望这会对某人有所帮助 - 我花了几个小时来正确配置MSBuild!
我从样式中引用的属性出现错误,因此将attrs.xml重命名为Attrs.xml(然后在干净重建后重新发生错误时再次返回)。
将项目从一个文件夹移动到另一个文件夹后,在完全相同的笔记本电脑上我遇到了同样的问题。我通过反复试验让它工作,但仍然不知道问题的原因。修复它涉及清洁解决方案几次并重新启动visual studio。
您的编译SDK版本必须与支持库的主要版本匹配。
由于您使用的是支持库v23,因此需要针对v23的Android SDK进行编译。
或者,您可以通过切换到最新的支持库v22继续针对Android SDK的v22进行编译。
按照给定的顺序尝试其中一个或全部:
它为我解决了这个问题
在我的情况下,“最低Android版本”API 21,但“目标Android版本”是“使用目标框架版本(API 23)”,但它没有提前工作,然后我将该版本指向API 21和突然间,它开始按预期工作。
后来我把最低Android版本的API 21和目标Android版本更改为“使用目标框架版本(API 23)”
我遇到了同样的问题,因为我在style.xml中使用了这些项目
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
但是在color.xml里面没有定义colorAccent
<resources>
<color name="primary">#2196F3</color>
<color name="primaryDark">#1976D2</color>
<color name="accent">#FFC107</color>
<color name="window_background">#F5F5F5</color>
<color name="splash_background">#3498DB</color>
通过添加简单解决
<color name="colorAccent">#3498db</color>
试试这个。
导航到C:\Program Files (x86)\Android\android-sdk\extras\android\support\v7\appcompat
。
打开project.properties
文件。
将目标android更改为target=android-21
。
我从Xamarin组件切换到NuGet包,现在可以使用了。 MvvmCross为其依赖项安装了最新版本的Nuget(23.3.0)软件包(MvvmCross.Droid.Support.V4,MvvmCross.Droid.Support.V7.AppCompat,MvvmCross.Droid.Support.V7.Preference ...)。和之前使用的组件。
我还必须从我的虚拟机复制“C:\ Users \ andres \ AppData \ Local \ Xamarin”文件夹。
在Visual Studio中,我没有关于组件可用更新的通知。
在我的情况下,我能够通过在android-layout-xml.xsd
菜单下添加schemas.android.com.apk.res.android.xsd
和XML -> Schemas
来解决这个问题(只有在axml文件中才能访问)。对于这些文件的确切位置,我建议在计算机上进行搜索,因为它们不在其他答案中建议的Xamarin文件夹中。在我的情况下,他们在obj文件夹下的项目[obj -> Debug -> Schemas ...
]
希望这可以帮助您解决问题。
在我的情况下,问题是我有一个本地Nuget包服务器。
花了一些时间才意识到Xamarin Studio正试图从错误的来源更新软件包。
在我的例子中,将Xamarin.Support版本与Target Framework版本匹配起作用。
例如:如果您的目标是25个API,那么您的支持库也应该是25.x ..