小编Dou*_*ert的帖子

如何修复:"你需要在这个活动中使用Theme.AppCompat主题(或后代)"

根据视频说明,我无法在全屏模式下运行Android应用.当它试图运行时,应用程序崩溃并出现错误.

"You need to use a Theme.AppCompat theme (or descendant) with this activity

清单文件

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.djsg38.hikerswatch">

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">
    <activity android:name=".MainActivity"
        android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>

</manifest>
Run Code Online (Sandbox Code Playgroud)

样式文件

<resources>

<!-- Base application theme. -->
<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>
</style>
Run Code Online (Sandbox Code Playgroud)

可能有用的部分MainActivity

public class MainActivity extends AppCompatActivity {
Run Code Online (Sandbox Code Playgroud)

android android-appcompat appcompatactivity

29
推荐指数
4
解决办法
8万
查看次数

段故障-收到信号,SIGABORT

因此,我的代码可以很好地编译,但是每当我尝试运行该程序时,它就会出现段错误。我通过gdb运行它并得到了这组错误:

terminate called after throwing an instance of 'std::logic_error'
   what():  basic_string::_S_construct null not valid

Program received signal SIGABRT, Aborted.
0x00007ffff722bcc9 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
56  ../nptl/sysdeps/unix/sysv/linux/raise.c: No such file or directory.
Run Code Online (Sandbox Code Playgroud)

这是我的代码,如果有帮助的话:

using namespace std;
#include <iostream>
#include <vector>
#include <cmath>
#include<fstream>
#include <cstdlib>
#include <utility>
#include <string>

class Page
{
  public:
    int TimeStamp;
    int ProgramOwner;
    int LocalPageNumber;

};

//Pair: first entry is local page, second entry is global page
//Second entry: 1 if in main memory, 0 if …
Run Code Online (Sandbox Code Playgroud)

c++ gdb abort segmentation-fault

-2
推荐指数
1
解决办法
1万
查看次数