I’m struggling in making my app work on Android APK release, the only scenario it fails is at generating and signing the apk. All http requests doesn’t work. (The server is running under SSL)
All Scenarios I’ve tried already:
-
ionic serve
-> Works fine. -
ionic cordova run android
--device -> Works fine. - Works on emulators as well.
Also works fine generating the iOS build:
-
ionic cordova build ios
. -
ionic cordova run ios --device
. - On Xcode, running build targeting a real device.
- On Xcode, archiving and uploading it to Itunesconnect then downloading it from AppStore once it’s accepted by Apple.
So, the only case it doesn’t work is when I try to generate it’s apk through ionic cordova build android --prod --release
and signing it.
Google Play also accepts the new APK, so there’s no problem with the package sign at all.
Since it works on iOS and running directly on android device, it isn’t a CORS or HTTPS certificate problem.
The code:
snippet of login.ts:
this.userService.loginUser(this.user).then(
(data) => {
let response = data.json();
loading.dismiss().then(loadData => {
if (response.access_token) {
this.global.access_token = response.access_token;
this.getUserData();
}
});
}, err => {
let error = err.json();
loading.dismiss().then(response => {
if (error.message) {
this.showToast(error.message, 3000, 'bottom');
}
});
}
);
userService.loginUser method:
loginUser(data) {
let headers = new Headers();
headers.append('Access-Control-Allow-Origin', '*');
headers.append('auth-token', '*');
return this.abs.post('/authenticateMobile',
{
login_ds_email: data.email,
login_ds_password: data.pass
}, headers);
}
Where abs
is:
constructor(http) {
this.abs = new ApiService(http);
}
ApiService.post method:
public post(api, params, header): any {
if (!header) {
header = this.getHeaders();
}
let options = new RequestOptions({headers: header});
let url = this.global.urlGlobal + api;
return this.http.post(url, params, options).toPromise();
}
The App gets stuck when I fire “login” button and the request is made. There’s no exception thrown by the server, so the loading screen is shown forever.
I’ve running out of solutions for this and I hope you guys can help me out.
Ionic info:
global packages:
@ionic/cli-utils : 1.4.0
Cordova CLI : 6.4.0
Gulp CLI : CLI version 3.9.1 Local version 3.9.1
Ionic CLI : 3.4.0
local packages:
@ionic/app-scripts : 1.3.0
@ionic/cli-plugin-cordova : 1.4.0
@ionic/cli-plugin-gulp : 1.0.1
@ionic/cli-plugin-ionic-angular : 1.3.1
Cordova Platforms : android 6.0.0 ios 4.3.1
Ionic Framework : ionic-angular 3.0.1
System:
Node : v7.8.0
OS : macOS Sierra
Xcode : Xcode 8.3.3 Build version 8E3004b
ios-deploy : 1.9.0
ios-sim : 5.0.6
npm : 5.0.3