0

I'm trying to test the app in release mode before uploading to Google Play Store but I'm getting an error like

"E/AsyncHttpRequest: Unhandled exception origin cause java.lang.ClassCastException: $Proxy0 cannot be cast to d.a.a.a.k.h".

If anyone faces this same problem and found out the solution then let me know, Thanks. In debug mode, it works fine but in release mode, I'm getting error

Earlier it was working in release mode too but now it is not working in release mode

phoneNo = phoneText.getText().toString();
            System.out.println( phoneNo );
            params.put( "mob_no", phoneNo );
            //String debugHashKey = "Yq%2BZIxNoG%2BK";
            String releaseHashKey = "hFmVMD4X1DR";
            System.out.println( releaseHashKey );
            params.put( "uniqueKey", releaseHashKey );
            try {
                asyncHttpClient.post( mob_validate, params, new JsonHttpResponseHandler() {
                    @Override
                    public void onSuccess(int statusCode, Header[] headers, JSONObject response) {
                        try {
                            System.out.println( "onSuccess" );
                            status = response.getString( "status" );
                            msg = response.getString( "msg" );
                            Toast.makeText( getApplicationContext(), msg, Toast.LENGTH_SHORT ).show();
                            if (status.equals( "success" )) {
                                Intent intent = new Intent( MainActivity.this, OTPConfirmationActivity.class );
                                intent.putExtra( "phone_no", phoneNo );
                                startActivity( intent );
                                finish();
                            }
                        } catch (JSONException e) {
                            e.printStackTrace();
                        }
                    }

                    @Override
                    public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) {
                        //Toast.makeText( getApplicationContext(), R.string.onFailure, Toast.LENGTH_SHORT ).show();
                    }

                    @Override
                    public void onFailure(int statusCode, Header[] headers, String responseString, Throwable throwable) {
                        super.onFailure( statusCode, headers, responseString, throwable );
                    }

                    @Override
                    public void onStart() {
                        progressBar.setVisibility( View.VISIBLE );
                    }

                    @Override
                    public void onFinish() {
                        progressBar.setVisibility( View.INVISIBLE );
                    }
                } );
            } catch (ClassCastException e) {
                e.printStackTrace();
            }


/////////////////build.gradle file//////////////////////

apply plugin: 'com.android.application'

android {
    signingConfigs {
        release {
            storeFile file('/home/eazysoft/Documents/finalKey/releaseKey.jks')
            storePassword 'password'
            keyAlias = 'upload'
            keyPassword 'password'
        }
    }
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.eazysoft.lookAround"
        minSdkVersion 15
        targetSdkVersion 28
        versionCode 2
        versionName "1.0.1"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        multiDexEnabled true
        signingConfig signingConfigs.release
    }
    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
            signingConfig signingConfigs.release
            debuggable = true
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support:support-v4:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:2.0.0-alpha4'
    testImplementation 'junit:junit:4.13-beta-2'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'

    implementation 'com.android.support:design:28.0.0'
    implementation 'com.android.support:multidex:1.0.3'
    implementation 'com.android.support:recyclerview-v7:28.0.0'
    implementation 'com.android.support:cardview-v7:28.0.0'
    implementation 'com.android.support:design:28.0.0'
    implementation 'com.android.support:exifinterface:28.0.0'

    implementation 'com.google.android.gms:play-services-maps:16.1.0'
    implementation 'com.google.android.gms:play-services-location:16.0.0'
    implementation 'com.google.android.gms:play-services-base:16.1.0'
    implementation 'com.google.android.gms:play-services-identity:16.0.0'
    implementation 'com.google.android.gms:play-services-auth:16.0.1'
    implementation 'com.google.android.gms:play-services-auth-api-phone:16.0.0'

    implementation 'com.loopj.android:android-async-http:1.4.9'
}

Please provide me the solution that works with Sms Retriever API so that I can upload my app to play store.

Jaroslav
  • 724
  • 4
  • 17
Rohan
  • 96
  • 8
  • you need to set up your ProGuard – budgie Apr 29 '19 at 09:44
  • How can I achieve that can you elaborate. – Rohan Apr 29 '19 at 09:50
  • just try to run the app `minifyEnabled false`. after you'll be sure that the app works with this option, change it back to `true` and go through the guide on Android Developers: https://developer.android.com/studio/build/shrink-code – budgie Apr 29 '19 at 09:54
  • Thanks for the help it works like butter but I have another problem when I uploaded my app to play store automatically msg reading stop working, please help – Rohan Apr 29 '19 at 11:03

1 Answers1

0

Update your release block in app level gradle:

release {
   minifyEnabled true
   useProguard true
   proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'

}

proguard-android.txt is generated automatically when you create your project. Open the file and add these rules in it.

-keep class cz.msebera.android.httpclient.** { *; }
-keep class com.loopj.android.http.** { *; }
Ahsan
  • 131
  • 2
  • 3