我已经完成了我的第一个Xamarin Android移动应用程序。一切都很好。我只有一个无法解决的问题,我无法使用Google找到解决方案。
当我启动应用程序时,一切都很好,但是当我按Home -Home按钮,打开并关闭其他几个应用程序并回到应用程序崩溃时。另外,当我打开应用程序并关闭屏幕时,然后将其重新打开并回到应用程序时。
此外,所有这些都很好,而且没有崩溃。这次崩溃都在模拟器和物理设备上发生。
在模拟器上发生这种错误时,我遇到的错误是:
android.content.ActivityNotFoundException: Unable to find explicit activity class {com.name.appname/com.name.android.publish.OverlayActivity}; have you declared this activity in your AndroidManifest.xml?
如果可能的话,如何解决?
编辑:AndoirdManifest.xml文件看起来像这样:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.name.tournamentorganizer" android:installLocation="auto" android:versionName="1.1" android:versionCode="2">
<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="27" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application android:allowBackup="true" android:label="@string/app_name" android:icon="@drawable/icon11" android:name="android.app.Application" android:debuggable="true">
<activity android:label="Create new tournament" android:theme="@android:style/Theme.Material.Light" android:name="md57e31db4bba5ea713128b60ee6f3868c2.createNewTournament" />
<activity android:label="Tournament Organizer" android:theme="@android:style/Theme.Material.Light" android:name="md57e31db4bba5ea713128b60ee6f3868c2.MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:label="Add new players" android:theme="@android:style/Theme.Material.Light" android:name="md5a2089f5b800658a06dd2a11fca5a1f83.addNewPlayers" />
<activity android:label="addGoalScorer" android:theme="@android:style/Theme.Material.Light" android:name="md54d075dbf8b437fae408fa9e57e2203ba.addGoalScorer" />
<activity android:label="All fixtures and results" android:theme="@android:style/Theme.Material.Light" android:name="md54d075dbf8b437fae408fa9e57e2203ba.allFixturesAndResults" />
<activity android:label="Players database" android:theme="@android:style/Theme.Material.Light" android:name="md54d075dbf8b437fae408fa9e57e2203ba.allPlayersActivity" />
<activity android:label="knockout4Players" android:name="md54d075dbf8b437fae408fa9e57e2203ba.knockout4Players" />
<activity android:label="League" android:theme="@android:style/Theme.Material.Light" android:name="md54d075dbf8b437fae408fa9e57e2203ba.leagueType" />
<activity android:label="My tournaments" android:theme="@android:style/Theme.Material.Light" android:name="md54d075dbf8b437fae408fa9e57e2203ba.myTournaments" />
<activity android:label="About" android:theme="@android:style/Theme.Material.Light" android:name="md54d075dbf8b437fae408fa9e57e2203ba.settings" />
<activity android:label="Player Info" android:theme="@android:style/Theme.Material.Light" android:name="md54d075dbf8b437fae408fa9e57e2203ba.stats" />
<activity android:label="table" android:theme="@android:style/Theme.Material.Light" android:name="md54d075dbf8b437fae408fa9e57e2203ba.table" />
<activity android:label="Top scorers" android:theme="@android:style/Theme.Material.Light" android:name="md54d075dbf8b437fae408fa9e57e2203ba.topScorerActivity" />
<activity android:label="Winners" android:theme="@android:style/Theme.Material.Light" android:name="md54d075dbf8b437fae408fa9e57e2203ba.winnersActivity" />
<activity android:label="winnersAllTimeActivity" android:theme="@android:style/Theme.Material.Light" android:name="md54d075dbf8b437fae408fa9e57e2203ba.winnersAllTimeActivity" />
<provider android:name="mono.MonoRuntimeProvider" android:exported="false" android:initOrder="2147483647" android:authorities="com.name.tournamentorganizer.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.com.name.tournamentorganizer" />
</intent-filter>
</receiver>
<meta-data android:name="android.support.VERSION" android:value="25.4.0" />
</application>
</manifest>
edit2:
我有和没有广告的应用程序版本。没有广告的那个没有这个问题。一张广告确实有问题,因此广告以某种方式出现问题。我正在使用StartApp广告。
您可能不使用[Activity]
代码装饰
[Activity]
internal class YourActivity: Activity {}
如果您的所有活动都有
[Activity(Theme = "theme", Label = "name", MainLauncher = true)]
主流参数设置为true,您将遇到麻烦。
Xamarin使用活动注释来配置/生成AndroidManifest.xml
您是否加入了一个主题类别,也标有[应用程序]属性?看着你的清单,我惊讶地看到这条线
<application android:allowBackup="true" android:label="@string/app_name" android:icon="@drawable/icon11" android:name="android.app.Application" android:debuggable="true">
使用android:name =" android.app.application"。我希望看到MD5 Hash(即md5xxx.mainapplication-或您的应用程序类是什么名称(
更改应用程序类后可能需要进行干净和重建