我正在开发一个位置感知应用程序。我将Google Play定位服务和Google地图集成到了我的应用程序中。我的应用程序在调试模式下运行没有问题。当我在发布模式下生成已签名的APK并运行该应用程序时,它会在启动时崩溃并出现以下异常:
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.i.b(Unknown)
at com.google.android.gms.b.d.b(Unknown)
at com.google.android.gms.b.j.a(Unknown)
at com.google.android.gms.maps.h.b(Unknown)
at com.google.android.gms.maps.h.a(Unknown)
at com.google.android.gms.b.a.c(Unknown)
at com.google.android.gms.b.a.e(Unknown)
at com.google.android.gms.maps.g.f(Unknown)
at android.support.v4.app.k.ay(Unknown)
at android.support.v4.app.x.l(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'
}
我根据我的软件包名称com.example.akif.test
和com.example.akif
分别设置了两个Google Maps API密钥,用于调试和发布模式。所以,我不认为它与包名有关,但是再一次,它很可能就是因为我对错误一无所知。
知道发生了什么事吗?
答案 0 :(得分:2)
经过大量研究后几乎没有结果,我能够按照Proguard规则解决问题:
wb.Document.GetElementById("a").SetAttribute("value", "bla bla bla");
我仍然不知道我遇到这个问题的真正原因,但似乎已经解决了这个问题。
希望这有帮助。