NoSuchMethodException:<init> [类android.view.View]生成签名后的apk

时间:2017-01-26 19:34:19

标签: android firebase firebaseui

我不知道为什么 NoSuchMethodException 正在应用中发生。我正在使用firebase auth +数据库。我使用 FirebaseRecyclerAdapter 将数据填充到recyclerview。我正在尝试按照this answer解决此异常,但无法使其成为可能。

public class PostViewHolder extends RecyclerView.ViewHolder {...}

如果我使用应用程序的调试版本,它可以完美运行而不会崩溃。但是在创建签名的apk应用程序后每次都崩溃了。我正在使用firebase崩溃报告,其中我得到了这个 Logcat:

Exception java.lang.RuntimeException: java.lang.NoSuchMethodException: <init> [class android.view.View]
com.b.a.a.b.a ()
android.support.v7.widget.RecyclerView$a.b ()
android.support.v7.widget.RecyclerView$o.a ()
android.support.v7.widget.RecyclerView$o.a ()
android.support.v7.widget.RecyclerView$o.c ()
android.support.v7.widget.LinearLayoutManager$c.a ()
android.support.v7.widget.LinearLayoutManager.a ()
android.support.v7.widget.LinearLayoutManager.a ()
android.support.v7.widget.LinearLayoutManager.c ()
android.support.v7.widget.RecyclerView.M ()
android.support.v7.widget.RecyclerView.p ()
android.support.v7.widget.RecyclerView.c ()
android.support.v7.widget.RecyclerView$1.run ()
android.view.Choreographer$CallbackRecord.run (Choreographer.java:767)
android.view.Choreographer.doCallbacks (Choreographer.java:580)
android.view.Choreographer.doFrame (Choreographer.java:549)
android.view.Choreographer$FrameDisplayEventReceiver.run (Choreographer.java:753)
android.os.Handler.handleCallback (Handler.java:739)
android.os.Handler.dispatchMessage (Handler.java:95)
android.os.Looper.loop (Looper.java:135)
android.app.ActivityThread.main (ActivityThread.java:5233)
java.lang.reflect.Method.invoke (Method.java)
java.lang.reflect.Method.invoke (Method.java:372)
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:898)
com.android.internal.os.ZygoteInit.main (ZygoteInit.java:693)

Caused by java.lang.NoSuchMethodException: <init> [class android.view.View]
java.lang.Class.getConstructor (Class.java:531)
java.lang.Class.getConstructor (Class.java:495)
com.b.a.a.b.a ()
android.support.v7.widget.RecyclerView$a.b ()
android.support.v7.widget.RecyclerView$o.a ()
android.support.v7.widget.RecyclerView$o.a ()
android.support.v7.widget.RecyclerView$o.c ()
android.support.v7.widget.LinearLayoutManager$c.a ()
android.support.v7.widget.LinearLayoutManager.a ()
android.support.v7.widget.LinearLayoutManager.a ()
android.support.v7.widget.LinearLayoutManager.c ()
android.support.v7.widget.RecyclerView.M ()
android.support.v7.widget.RecyclerView.p ()
android.support.v7.widget.RecyclerView.c ()
android.support.v7.widget.RecyclerView$1.run ()
android.view.Choreographer$CallbackRecord.run (Choreographer.java:767)
android.view.Choreographer.doCallbacks (Choreographer.java:580)
android.view.Choreographer.doFrame (Choreographer.java:549)
android.view.Choreographer$FrameDisplayEventReceiver.run (Choreographer.java:753)
android.os.Handler.handleCallback (Handler.java:739)
android.os.Handler.dispatchMessage (Handler.java:95)
android.os.Looper.loop (Looper.java:135)
android.app.ActivityThread.main (ActivityThread.java:5233)
java.lang.reflect.Method.invoke (Method.java)
java.lang.reflect.Method.invoke (Method.java:372)
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:898)
com.android.internal.os.ZygoteInit.main (ZygoteInit.java:693)

我的代码有什么问题,每个东西在调试版本中工作得很好,但签名的应用程序在打开时崩溃了。

1 个答案:

答案 0 :(得分:1)

这是因为ProGuard混淆了你的apk,使黑客更难对你的apk进行逆向工程。如果您认为不需要混淆,请在您的gradle配置中进行更改:

#include <iostream>

#include <algorithm>

using namespace std;

int main()
{
    int arr[5] = {1,2,3,4,5};
    int m=3;

    do {
    for(int i=0;i<m;i++) {
        cout<<arr[i]<<" ";
    }
    cout<<endl;
    } while(next_permutation(arr, arr+m));
    return 0;
}

或者,您可以使用以下命令让ProGuard跳过对支持库的混淆:

minifyEnabled false

添加文件minifyEnabled true proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt' 并尝试添加以下行:

proguard-rules.txt