具体错误
2021-11-01 20:03:17.567 14095-14095/com.serenegiant.usbcameratest E/AndroidRuntime: FATAL EXCEPTION: main Process: com.serenegiant.usbcameratest, PID: 14095 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.serenegiant.usbcameratest/com.serenegiant.usbcameratest.MainActivity}: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity. at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3483) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3655) at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85) at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135) at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2108) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:236) at android.app.ActivityThread.main(ActivityThread.java:7879) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:656) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:967) Caused by: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity. at androidx.appcompat.app.AppCompatDelegateImpl.createSubDecor(AppCompatDelegateImpl.java:696) at androidx.appcompat.app.AppCompatDelegateImpl.ensureSubDecor(AppCompatDelegateImpl.java:659) at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:552) at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:161) at com.serenegiant.usbcameratest.MainActivity.onCreate(MainActivity.java:63)
解决办法一
由继承自AppCompatActivity改为继承自Activity
解决办法二
第一步:在当前应用的build.gradle,添加红色加粗这两句:
dependencies {
compile 'com.android.support:design:25.0.0'
compile 'com.android.support.constraint:constraint-layout:1.0.0-beta5'
}
第二步:在对应的activity中添加红色加粗这一句:
<activity android:name="net.quantum6.MainActivity"
android:windowSoftInputMode="stateHidden|adjustPan"
android:theme="@style/AppThemeQuantum6"
android:screenOrientation="portrait"
>
第三步:在style.xml添加红色加粗这三句:
<style name="AppThemeQuantum6" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
</style>