Ich verwende Material Design (Floating Action Button) in meinem Projekt. also importiere ich android.support.design.widget.FloatingActionButton
und verwende android.support.v7
für die Verwendung von ToolBar und AppCompat Theme in den niedrigsten API-Ebenen.mit android.support.design Bibliothek für die niedrigste API-Ebene in Android
endlich wie ich meins in API 17+ laufen, läuft es komplett. aber für niedrigere zeigt es HAS STOPPED Fehler, und LogCat sagt, dass Theme/AppCompat
muss für App-Thema ausgewählt werden. das ist mein style.xml:
<style name="AppTheme" parent="Theme.AppCompat.Light">
<item name="android:actionBarStyle">@style/TB_Back_color</item>
<item name="android:alertDialogStyle">@style/AD_Style</item>
<item name="android:icon">@drawable/icon</item>
</style>
<style name="TB_Back_color" parent="Theme.AppCompat">
<item name="android:background">#ffffff</item>
<item name="android:titleTextStyle">@style/titleText</item>
<item name="android:textSize">15sp</item>
</style>
<style name="titleText" parent="AppTheme">
<item name="android:textColor">#002797</item>
<item name="android:textSize">20sp</item>
<item name="android:fontFamily">Arial</item>
</style>
<style name="AD_Style" parent="Theme.AppCompat">
<item name="android:titleTextStyle">@style/AD_title</item>
<item name="android:textColor">#ffffff</item>
<item name="android:textSize">25sp</item>
<item name="android:buttonBarButtonStyle">@style/AD_Btn_back</item>
<item name="android:divider">#000000</item>
</style>
<style name="AD_Btn_back" parent="AppTheme">
<item name="android:background">#002727</item>
und das ist build.gradle:
apply plugin: 'com.android.application'
android {
repositories {
maven { url 'http://repo1.maven.org/maven2' }
}
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
minSdkVersion 10
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
}
Manifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<uses-sdk android:minSdkVersion="15"/>
<uses-permission android:name="android.permission.VIBRATE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<supports-screens
android:xlargeScreens="true"
android:largeScreens="true"
android:normalScreens="true"
android:anyDensity="true" />
<application
android:allowBackup="true"
android:icon="@drawable/icon"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:label="@string/app_name"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity
</application>
LogCat s:
04-16 10:11:52.760 11960-11960/? D/dalvikvm: Late-enabling CheckJNI
04-16 10:11:52.865 11960-11960/vow_note.maxsoft.com.vownote W/dalvikvm: VFY: unable to find class referenced in signature (Landroid/view/SearchEvent;)
04-16 10:11:52.865 11960-11960/vow_note.maxsoft.com.vownote I/dalvikvm: Could not find method android.view.Window$Callback.onSearchRequested, referenced from method android.support.v7.view.WindowCallbackWrapper.onSearchRequested
04-16 10:11:52.865 11960-11960/vow_note.maxsoft.com.vownote W/dalvikvm: VFY: unable to resolve interface method 17998: Landroid/view/Window$Callback;.onSearchRequested (Landroid/view/SearchEvent;)Z
04-16 10:11:52.865 11960-11960/vow_note.maxsoft.com.vownote D/dalvikvm: VFY: replacing opcode 0x72 at 0x0002
04-16 10:11:52.865 11960-11960/vow_note.maxsoft.com.vownote I/dalvikvm: Could not find method android.view.Window$Callback.onWindowStartingActionMode, referenced from method android.support.v7.view.WindowCallbackWrapper.onWindowStartingActionMode
04-16 10:11:52.865 11960-11960/vow_note.maxsoft.com.vownote W/dalvikvm: VFY: unable to resolve interface method 18002: Landroid/view/Window$Callback;.onWindowStartingActionMode (Landroid/view/ActionMode$Callback;I)Landroid/view/ActionMode;
04-16 10:11:52.870 11960-11960/vow_note.maxsoft.com.vownote D/dalvikvm: VFY: replacing opcode 0x72 at 0x0002
04-16 10:11:52.955 11960-11960/vow_note.maxsoft.com.vownote I/dalvikvm: Could not find method android.content.res.TypedArray.getChangingConfigurations, referenced from method android.support.v7.widget.TintTypedArray.getChangingConfigurations
04-16 10:11:52.955 11960-11960/vow_note.maxsoft.com.vownote W/dalvikvm: VFY: unable to resolve virtual method 445: Landroid/content/res/TypedArray;.getChangingConfigurations()I
04-16 10:11:52.955 11960-11960/vow_note.maxsoft.com.vownote D/dalvikvm: VFY: replacing opcode 0x6e at 0x0002
04-16 10:11:52.955 11960-11960/vow_note.maxsoft.com.vownote I/dalvikvm: Could not find method android.content.res.TypedArray.getType, referenced from method android.support.v7.widget.TintTypedArray.getType
04-16 10:11:52.955 11960-11960/vow_note.maxsoft.com.vownote W/dalvikvm: VFY: unable to resolve virtual method 467: Landroid/content/res/TypedArray;.getType (I)I
04-16 10:11:52.955 11960-11960/vow_note.maxsoft.com.vownote D/dalvikvm: VFY: replacing opcode 0x6e at 0x0002
04-16 10:11:53.140 11960-11960/vow_note.maxsoft.com.vownote D/dalvikvm: GC_FOR_ALLOC freed 133K, 10% free 7205K/7943K, paused 21ms, total 21ms
04-16 10:11:53.145 11960-11960/vow_note.maxsoft.com.vownote I/dalvikvm-heap: Grow heap (frag case) to 8.625MB for 1048592-byte allocation
04-16 10:11:53.165 11960-11962/vow_note.maxsoft.com.vownote D/dalvikvm: GC_CONCURRENT freed 3K, 9% free 8225K/9031K, paused 1ms+2ms, total 22ms
04-16 10:11:53.165 11960-11960/vow_note.maxsoft.com.vownote D/dalvikvm: WAIT_FOR_CONCURRENT_GC blocked 17ms
04-16 10:11:53.180 11960-11960/vow_note.maxsoft.com.vownote D/AndroidRuntime: Shutting down VM
04-16 10:11:53.180 11960-11960/vow_note.maxsoft.com.vownote W/dalvikvm: threadid=1: thread exiting with uncaught exception (group=0x410492a0)
04-16 10:11:53.180 11960-11960/vow_note.maxsoft.com.vownote E/AndroidRuntime: FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to start activity ComponentInfo{vow_note.maxsoft.com.vownote/vow_note.maxsoft.com.vownote.MainActivity}: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2110)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2135)
at android.app.ActivityThread.access$700(ActivityThread.java:140)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1237)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4921)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1038)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:805)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
at android.support.v7.app.AppCompatDelegateImplV7.createSubDecor(AppCompatDelegateImplV7.java:310)
at android.support.v7.app.AppCompatDelegateImplV7.ensureSubDecor(AppCompatDelegateImplV7.java:279)
at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:253)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:109)
at vow_note.maxsoft.com.vownote.MainActivity.onCreate(MainActivity.java:57)
at android.app.Activity.performCreate(Activity.java:5188)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1094)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2074)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2135)
at android.app.ActivityThread.access$700(ActivityThread.java:140)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1237)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4921)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1038)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:805)
at dalvik.system.NativeStart.main(Native Method)
04-16 10:12:01.255 11960-11960/? I/Process: Sending signal. PID: 11960 SIG: 9
Ich benutze diese, aber ich weiß nicht, warum es diese zeigen ???
Dank
Bitte zeigen Sie sowohl das Manifest und die vollständige Logcat Fehler –
'android: theme =" @ style/AppTheme.NoActionBar ">' ist im Manifest, noch haben Sie nicht angezeigt dass in Ihrer Frage –
sind Sie sicher Ihre Aktivität AppCompatActivity? –