我的应用程序在Android 5.0.0(Genymotion)的模拟器上正常运行,但它在所有其他较低的API上崩溃。 mainacx支持已添加到mainactivity.java和build.gradle中,但它没有修复它。
请提供建议。
的build.gradle
android {
compileSdkVersion 21
buildToolsVersion '22.0.1'
defaultConfig {
applicationId "gym.myapp"
minSdkVersion 8
targetSdkVersion 21
versionCode 1
versionName "1.0"
// Enabling multidex support.
multiDexEnabled true }
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7}
buildTypes {
release {minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' }
debug {
debuggable true}}
productFlavors {}}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.parse.bolts:bolts-android:1.+'
compile 'com.google.android.gms:play-services:4.1.32'
compile 'com.android.support:appcompat-v7:21.0.0'
compile 'com.android.support:cardview-v7:21.0.0'
compile 'com.android.support:recyclerview-v7:21.0.0'
compile 'com.android.support:multidex:1.0.0'}
Mainactivity.java
public class MainActivity extends ListActivity {
protected ImageButton composeButton;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
composeButton=(ImageButton)findViewById(R.id.mainComposeButton);}
@Override protected void attachBaseContext(Context base) { super.attachBaseContext(base); MultiDex.install(this); }
activity_main.xml中
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/mainComposeButton"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:minHeight="60dp"
android:minWidth="60dp"
android:layout_margin="8dp"
android:layout_gravity="center_vertical|end|center"
android:src="@drawable/ic_content_create"
logcat的
java.lang.RuntimeException: Unable to start activity ComponentInfo{gym.myapp/gym.myApp.MainActivity}: android.view.InflateException: Binary XML file line #27: Error inflating class android.widget.ImageButton
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2184)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233)
at android.app.ActivityThread.access$800(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5001)
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:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.view.InflateException: Binary XML file line #27: Error inflating class android.widget.ImageButton
at android.view.LayoutInflater.createView(LayoutInflater.java:620)
at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:669)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:694)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:758)
at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:290)
at android.app.Activity.setContentView(Activity.java:1929)
at gym.myapp.MainActivity.onCreate(MainActivity.java:73)
at android.app.Activity.performCreate(Activity.java:5231)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2148)