Android IllegalArgumentException:类com.e.pi的默认构造函数不可访问

Android IllegalArgumentException:类com.e.pi的默认构造函数不可访问,android,proguard,Android,Proguard,在调试模式下运行我的应用程序,并从Android studio运行,应用程序运行良好;但是,当构建并签署APK并在手机上安装时,应用程序会崩溃,并出现以下堆栈跟踪: 06-24 13:54:59.725 17656-17656/? E/AndroidRuntime: FATAL EXCEPTION: main Process: com.test, PID: 17656 java.lang.RuntimeException: Unable to create application c

在调试模式下运行我的应用程序,并从Android studio运行,应用程序运行良好;但是,当构建并签署APK并在手机上安装时,应用程序会崩溃,并出现以下堆栈跟踪:

06-24 13:54:59.725 17656-17656/? E/AndroidRuntime: FATAL EXCEPTION: main
   Process: com.test, PID: 17656
   java.lang.RuntimeException: Unable to create application com.test.Utilities.TestApplication: java.lang.IllegalArgumentException: Default constructor for class com.e.pi is not accessible.
       at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4715)
       at android.app.ActivityThread.-wrap1(ActivityThread.java)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1405)
       at android.os.Handler.dispatchMessage(Handler.java:102)
       at android.os.Looper.loop(Looper.java:148)
       at android.app.ActivityThread.main(ActivityThread.java:5422)
       at java.lang.reflect.Method.invoke(Native Method)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
    Caused by: java.lang.IllegalArgumentException: Default constructor for class com.e.pi is not accessible.
       at com.e.mo.b(Unknown Source)
       at com.e.kh.b(Unknown Source)
       at com.e.kh.J(Unknown Source)
       at com.e.gr.a(Unknown Source)
       at com.test.Utilities.TestApplication.onCreate(Unknown Source)
       at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1013)
       at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4712)
       at android.app.ActivityThread.-wrap1(ActivityThread.java) 
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1405) 
       at android.os.Handler.dispatchMessage(Handler.java:102) 
       at android.os.Looper.loop(Looper.java:148) 
       at android.app.ActivityThread.main(ActivityThread.java:5422) 
       at java.lang.reflect.Method.invoke(Native Method) 
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 
我不希望删除ProGuard并解决此问题,任何帮助都将不胜感激

以下是申请代码:

public class TestApplication extends Application {

    public static final String TAG = "ALL";
    private static TestApplication mInstance;
    private RequestQueue mRequestQueue;

    public TestApplication()
    {
        mInstance = this;
    }

    @Override
    public void onCreate() {
        super.onCreate();
        Fabric.with(this, new Crashlytics());

        String server = "eg....";
        // Enable Local Datastore.
        Parse.enableLocalDatastore(this);
        Parse.initialize(new Parse.Configuration.Builder(this)
                .applicationId(BuildConfig.PARSE_APP_ID)
                .clientKey(BuildConfig.PARSE_CLIENT_KEY)
                .server(server)
                .build());

        // Logging set to help debug issues, remove before releasing your app.
        OneSignal.setLogLevel(OneSignal.LOG_LEVEL.DEBUG, OneSignal.LOG_LEVEL.WARN);

        OneSignal.startInit(this)
                .setNotificationOpenedHandler(new ExampleNotificationOpenedHandler())
                .setAutoPromptLocation(true)
                .init();

        CalligraphyConfig.initDefault(new CalligraphyConfig.Builder()
                .setDefaultFontPath("fonts/Roboto-Regular.ttf")
                .setFontAttrId(R.attr.fontPath)
                .build()
        );
    }

    public static synchronized TestApplication getInstance()
    {
        if(mInstance == null)
        {
            mInstance = new TestApplication();
        }
        return mInstance;
    }

    public RequestQueue getRequestQueue(Context context)
    {
        if(mRequestQueue == null)
        {
            mRequestQueue = Volley.newRequestQueue(context);
        }

        return mRequestQueue;
    }

    public <T> void addToRequestQueue(Request<T> request, String tag, Context context)
    {
        request.setTag(TextUtils.isEmpty(tag) ? TAG : tag);
        request.setShouldCache(false);
        getRequestQueue(context).add(request);
    }

    public <T> void addToRequestQueue(Request<T> request, Context context)
    {
        request.setTag(TAG);
        getRequestQueue(context).add(request);
    }

    public void cancelPendingRequests(Object tag)
    {
        if(mRequestQueue != null)
        {
            mRequestQueue.cancelAll(tag);
        }
    }

    @Override
    protected void attachBaseContext(Context base) {
        super.attachBaseContext(base);
        MultiDex.install(this);
    }

    private class ExampleNotificationOpenedHandler implements OneSignal.NotificationOpenedHandler {
        /**
         * Callback to implement in your app to handle when a notification is opened from the Android status bar or
         * a new one comes in while the app is running.
         * This method is located in this Application class as an example, you may have any class you wish implement NotificationOpenedHandler and define this method.
         *
         * @param message        The message string the user seen/should see in the Android status bar.
         * @param additionalData The additionalData key value pair section you entered in on onesignal.com.
         * @param isActive       Was the app in the foreground when the notification was received.
         */
        @Override
        public void notificationOpened(String message, JSONObject additionalData, boolean isActive) {
            String additionalMessage = "";

            try {
                if (additionalData != null) {
                    if (additionalData.has("this")) {
                        additionalMessage = additionalData.getString("this");

                        if (additionalMessage.toString().trim().equalsIgnoreCase("x")) {
                            Intent newIntent = new Intent("com.test.push");//this has to match your intent filter
                            newIntent.putExtra("FEATURE_PUSH", "x");
                            newIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                            startActivity(newIntent);
                        }
                        else if (additionalMessage.toString().trim().equalsIgnoreCase("y")) {
                            Intent newIntent = new Intent("com.test.push");//this has to match your intent filter
                            newIntent.putExtra("FEATURE_PUSH", "y");
                            newIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                            startActivity(newIntent);
                        }
                    }
                }

            } catch (Throwable t) {
                t.printStackTrace();
            }
        }
    }

    public ImageLoader getImageLoader() {
        return mImageLoader;
    }
}
公共类测试应用程序扩展了应用程序{
公共静态最终字符串TAG=“ALL”;
专用静态测试应用程序;
私有请求队列mRequestQueue;
公开测试应用程序()
{
mInstance=这个;
}
@凌驾
public void onCreate(){
super.onCreate();
Fabric.with(this,newcrashlytics());
String server=“例如…”;
//启用本地数据存储。
enableLocalDatastore(this);
初始化(新的Parse.Configuration.Builder(此)
.applicationId(BuildConfig.PARSE\u APP\u ID)
.clientKey(BuildConfig.PARSE_CLIENT_KEY)
.server(服务器)
.build());
//日志设置帮助调试问题,请在发布应用程序之前删除。
OneSignal.setLogLevel(OneSignal.LOG_LEVEL.DEBUG,OneSignal.LOG_LEVEL.WARN);
OneSignal.startInit(这个)
.setNotificationOpenedHandler(新示例NotificationOpenedHandler())
.SetAutoPrompLocation(真)
.init();
CalligraphyConfig.initDefault(新的CalligraphyConfig.Builder()
.setDefaultFontPath(“fonts/Roboto Regular.ttf”)
.setFontAttrId(R.attr.fontPath)
.build()
);
}
公共静态同步测试应用程序getInstance()
{
if(minInstance==null)
{
MinInstance=新约应用程序();
}
回报率;
}
公共请求队列getRequestQueue(上下文)
{
if(mRequestQueue==null)
{
mRequestQueue=Volley.newRequestQueue(上下文);
}
返回mrequest队列;
}
public void addToRequestQueue(请求、字符串标记、上下文)
{
request.setTag(TextUtils.isEmpty(tag)?tag:tag;
request.setShouldCache(false);
getRequestQueue(上下文).add(请求);
}
public void addToRequestQueue(请求、上下文)
{
request.setTag(TAG);
getRequestQueue(上下文).add(请求);
}
公共作废取消挂起请求(对象标记)
{
if(mRequestQueue!=null)
{
mRequestQueue.cancelAll(标记);
}
}
@凌驾
受保护的void attachBaseContext(上下文基){
super.attachBaseContext(base);
多索引安装(本);
}
私有类ExampleNotificationOpenedHandler实现一个信号。NotificationOpenedHandler{
/**
*在应用程序中实现回调,以便在从Android状态栏或
*应用程序运行时会出现一个新的应用程序。
*此方法位于此应用程序类中。例如,您可以使用任何希望实现NotificationOpenedHandler并定义此方法的类。
*
*@param message用户在Android状态栏中看到/应该看到的消息字符串。
*@param additionalData您在onesignal.com上输入的additionalData键值对部分。
*@param isActive是收到通知时前台的应用程序。
*/
@凌驾
公共void通知已打开(字符串消息、JSONObject附加数据、布尔isActive){
字符串additionalMessage=“”;
试一试{
如果(附加数据!=null){
if(附加数据.has(“本”)){
additionalMessage=additionalData.getString(“this”);
if(additionalMessage.toString().trim().equalsIgnoreCase(“x”)){
Intent newIntent=newIntent(“com.test.push”);//这必须与您的意图过滤器匹配
newIntent.putExtra(“功能推送”、“x”);
newIntent.setFlags(Intent.FLAG\u活动\u新任务);
星触觉(新意图);
}
else if(additionalMessage.toString().trim().equalsIgnoreCase(“y”)){
Intent newIntent=newIntent(“com.test.push”);//这必须与您的意图过滤器匹配
newIntent.putExtra(“功能推送”、“y”);
newIntent.setFlags(Intent.FLAG\u活动\u新任务);
星触觉(新意图);
}
}
}
}捕获(可丢弃的t){
t、 printStackTrace();
}
}
}
公共ImageLoader getImageLoader(){
返回图像加载器;
}
}

您可以通过support.annotation对要继续使用的类或方法进行注释。

将源代码发布到
com.boulevard.Utilities.boulevard应用程序中。其中有些东西是您的困难的根源。在@commonwarehmmmm上面添加了应用程序类代码。。。您可以尝试删除构造函数并将singleton
mInstance=this
移动到
attachBaseContext()
。如果这没有帮助——我也不认为会有帮助——您将需要使用ProGuard工具对堆栈跟踪进行去模糊处理,以查看
com.e.pi
是什么。是的,我尝试过移动构造函数,但没有什么不同。我如何使用ProGuard工具来实现这一点?我不熟悉那个@CommonsWareBeats我。我一开始从不使用模糊处理。