【问题标题】:Xamarin No resource found that matches the given name (at 'theme' with value '@style/DesignTheme'). App1.DroidXamarin 找不到与给定名称匹配的资源(在“主题”处,值为“@style/DesignTheme”)。 App1.Droid
【发布时间】:2023-03-03 18:43:01
【问题描述】:

我是 Xamarin 的新手。所以我开始了一个共享项目。然后我谷歌一些链接来添加材料设计并做了以下。

  1. 我创建了 styles.xml。(我不明白为什么在 Visual Studio 中看不到资源/值文件夹,但是当我手动进入目录时,我可以看到所以我在那里手动创建了以下内容。

    <?xml version="1.0" encoding="UTF-8" ? >
    <resources>
        <style name="DesignTheme" parent="Theme.AppCompat.Light.DarkActionBar">
            <item name="windowNoTitle" >true </item >
            <item name="windowActionBar" >false </item >
            <item name="colorPrimary" >@color/primary </item >
            <item name="colorPrimaryDark" >@color/primary_dark </item >
            <item name="colorAccent" >@color/accent </item > 
        </style >
    </resources >
    
  2. 接下来我将清单更改如下。我添加了这个 android:theme="@style/DesignTheme"

    <?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android">
        <uses-sdk android:minSdkVersion="15" />
        <application android:label="App1.Droid" android:theme="@style/DesignTheme"></application>
    </manifest>
    
  3. 我刚刚尝试构建并收到此错误未找到与给定名称匹配的资源(在“主题”处,值为“@style/DesignTheme”)。但清单现在显示了这一点。为什么与第 2 步不同?

    <?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="App1.Droid">
        <!--suppress UsesMinSdkAttributes-->
        <uses-sdk android:minSdkVersion="15" />
        <uses-permission android:name="android.permission.INTERNET" />
        <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
        <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
        <application android:label="App1.Droid" android:theme="@style/DesignTheme" android:name="android.app.Application" android:allowBackup="true" android:icon="@drawable/icon" android:debuggable="true">
            <activity android:configChanges="orientation|screenSize" android:icon="@drawable/icon" android:label="App1" android:name="md50170a25da682dd459b9251c65ebe3a7a.MainActivity">
                <intent-filter>
                    <action android:name="android.intent.action.MAIN" />
                    <category android:name="android.intent.category.LAUNCHER" />
                </intent-filter>
            </activity>
            <provider android:name="mono.MonoRuntimeProvider" android:exported="false" android:initOrder="2147483647" android:authorities="App1.Droid.mono.MonoRuntimeProvider.__mono_init__" />
            <!--suppress ExportedReceiver-->
            <receiver android:name="mono.android.Seppuku">
                <intent-filter>
                    <action android:name="mono.android.intent.action.SEPPUKU" />
                    <category android:name="mono.android.intent.category.SEPPUKU.App1.Droid" />
                </intent-filter>
            </receiver>
        </application>
    </manifest>
    

完整的错误是。

找不到与给定名称匹配的资源(在“主题”处,值为“@style/DesignTheme”)。 App1.Droid C:\Users\ns\Documents\Visual Studio 2015\Projects\App1\App1\App1.Droid\obj\Debug\android\manifest\AndroidManifest.xml

Under the Nuget Package Manager I can see the installed list shows this Xamarin.Android.Support.Design is installed for version v24.2.1

【问题讨论】:

  • 我按编辑时进行了相应的格式化,我可以看到我的代码吗?对编辑有帮助吗?
  • 你能添加来自styles.xml的完整代码吗?此外,如果 VS 中未显示该文件夹,则需要在解决方案资源管理器上方单击“显示所有文件”以显示项目中未包含的项目。如果出现,请右键单击并选择“包含在项目中”。
  • 我已经添加了完整的代码,但它似乎没有出现。是的 vs 文件夹没有完整显示。现在它没有出现在任何地方?
  • 我别无选择,只能在这里显示styles.xml
  • 我尝试了很多次编辑它只是没有出现我的所有代码?

标签: android xamarin xamarin.forms


【解决方案1】:

MainActivity,在

[Activity(Label = "appName", ScreenOrientation = Android.Content.PM.ScreenOrientation.Portrait, MainLauncher = true)]

删除它们。

【讨论】:

    猜你喜欢
    • 2013-11-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-02-10
    • 2014-01-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多