该应用程序在android 5.1和6.1中运行良好,但在4.10中崩溃(API 16)

该应用程序在android 5.1和6.1中运行良好,但在4.10中崩溃(API 16),android,android-5.1.1-lollipop,android-4.1-jelly-bean,Android,Android 5.1.1 Lollipop,Android 4.1 Jelly Bean,我是Android开发的新手。我可以让这个应用程序在安卓5.1中运行,但是当我试图在安卓4.1中部署这个应用程序时,它常常在主活动中崩溃。我理解它,因为我使用了矢量图像,android 4.1与它不兼容。为了克服这个问题,我设置了如下代码: // Gradle Plugin 2.0+ android { defaultConfig { vectorDrawables.useSupportLibrary = true } } You’ll no

我是Android开发的新手。我可以让这个应用程序在安卓5.1中运行,但是当我试图在安卓4.1中部署这个应用程序时,它常常在主活动中崩溃。我理解它,因为我使用了矢量图像,android 4.1与它不兼容。为了克服这个问题,我设置了如下代码:

 // Gradle Plugin 2.0+  
 android {  
   defaultConfig {  
     vectorDrawables.useSupportLibrary = true  
    }  
 }  
You’ll note this new attribute only exists in the version 2.0 of the Gradle Plugin. If you are using Gradle 1.5 you’ll instead use
 // Gradle Plugin 1.5  
 android {  
   defaultConfig {  
     generatedDensities = []  
  }  

  // This is handled for you by the 2.0+ Gradle Plugin  
  aaptOptions {  
    additionalParameters "--no-version-vectors"  
  }  
 }
我现在收到此错误

AndroidRuntime:致命异常:主java.lang.RuntimeException:无法启动activityComponentInfo{com.abc.efg.plcapp/com.abc.efg.ghi.MainActivity}: android.view.InflateException:二进制XML文件行#37:错误 膨胀类图像视图 在 android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059) 在 android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084) 在android.app.ActivityThread.access$600(ActivityThread.java:130) 在 android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195) 位于android.os.Handler.dispatchMessage(Handler.java:99) 位于android.os.Looper.loop(Looper.java:137) 位于android.app.ActivityThread.main(ActivityThread.java:4745) 位于java.lang.reflect.Method.Invokenactive(本机方法) 位于java.lang.reflect.Method.invoke(Method.java:511) 在 com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786) 位于com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553) 在dalvik.system.NativeStart.main(本机方法) 原因:android.view.InflateException:二进制XML文件行#37: 膨胀类ImageView时出错 在 android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704) 位于android.view.LayoutInflater.rInflate(LayoutInflater.java:746) 位于android.view.LayoutInflater.parseInclude(LayoutInflater.java:830) 位于android.view.LayoutInflater.rInflate(LayoutInflater.java:736) 位于android.view.LayoutInflater.parseInclude(LayoutInflater.java:830) 位于android.view.LayoutInflater.rInflate(LayoutInflater.java:736) 在android.view.LayoutInflater.充气(LayoutInflater.java:489) 在android.view.LayoutInflater.inflate(LayoutInflater.java:396) 在android.view.LayoutInflater.充气(LayoutInflater.java:352) 在 android.support.v7.app.AppCompateDelegateImplv7.setContentView(AppCompateDelegateImplv7.java:267) 在 android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:129) 在 onCreate(MainActivity.java:40) 在android.app.Activity.performCreate上(Activity.java:5008) 在 android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079) 在 android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023) 在 android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084) 在android.app.ActivityThread.access$600(ActivityThread.java:130) 在 android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195) 位于android.os.Handler.dispatchMessage(Handler.java:99) 位于android.os.Looper.loop(Looper.java:137) 位于android.app.ActivityThread.main(ActivityThread.java:4745) 在java.lang.reflect.M
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.provider.Settings;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.view.View;
import android.support.design.widget.NavigationView;
import android.support.v4.view.GravityCompat;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;

import com.google.android.gms.appindexing.Action;
import com.google.android.gms.appindexing.AppIndex;
import com.google.android.gms.common.api.GoogleApiClient;

import android.util.Log;
import android.widget.Button;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity
        implements NavigationView.OnNavigationItemSelectedListener {
    Button btnRegister;
    Button btnRequestLog;
    /**
     * ATTENTION: This was auto-generated to implement the App Indexing API.
     * See https://g.co/AppIndexing/AndroidStudio for more information.
     */
    private GoogleApiClient client;
    private String android_id;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

       Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
       setSupportActionBar(toolbar);
if ( findViewById(R.id.fab) == null)
    {}
        else {

        }
        FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
        fab.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
                        .setAction("Action", null).show();
            }
        });

        DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
        ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
                this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
        drawer.setDrawerListener(toggle);
        toggle.syncState();

        NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
        navigationView.setNavigationItemSelectedListener(this);
        // ATTENTION: This was auto-generated to implement the App Indexing API.
        // See https://g.co/AppIndexing/AndroidStudio for more information.
        client = new GoogleApiClient.Builder(this).addApi(AppIndex.API).build();

        // Buttons
        btnRegister = (Button) findViewById(R.id.btnRegister);
        btnRequestLog = (Button) findViewById(R.id.btnRequestLog);
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout 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:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    tools:openDrawer="start">

    <include
        layout="@layout/app_bar_main"
        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:fitsSystemWindows="true"
        app:headerLayout="@layout/nav_header_main"
        app:menu="@menu/activity_main_drawer" />

</android.support.v4.widget.DrawerLayout>