我的签名 apk 有问题 --> 当我通过“播放”按钮直接从 Android Studio 安装 apk 时,不会出现以下问题。
应用程序的启动没有任何问题,但是当我尝试单击视图时出现以下异常:
java.lang.IllegalStateException: Could not find method openCurrentFeedback(View) in a parent or ancestor Context for android:onClick attribute defined on view class android.support.v7.widget.Toolbar with id 'toolbar_top'
at android.view.View$DeclaredOnClickListener.resolveMethod(View.java:4784)
at android.view.View$DeclaredOnClickListener.onClick(View.java:4748)
at android.view.View.performClick(View.java:5714)
at android.view.View$PerformClick.run(View.java:22589)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:7325)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
我听说过有关 build.gradle 的一些信息,尤其是 propguard 文件。这是我当前的 gradle.build 设置:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion '24.0.0'
useLibrary 'org.apache.http.legacy'
defaultConfig {
applicationId "com.app.app"
minSdkVersion 19
targetSdkVersion 23
versionCode 7
versionName "1.06"
//multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
debuggable true
}
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
}
testOptions {
unitTests.returnDefaultValues = true
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile files('libs/PPJASCommon.jar')
compile files('libs/easywsdl/ksoap2-android-assembly-3.6.0-jar-with-dependencies.jar')
compile files('libs/gson/gson-2.2.4.jar')
//for autoresize of text
//dependencies for testing
//junit 4
testCompile 'junit:junit:4.12'
//roboeletric for unittests in the jvm without any (emulated) android device
testCompile 'org.robolectric:robolectric:3.0'
//mockito
testCompile 'org.mockito:mockito-core:1.+'
//power mock, for mock ups
testCompile 'org.powermock:powermock-module-junit4:1.6.2'
testCompile 'org.powermock:powermock-api-mockito:1.6.2'
//robotium for ui tests
androidTestCompile 'com.jayway.android.robotium:robotium-solo:5.5.4'
compile 'com.android.support:appcompat-v7:23.3.0'
compile 'com.android.support:design:23.3.0'
compile 'org.apache.httpcomponents:httpclient:4.5'
compile 'com.android.support:support-v4:23.3.0'
compile 'me.grantland:autofittextview:0.2.1'
}
还有我的 propgurard-rule.pro 条目:
-keep public class com.app.*
再说一遍:如果我直接从 android studio(没有签名的 apk)安装应用程序,点击功能可以正常工作。
我正在使用运行 android 6.0.1 的三星 Galaxy a5 设备进行测试。
有没有人有任何想法?
编辑:openCurrentFeedback-Method
protected void openCurrentFeedback(View v) {
if (globals.isFeedbackRunning()) {
Intent intent = new Intent();
intent.setClass(v.getContext(), FeedbackManuallyActivity.class);
startActivity(intent);
}
}