Weird problem release apk

The problem is when I generate the APK in release mode, the login in my app doesn’t work. But… I already done a lot of tests. And I found that the problem is when I change “Debuggable” to false. If I set it true, the app works like a charm.

The other problem is that I can’t upload a debuggable APK to Google Play.

That is not a problem, that is as it should be.

You should not need to do that.
You actually should not do anything in Android Studio. Why aren’t you building with Ionic CLI?

What is your ionic info output?

Yes, I always build with ionic CLI with this commands:
ionic cordova build android --release
ionic cordova build android --prod --release

I just was using Android Studio for testing purposes. Just to have more advanced options in the build steps.

I already tried with a new project, but in all my projects the HTTP or HTTPCLIENT requests in debug mode work propperly. When I change to build a release APK the HTTP or HTTPCLIENT requests don’t return anything. (It’s the same code, same provider, etc for debug and release )

For example this is my provider’s function:

	search(path): Promise<any> {
        alert("First");
		return this.http.get(path)
			.map(res => res.json())
			.toPromise() 
			.then(
			response => { 
               alert("Response");
		       return response;
			},
			error => {  
                alert("Error");
				return null;
			});
	}

this is the code in my page.ts:

this.apiprovider.search(path).then(res => {
   alert("Received");
   //code
});

Only the first alert (“First”) is shown, the “Received” alert not.

I already tried with Observables, Http and HttpClient. But same problem. If it’s in debug mode works fine, but if I build a release the requests doesn’t work.

My ionic info is:

cli packages: (C:\Users\admin\AppData\Roaming\npm\node_modules)

    @ionic/cli-utils  : 1.13.1
    ionic (Ionic CLI) : 3.13.2

global packages:

    cordova (Cordova CLI) : 7.0.1

local packages:

    @ionic/app-scripts : 2.1.4
    Cordova Platforms  : android 6.2.3
    Ionic Framework    : ionic-angular 3.6.0

System:

    Node : v8.5.0
    npm  : 5.3.0
    OS   : Windows 10

Misc:

    backend : pro

Solution:

The site where I have my rest api, didn’t have a valid SSL certificate. I think HTTP and HTTPClient validates the url in release mode. I update my SSL and it worked

2 Likes

Yep, --release turns that on. Shame there is no real feedback about it :confused: