SecurityException:绑定器调用到已签名的APK上不正确的接口

我正在开发一个位置感知应用程序。 我将Google Play位置服务和Google地图整合到了我的应用程序中。 我的应用程序在debugging模式下运行时没有问题。 当我在发布模式下生成签名APK并运行应用程序时,它在启动时崩溃,但出现以下exception

Process: com.example.akif, PID: 4233 java.lang.RuntimeException: Unable to resume activity {com.example.akif/com.example.akif.activities.MainActivity}: java.lang.SecurityException: Binder invocation to an incorrect interface at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3400) at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3440) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2713) at android.app.ActivityThread.-wrap12(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1460) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6077) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755) Caused by: java.lang.SecurityException: Binder invocation to an incorrect interface at android.os.Parcel.nativeEnforceInterface(Native Method) at android.os.Parcel.enforceInterface(Parcel.java:482) at vz.onTransact(:com.google.android.gms.DynamiteModulesB:81) at android.os.Binder.transact(Binder.java:499) at com.google.android.gms.maps.a.bt.c(Unknown) at com.google.android.gms.maps.ib(Unknown) at com.google.android.gms.bdb(Unknown) at com.google.android.gms.bja(Unknown) at com.google.android.gms.maps.hb(Unknown) at com.google.android.gms.maps.ha(Unknown) at com.google.android.gms.bac(Unknown) at com.google.android.gms.bae(Unknown) at com.google.android.gms.maps.gf(Unknown) at android.support.v4.app.k.ay(Unknown) at android.support.v4.app.xl(Unknown) at android.support.v4.app.ax.h(Unknown) at android.support.v4.app.ax.i(Unknown) at android.support.v4.app.ax.run(Unknown) at android.support.v4.app.x.ae(Unknown) at android.support.v4.app.i.aa(Unknown) at android.support.v4.app.a.onPostResume(Unknown) at android.support.v7.app.a.onPostResume(Unknown) at android.app.Activity.performResume(Activity.java:6792) at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3377) at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3440) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2713) at android.app.ActivityThread.-wrap12(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1460) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6077) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865) 

我注意到在每个生命周期方法中的以下日志,这发生在我的片段的onResume方法中,我检查的Google Play服务可用性如下:

 @Override public void onResume() { Log.debug(getClass(), "onResume()"); GoogleApiAvailability googleApiAvailability = GoogleApiAvailability.getInstance(); int googlePlayServicesAvailabilityResult = googleApiAvailability.isGooglePlayServicesAvailable(getContext()); if (googlePlayServicesAvailabilityResult != ConnectionResult.SUCCESS) { if (!googleApiAvailability.isUserResolvableError(googlePlayServicesAvailabilityResult)) { Toast.makeText(getContext(), "Your device doesn't support Google Play location services. This application cannot run without it!", Toast.LENGTH_LONG).show(); getActivity().finish(); return; } Dialog errorDialog = googleApiAvailability.getErrorDialog(getActivity(), googlePlayServicesAvailabilityResult, GOOGLE_PLAY_SERVICES_REQUEST_CODE); if (errorDialog != null) { errorDialog.setCancelable(false); errorDialog.setCanceledOnTouchOutside(false); errorDialog.setOnDismissListener((DialogInterface dialogInterface) -> { Toast.makeText(getContext(), "You need Google Play location services to run this application!", Toast.LENGTH_LONG).show(); getActivity().finish(); }); errorDialog.show(); } } else if (googleApiClient.isConnected() && !isUpdatingLocation) { startLocationUpdates(); } super.onResume(); } 

我的gradle文件如下所示:

 apply plugin: 'com.android.application' android { compileSdkVersion 24 buildToolsVersion "24.0.1" defaultConfig { applicationId "com.example.akif" minSdkVersion 15 targetSdkVersion 24 versionCode 1 versionName "0.1" jackOptions { enabled true } } compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } buildTypes { debug { applicationIdSuffix '.test' } release { minifyEnabled true proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } } dependencies { compile fileTree(include: ['*.jar'], dir: 'libs') compile 'com.android.support:appcompat-v7:24.2.0' compile 'com.android.support:cardview-v7:24.2.0' compile 'com.android.support:design:24.2.0' compile 'com.android.support:preference-v7:24.2.0' compile 'com.google.android.gms:play-services-location:9.4.0' compile 'com.google.android.gms:play-services-maps:9.4.0' compile 'com.github.mehmetakiftutuncu:toolbelt:1.1.0' compile 'com.squareup.okhttp3:okhttp:3.4.1' compile 'joda-time:joda-time:2.9.4' } 

我有两个Google Maps API密钥,分别根据我的软件包名称com.example.akif.testcom.example.akif进行设置,以用于debugging和发布模式。 所以,我不认为它与软件包名称有关,但是再一次,这很可能是因为我对错误没有任何理解。

任何想法发生了什么?

Solutions Collecting From Web of "SecurityException:绑定器调用到已签名的APK上不正确的接口"