How can I run app in release mode using sms retriever api and upload to the google app store

348 Views Asked by At

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.

1

There are 1 best solutions below

1
Ahsan On

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.** { *; }