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

问题描述:

我遇到了已签名的apk问题 - >当我通过“play”-Button从Android Studio直接安装apk时,未出现以下问题。已签名的Apk崩溃,直接通过Android Studio安装不是

应用程序的启动是怎么回事,没有任何问题,但是当我尝试点击出现以下异常的看法:

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法

protected void openCurrentFeedback(View v) { 
    if (globals.isFeedbackRunning()) { 
     Intent intent = new Intent(); 
     intent.setClass(v.getContext(), FeedbackManuallyActivity.class); 
     startActivity(intent); 
    } 
} 
+0

检查方法'openCurrentFeedback(View)'并检查实现它的布局。检查拼写是否正确。 – FiN

+0

这是好的,因为它工作时,我直接从android工作室安装应用程序到相同的设备。我在这样做的代码中没有改变任何东西。我怀疑propguard,也许它是删除东西.... – user99316

+0

你可以发布方法'openCurrentFeedback(查看)' – FiN

抱歉,没有足够的声誉对此事发表评论。 崩溃给我的理由似乎是在XML布局的按钮直接使用

onclick="openCurrentFeedback" 

因此,proguard的加密,并改名为代码,方法有所改变和不同的您在XML声明的名称。

只是一些信息来源,如果你想保留保护,而不是公开的,你可以在proguad添加保持这种方法:

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

无论如何,这answser信贷应该是鳍的:)