这是崩溃:
java.lang.RuntimeException:
at android.app.ActivityThread.performLaunchActivity (ActivityThread.java:2413)
at android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:2471)
at android.app.ActivityThread.access$900 (ActivityThread.java:175)
at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1308)
at android.os.Handler.dispatchMessage (Handler.java:102)
at android.os.Looper.loop (Looper.java:146)
at android.app.ActivityThread.main (ActivityThread.java:5602)
at java.lang.reflect.Method.invokeNative (Native Method)
at java.lang.reflect.Method.invoke (Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:1283)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1099)
at dalvik.system.NativeStart.main (Native Method)
Caused by: android.view.InflateException:
at android.view.LayoutInflater.createView (LayoutInflater.java:626)
at android.view.LayoutInflater.createViewFromTag (LayoutInflater.java:702)
at android.view.LayoutInflater.rInflate (LayoutInflater.java:761)
at android.view.LayoutInflater.inflate (LayoutInflater.java:498)
at android.view.LayoutInflater.inflate (LayoutInflater.java:398)
at android.view.LayoutInflater.inflate (LayoutInflater.java:354)
at android.support.v7.app.AppCompatDelegateImplV9.setContentView (AppCompatDelegateImplV9.java:292)
at android.support.v7.app.AppCompatActivity.setContentView (AppCompatActivity.java:140)
at com.bitcoinaverage.bitcoinapp.activities.MainActivity.onCreate (MainActivity.java:115)
at android.app.Activity.performCreate (Activity.java:5451)
at android.app.Instrumentation.callActivityOnCreate (Instrumentation.java:1093)
at android.app.ActivityThread.performLaunchActivity (ActivityThread.java:2377)
这是我的MainActivity(第115行):setContentView(R.layout.activity_main);
这是我的activity_main.xml:
<include
layout="@layout/app_bar_dashboard"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<android.support.design.widget.NavigationView
android:id="@+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="@color/colorPrimaryLight"
android:fitsSystemWindows="true"
app:headerLayout="@layout/nav_header_dashboard"
app:itemTextColor="@color/textColorGrey"
app:menu="@menu/navigation_drawer" />
</android.support.v4.widget.DrawerLayout>
这是app_bar_dashboard.xml:
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/blackTwo"
xmlns:ads="http://schemas.android.com/apk/res-auto"
tools:context="com.bitcoinaverage.bitcoinapp.activities.MainActivity">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/blackTwo"
app:popupTheme="@style/AppTheme.PopupOverlay" />
</android.support.design.widget.AppBarLayout>
<FrameLayout
android:id="@+id/fragment_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
</android.support.design.widget.CoordinatorLayout>
我在项目中使用了材质设计主题。应用程序即时崩溃,因为它在三星音符2上打开,它有Android 4.4和2gb内存。 任何人都可以解释为什么它会崩溃?
这是build.gradle [app]:
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.bitcoinaverage.bitcoinapp"
minSdkVersion 16
targetSdkVersion 25
versionCode 13
versionName "1.1.9"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dataBinding.enabled = true
android.defaultConfig.vectorDrawables.useSupportLibrary = true
dexOptions {
javaMaxHeapSize "4g"
}
}
dependencies {
compile files('libs/joda-time-2.9.9.jar')
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:design:25.3.1'
compile 'com.android.support:cardview-v7:25.3.1'
compile 'com.android.support:recyclerview-v7:25.3.1'
compile 'com.google.firebase:firebase-messaging:11.0.1'
compile 'com.google.code.gson:gson:2.8.1'
compile 'com.squareup.retrofit2:retrofit:2.3.0'
compile 'com.squareup.retrofit2:converter-gson:2.3.0'
compile 'android.arch.persistence.room:runtime:1.0.0-alpha5'
compile 'com.squareup.picasso:picasso:2.5.0'
compile 'com.github.PhilJay:MPAndroidChart:v3.0.2'
compile 'com.google.firebase:firebase-analytics:11.0.1'
compile 'com.google.firebase:firebase-ads:11.0.1'
annotationProcessor 'android.arch.persistence.room:compiler:1.0.0-alpha5'
}
apply plugin: 'com.google.gms.google-services'
style.xml
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="android:listDivider">@color/textColorGrey</item>
</style>
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
<style name="interval_style">
<item name="android:layout_width">0dp</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_weight">1</item>
<item name="android:gravity">center</item>
<item name="android:textColor">@color/warmGreyTwo</item>
<item name="android:textSize">@dimen/dashboard_graph_interval_text_size</item>
<item name="android:textStyle">bold</item>
<item name="android:paddingTop">10dp</item>
<item name="android:paddingBottom">10dp</item>
</style>
</resources>
style.xml [V21]
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="android:statusBarColor">@android:color/transparent</item>
</style>
</resources>