签名Apk崩溃,不通过Android Studio直接安装

时间:2017-02-24 13:25:33

标签: android android-studio gradle apk signed-apk

我的签名apk有问题 - >当我通过“播放”-Button从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);
    }
}

1 个答案:

答案 0 :(得分:0)

抱歉没有足够的评论声誉。 崩溃的原因似乎是xml布局中的按钮直接使用

onclick="openCurrentFeedback"

因此,proguard加密并重命名代码,方法被更改,并且与您在xml中声明的名称不同。

只是一些信息,如果你想保持受保护而不是公开,你可以在proguad中添加以保持该方法:

-keep class package.TheClass {
  protected void openCurrentFeedback(android.view.View);
}

无论如何,这个回答者应该是FiN的:)