How To Fix API cannot connect to Online Web Hosting
I'm making a car rental application on Android Studio, initially I entered the API on localhost XAMPP and this work. After I move to hosting online, and I point to the hosting address. Can't connect.
public class client {
private static final String URL="https://ssrentalmobil.000webhostapp.com/rental-api/";
private static final String URL_IMAGE="https://ssrentalmobil.000webhostapp.com/rental-api/upload/avatars/";
private static final String URL_IMG="https://ssrentalmobil.000webhostapp.com/rental-api/upload/";
public static request getApi() {
//Builder Retrofit
Retrofit retrofit = new Retrofit.Builder()
.baseUrl(URL)
.addConverterFactory(GsonConverterFactory.create())
.build();
return retrofit.create(request.class);
}
public static String getBaseUrlImage() {
return URL_IMAGE;
}
public static String getBaseImg() {
return URL_IMG;
}
}
android api android-studio web-hosting
New contributor
add a comment |
I'm making a car rental application on Android Studio, initially I entered the API on localhost XAMPP and this work. After I move to hosting online, and I point to the hosting address. Can't connect.
public class client {
private static final String URL="https://ssrentalmobil.000webhostapp.com/rental-api/";
private static final String URL_IMAGE="https://ssrentalmobil.000webhostapp.com/rental-api/upload/avatars/";
private static final String URL_IMG="https://ssrentalmobil.000webhostapp.com/rental-api/upload/";
public static request getApi() {
//Builder Retrofit
Retrofit retrofit = new Retrofit.Builder()
.baseUrl(URL)
.addConverterFactory(GsonConverterFactory.create())
.build();
return retrofit.create(request.class);
}
public static String getBaseUrlImage() {
return URL_IMAGE;
}
public static String getBaseImg() {
return URL_IMG;
}
}
android api android-studio web-hosting
New contributor
What error you get
– maytham-ɯɐɥʇʎɐɯ
Dec 27 '18 at 15:37
moving you api code is not enough you need to move the database also outside your local environment, and checking if you hosting service approve the ip addresses, any firewall rules, it's not an android problem if it works locally it"s server side issue
– Oussema Aroua
Dec 27 '18 at 15:45
As mentioned by others, there are multiple variables that can contribute to the problem. For starters, you need to supply the error log as there might be a response code hidden which is received from the server. That response code will indicate as to if the communication is successful or not.
– Nero
Dec 27 '18 at 15:55
I have moved the database and set it up in hosting online. When I run in the browser it work. But when im run this android app it's don't work. There is no connection
– Fajar Syairillah
Dec 27 '18 at 16:34
add a comment |
I'm making a car rental application on Android Studio, initially I entered the API on localhost XAMPP and this work. After I move to hosting online, and I point to the hosting address. Can't connect.
public class client {
private static final String URL="https://ssrentalmobil.000webhostapp.com/rental-api/";
private static final String URL_IMAGE="https://ssrentalmobil.000webhostapp.com/rental-api/upload/avatars/";
private static final String URL_IMG="https://ssrentalmobil.000webhostapp.com/rental-api/upload/";
public static request getApi() {
//Builder Retrofit
Retrofit retrofit = new Retrofit.Builder()
.baseUrl(URL)
.addConverterFactory(GsonConverterFactory.create())
.build();
return retrofit.create(request.class);
}
public static String getBaseUrlImage() {
return URL_IMAGE;
}
public static String getBaseImg() {
return URL_IMG;
}
}
android api android-studio web-hosting
New contributor
I'm making a car rental application on Android Studio, initially I entered the API on localhost XAMPP and this work. After I move to hosting online, and I point to the hosting address. Can't connect.
public class client {
private static final String URL="https://ssrentalmobil.000webhostapp.com/rental-api/";
private static final String URL_IMAGE="https://ssrentalmobil.000webhostapp.com/rental-api/upload/avatars/";
private static final String URL_IMG="https://ssrentalmobil.000webhostapp.com/rental-api/upload/";
public static request getApi() {
//Builder Retrofit
Retrofit retrofit = new Retrofit.Builder()
.baseUrl(URL)
.addConverterFactory(GsonConverterFactory.create())
.build();
return retrofit.create(request.class);
}
public static String getBaseUrlImage() {
return URL_IMAGE;
}
public static String getBaseImg() {
return URL_IMG;
}
}
android api android-studio web-hosting
android api android-studio web-hosting
New contributor
New contributor
New contributor
asked Dec 27 '18 at 15:33
Fajar Syairillah
12
12
New contributor
New contributor
What error you get
– maytham-ɯɐɥʇʎɐɯ
Dec 27 '18 at 15:37
moving you api code is not enough you need to move the database also outside your local environment, and checking if you hosting service approve the ip addresses, any firewall rules, it's not an android problem if it works locally it"s server side issue
– Oussema Aroua
Dec 27 '18 at 15:45
As mentioned by others, there are multiple variables that can contribute to the problem. For starters, you need to supply the error log as there might be a response code hidden which is received from the server. That response code will indicate as to if the communication is successful or not.
– Nero
Dec 27 '18 at 15:55
I have moved the database and set it up in hosting online. When I run in the browser it work. But when im run this android app it's don't work. There is no connection
– Fajar Syairillah
Dec 27 '18 at 16:34
add a comment |
What error you get
– maytham-ɯɐɥʇʎɐɯ
Dec 27 '18 at 15:37
moving you api code is not enough you need to move the database also outside your local environment, and checking if you hosting service approve the ip addresses, any firewall rules, it's not an android problem if it works locally it"s server side issue
– Oussema Aroua
Dec 27 '18 at 15:45
As mentioned by others, there are multiple variables that can contribute to the problem. For starters, you need to supply the error log as there might be a response code hidden which is received from the server. That response code will indicate as to if the communication is successful or not.
– Nero
Dec 27 '18 at 15:55
I have moved the database and set it up in hosting online. When I run in the browser it work. But when im run this android app it's don't work. There is no connection
– Fajar Syairillah
Dec 27 '18 at 16:34
What error you get
– maytham-ɯɐɥʇʎɐɯ
Dec 27 '18 at 15:37
What error you get
– maytham-ɯɐɥʇʎɐɯ
Dec 27 '18 at 15:37
moving you api code is not enough you need to move the database also outside your local environment, and checking if you hosting service approve the ip addresses, any firewall rules, it's not an android problem if it works locally it"s server side issue
– Oussema Aroua
Dec 27 '18 at 15:45
moving you api code is not enough you need to move the database also outside your local environment, and checking if you hosting service approve the ip addresses, any firewall rules, it's not an android problem if it works locally it"s server side issue
– Oussema Aroua
Dec 27 '18 at 15:45
As mentioned by others, there are multiple variables that can contribute to the problem. For starters, you need to supply the error log as there might be a response code hidden which is received from the server. That response code will indicate as to if the communication is successful or not.
– Nero
Dec 27 '18 at 15:55
As mentioned by others, there are multiple variables that can contribute to the problem. For starters, you need to supply the error log as there might be a response code hidden which is received from the server. That response code will indicate as to if the communication is successful or not.
– Nero
Dec 27 '18 at 15:55
I have moved the database and set it up in hosting online. When I run in the browser it work. But when im run this android app it's don't work. There is no connection
– Fajar Syairillah
Dec 27 '18 at 16:34
I have moved the database and set it up in hosting online. When I run in the browser it work. But when im run this android app it's don't work. There is no connection
– Fajar Syairillah
Dec 27 '18 at 16:34
add a comment |
1 Answer
1
active
oldest
votes
Make sure you've added the permission.
If not, add this line
<uses-permission android:name="android.permission.INTERNET" />
in your AndroidManifest.xml
Check the doc for more details
If it didn't help, try adding a logging interceptor and check the log
I have done permission Internet in manifest
– Fajar Syairillah
Dec 27 '18 at 16:28
Please check the update
– Anees
Dec 27 '18 at 16:32
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Fajar Syairillah is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53947393%2fhow-to-fix-api-cannot-connect-to-online-web-hosting%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Make sure you've added the permission.
If not, add this line
<uses-permission android:name="android.permission.INTERNET" />
in your AndroidManifest.xml
Check the doc for more details
If it didn't help, try adding a logging interceptor and check the log
I have done permission Internet in manifest
– Fajar Syairillah
Dec 27 '18 at 16:28
Please check the update
– Anees
Dec 27 '18 at 16:32
add a comment |
Make sure you've added the permission.
If not, add this line
<uses-permission android:name="android.permission.INTERNET" />
in your AndroidManifest.xml
Check the doc for more details
If it didn't help, try adding a logging interceptor and check the log
I have done permission Internet in manifest
– Fajar Syairillah
Dec 27 '18 at 16:28
Please check the update
– Anees
Dec 27 '18 at 16:32
add a comment |
Make sure you've added the permission.
If not, add this line
<uses-permission android:name="android.permission.INTERNET" />
in your AndroidManifest.xml
Check the doc for more details
If it didn't help, try adding a logging interceptor and check the log
Make sure you've added the permission.
If not, add this line
<uses-permission android:name="android.permission.INTERNET" />
in your AndroidManifest.xml
Check the doc for more details
If it didn't help, try adding a logging interceptor and check the log
edited Dec 27 '18 at 16:32
answered Dec 27 '18 at 15:56
Anees
4,23841045
4,23841045
I have done permission Internet in manifest
– Fajar Syairillah
Dec 27 '18 at 16:28
Please check the update
– Anees
Dec 27 '18 at 16:32
add a comment |
I have done permission Internet in manifest
– Fajar Syairillah
Dec 27 '18 at 16:28
Please check the update
– Anees
Dec 27 '18 at 16:32
I have done permission Internet in manifest
– Fajar Syairillah
Dec 27 '18 at 16:28
I have done permission Internet in manifest
– Fajar Syairillah
Dec 27 '18 at 16:28
Please check the update
– Anees
Dec 27 '18 at 16:32
Please check the update
– Anees
Dec 27 '18 at 16:32
add a comment |
Fajar Syairillah is a new contributor. Be nice, and check out our Code of Conduct.
Fajar Syairillah is a new contributor. Be nice, and check out our Code of Conduct.
Fajar Syairillah is a new contributor. Be nice, and check out our Code of Conduct.
Fajar Syairillah is a new contributor. Be nice, and check out our Code of Conduct.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53947393%2fhow-to-fix-api-cannot-connect-to-online-web-hosting%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
What error you get
– maytham-ɯɐɥʇʎɐɯ
Dec 27 '18 at 15:37
moving you api code is not enough you need to move the database also outside your local environment, and checking if you hosting service approve the ip addresses, any firewall rules, it's not an android problem if it works locally it"s server side issue
– Oussema Aroua
Dec 27 '18 at 15:45
As mentioned by others, there are multiple variables that can contribute to the problem. For starters, you need to supply the error log as there might be a response code hidden which is received from the server. That response code will indicate as to if the communication is successful or not.
– Nero
Dec 27 '18 at 15:55
I have moved the database and set it up in hosting online. When I run in the browser it work. But when im run this android app it's don't work. There is no connection
– Fajar Syairillah
Dec 27 '18 at 16:34