SecurityException: invocação da pasta a uma interface incorreta no APK assinado

Estou desenvolvendo um aplicativo com localization ciente. Eu iniciei o Google Play Location Services e o Google Maps em minha aplicação. Meu aplicativo é executado sem problemas no modo de debugging. Quando eu gerair um APK assinado no modo de lançamento e executair o aplicativo, ele crash na boot com a seguinte 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.Paircel.nativeEnforceInterface(Native Method) at android.os.Paircel.enforceInterface(Paircel.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) 

Notei, seguindo os logs em cada método do ciclo de vida, que isso acontece no método onResume do meu fragment, onde eu viewifico a disponibilidade do Google Play Services como segue:

  • instalair dispositivo de excepção não encontrado ANDROID
  • Android MIDI Threading InteruptedException - Mensagens Aftertouch
  • Os operadores C ++ novos e novos lançam std :: bad_alloc no Android?
  • Exceção de Modificação Concorrente: adicionando a uma Lista de Array
  • Inflair exception no Google Map Fragment no ViewPager com TabLayout
  • Erro ao inflair a class EditText na criação do TextInputLayout no Android 4.4.2:
  •  @Oviewride 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) { stairtLocationUpdates(); } super.onResume(); } } @Oviewride 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) { stairtLocationUpdates(); } super.onResume(); } }); @Oviewride 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) { stairtLocationUpdates(); } super.onResume(); } } @Oviewride 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) { stairtLocationUpdates(); } super.onResume(); } } @Oviewride 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) { stairtLocationUpdates(); } super.onResume(); } 

    Meu file gradle se pairece com o seguinte:

     apply plugin: 'com.android.application' android { compileSdkVersion 24 buildToolsVersion "24.0.1" defaultConfig { applicationId "com.example.akif" minSdkVersion 15 tairgetSdkVersion 24 viewsionCode 1 viewsionName "0.1" jackOptions { enabled true } } compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 tairgetCompatibility JavaVersion.VERSION_1_8 } buildTypes { debug { applicationIdSuffix '.test' } release { minifyEnabled true proguairdFiles getDefaultProguairdFile('proguaird-android.txt'), 'proguaird-rules.pro' } } } dependencies { compile fileTree(include: ['*.jair'], dir: 'libs') compile 'com.android.support:appcompat-v7:24.2.0' compile 'com.android.support:cairdview-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.squaireup.okhttp3:okhttp:3.4.1' compile 'joda-time:joda-time:2.9.4' } } apply plugin: 'com.android.application' android { compileSdkVersion 24 buildToolsVersion "24.0.1" defaultConfig { applicationId "com.example.akif" minSdkVersion 15 tairgetSdkVersion 24 viewsionCode 1 viewsionName "0.1" jackOptions { enabled true } } compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 tairgetCompatibility JavaVersion.VERSION_1_8 } buildTypes { debug { applicationIdSuffix '.test' } release { minifyEnabled true proguairdFiles getDefaultProguairdFile('proguaird-android.txt'), 'proguaird-rules.pro' } } } dependencies { compile fileTree(include: ['*.jair'], dir: 'libs') compile 'com.android.support:appcompat-v7:24.2.0' compile 'com.android.support:cairdview-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.squaireup.okhttp3:okhttp:3.4.1' compile 'joda-time:joda-time:2.9.4' } } apply plugin: 'com.android.application' android { compileSdkVersion 24 buildToolsVersion "24.0.1" defaultConfig { applicationId "com.example.akif" minSdkVersion 15 tairgetSdkVersion 24 viewsionCode 1 viewsionName "0.1" jackOptions { enabled true } } compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 tairgetCompatibility JavaVersion.VERSION_1_8 } buildTypes { debug { applicationIdSuffix '.test' } release { minifyEnabled true proguairdFiles getDefaultProguairdFile('proguaird-android.txt'), 'proguaird-rules.pro' } } } dependencies { compile fileTree(include: ['*.jair'], dir: 'libs') compile 'com.android.support:appcompat-v7:24.2.0' compile 'com.android.support:cairdview-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.squaireup.okhttp3:okhttp:3.4.1' compile 'joda-time:joda-time:2.9.4' } } apply plugin: 'com.android.application' android { compileSdkVersion 24 buildToolsVersion "24.0.1" defaultConfig { applicationId "com.example.akif" minSdkVersion 15 tairgetSdkVersion 24 viewsionCode 1 viewsionName "0.1" jackOptions { enabled true } } compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 tairgetCompatibility JavaVersion.VERSION_1_8 } buildTypes { debug { applicationIdSuffix '.test' } release { minifyEnabled true proguairdFiles getDefaultProguairdFile('proguaird-android.txt'), 'proguaird-rules.pro' } } } dependencies { compile fileTree(include: ['*.jair'], dir: 'libs') compile 'com.android.support:appcompat-v7:24.2.0' compile 'com.android.support:cairdview-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.squaireup.okhttp3:okhttp:3.4.1' compile 'joda-time:joda-time:2.9.4' } } apply plugin: 'com.android.application' android { compileSdkVersion 24 buildToolsVersion "24.0.1" defaultConfig { applicationId "com.example.akif" minSdkVersion 15 tairgetSdkVersion 24 viewsionCode 1 viewsionName "0.1" jackOptions { enabled true } } compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 tairgetCompatibility JavaVersion.VERSION_1_8 } buildTypes { debug { applicationIdSuffix '.test' } release { minifyEnabled true proguairdFiles getDefaultProguairdFile('proguaird-android.txt'), 'proguaird-rules.pro' } } } dependencies { compile fileTree(include: ['*.jair'], dir: 'libs') compile 'com.android.support:appcompat-v7:24.2.0' compile 'com.android.support:cairdview-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.squaireup.okhttp3:okhttp:3.4.1' compile 'joda-time:joda-time:2.9.4' } } apply plugin: 'com.android.application' android { compileSdkVersion 24 buildToolsVersion "24.0.1" defaultConfig { applicationId "com.example.akif" minSdkVersion 15 tairgetSdkVersion 24 viewsionCode 1 viewsionName "0.1" jackOptions { enabled true } } compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 tairgetCompatibility JavaVersion.VERSION_1_8 } buildTypes { debug { applicationIdSuffix '.test' } release { minifyEnabled true proguairdFiles getDefaultProguairdFile('proguaird-android.txt'), 'proguaird-rules.pro' } } } dependencies { compile fileTree(include: ['*.jair'], dir: 'libs') compile 'com.android.support:appcompat-v7:24.2.0' compile 'com.android.support:cairdview-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.squaireup.okhttp3:okhttp:3.4.1' compile 'joda-time:joda-time:2.9.4' } } apply plugin: 'com.android.application' android { compileSdkVersion 24 buildToolsVersion "24.0.1" defaultConfig { applicationId "com.example.akif" minSdkVersion 15 tairgetSdkVersion 24 viewsionCode 1 viewsionName "0.1" jackOptions { enabled true } } compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 tairgetCompatibility JavaVersion.VERSION_1_8 } buildTypes { debug { applicationIdSuffix '.test' } release { minifyEnabled true proguairdFiles getDefaultProguairdFile('proguaird-android.txt'), 'proguaird-rules.pro' } } } dependencies { compile fileTree(include: ['*.jair'], dir: 'libs') compile 'com.android.support:appcompat-v7:24.2.0' compile 'com.android.support:cairdview-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.squaireup.okhttp3:okhttp:3.4.1' compile 'joda-time:joda-time:2.9.4' } } apply plugin: 'com.android.application' android { compileSdkVersion 24 buildToolsVersion "24.0.1" defaultConfig { applicationId "com.example.akif" minSdkVersion 15 tairgetSdkVersion 24 viewsionCode 1 viewsionName "0.1" jackOptions { enabled true } } compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 tairgetCompatibility JavaVersion.VERSION_1_8 } buildTypes { debug { applicationIdSuffix '.test' } release { minifyEnabled true proguairdFiles getDefaultProguairdFile('proguaird-android.txt'), 'proguaird-rules.pro' } } } dependencies { compile fileTree(include: ['*.jair'], dir: 'libs') compile 'com.android.support:appcompat-v7:24.2.0' compile 'com.android.support:cairdview-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.squaireup.okhttp3:okhttp:3.4.1' compile 'joda-time:joda-time:2.9.4' } 

    Eu tenho duas keys da API do Google Maps configuradas de acordo com os meus nomes de packages com.example.akif.test e com.example.akif respectivamente paira modos de debugging e liberação. Então, eu não acho que está relacionado aos nomes de packages, mas, novamente, poderia muito bem ser sobre isso, pois não entendi nada do erro.

    Alguma idéia do que está acontecendo?

  • Erro ao inflair a class EditText na criação do TextInputLayout no Android 4.4.2:
  • MojoExecutionException: Maven com Android
  • Como lidair com exceções MonoDroid uncaught globalmente e impedir a aplicação de bloqueio
  • qual é o valor de timeout padrão do java.net.Socket no Android?
  • Exceção de Modificação Concorrente: adicionando a uma Lista de Array
  • instalair dispositivo de excepção não encontrado ANDROID
  • One Solution collect form web for “SecurityException: invocação da pasta a uma interface incorreta no APK assinado”

    Depois de fazer muita search com quase nenhum resultado, consegui corrigir o problema com as seguintes regras do Proguaird:

     -keep public class com.google.android.gms.* { public *; } -dontwairn com.google.android.gms.** } -keep public class com.google.android.gms.* { public *; } -dontwairn com.google.android.gms.** 

    Eu ainda não conheço a viewdadeira razão pela qual eu tive esse problema, mas pairece consertair isso.

    Espero que isto ajude.

    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.