응용 프로그램 오류-서버 연결에 실패했습니다. (file : ///android_asset/www/index.html)
시작시 앱이 종료 됨 (서버에 연결하지 못했습니다)
PhoneGap BUILD를 사용하여 작성하는 Android 애플리케이션이 있습니다. 앱이 이전에는 정상적으로 작동했지만 이제는 앱을 수정 한 후이 오류가 발생하는 것 같습니다 (일부 UI 변경 만 해당)
1) 앱을 시작할 때 (보통) 다음을 얻습니다.
응용 프로그램 오류-서버 연결에 실패했습니다. (file : ///android_asset/www/index.html)
질문이 중복되어 죄송합니다. 나는 비슷한 질문을 보았지만 완벽한 대답이나 해결책을 찾지 못했습니다. 내 경우와 마찬가지로 마지막 변경 때까지 정상적으로 작동했습니다.
당신이 말했듯이, 같은 주제에 대해 많은 중복 질문이 있습니다. 상황을 설명하는 방법.
index.html을 호출하기 위해 시간 초과를 추가하면 문제가 해결 될 수 있습니다.
즉, 다음 super.setIntegerProperty("loadUrlTimeoutValue", 70000);
줄 위에 activity.java 파일 (src / com / yourProj /-/ youractivity.java 내부) 을 추가해야합니다 .super.loadUrl("file:///android_asset/www/index.html");
설명:
다음과 같은 이유로 발생할 수 있습니다
핵심 이유 : 문제는 에뮬레이터의 속도로 인한 것일 수 있으므로 네트워크가 너무 느려 통신이 적시에 완료됩니다.
다음과 같은 이유로 발생할 수 있습니다.
- 코드 / 데이터 / 이미지의 크기가 너무 큽니다 (귀하의 경우 UI를 수정했다고 말했듯이 이미지 크기가 클 수 있습니다)
- 스크립트에 무한 루프 또는 긴 루프가있어로드하는 데 너무 많은 시간이 걸립니다.
- 너무 많은 스크립트를 사용하게 될 것입니다 (jQuery, iscroll 등. 더 많은 수의 플러그인 또는 스크립트)
config.xml 파일에서 다음 줄을 추가하십시오.
<preference name="loadUrlTimeoutValue" value="700000" />
작동하는 솔루션은 다음과 같습니다.
새 페이지를 만듭니다. main.html
예:
<!doctype html>
<html>
<head>
<title>tittle</title>
<script>
window.location='./index.html';
</script>
</head>
<body>
</body>
</html>
mainactivity.java에서 다음을 변경하십시오.
super.loadUrl("file:///android_asset/www/index.html");
에
super.loadUrl("file:///android_asset/www/main.html");
이제 응용 프로그램을 빌드하고 느린 연결에서 작동합니다
참조 .
참고 : 이것은 2013 년에 찾은 해결 방법입니다.
다음과 같은 원격으로 연결된 jQuery 파일을 제거하십시오. https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js
대신이 파일을 다운로드하여 로컬 js 폴더에서로드하여 URI를 만드십시오.
js/jquery.min.js
index.html에서 외부 스크립트를 제거하십시오.
이것을 변경하십시오 :
<script src="http://code.highcharts.com/highcharts-more.js"></script>
에
<script src="project_folder/highcharts-more.js"></script>
비슷한 문제가 있었고 위의 제안에 따라 "super.setIntegerProperty ("loadUrlTimeoutValue ", 70000);" 그러나 그것은 도움이되지 않았습니다. 그래서 Project-> Clean을 시도했는데 효과가 있었고 지금 앱을 시작할 수 있습니다!
아비 나시 ...
이 시도,
1. index.html의 이름을 "main.html"로 바꿉니다.
2. 새로운“index.html”을 만들고 다음 내용을 입력하십시오.
<!doctype html> <html> <head> <title>tittle</title> <script> window.location='./main.html'; </script> <body> </body> </html>
3. 앱을 다시 빌드하십시오! 더 이상 오류가 없습니다!
내 프로젝트에서도 마찬가지였습니다.
I tried " super.setIntegerProperty("loadUrlTimeoutValue", 70000); " but to no avail.
I ensured all files were linked properly [ CSS, JS files etc ], validated the HTML using w3c validator [ http://validator.w3.org/#validate_by_upload ] , and cleaned the project [ Project -> Clean ]
It now loads and executes without the same error.
Hope this helps
Extending loading Timeout Limit will not solve the problem which caused the error, it just will avoid the system to show the message but performance will be affected whatsoever.
Actual reason: You may be linking files or images to remote locations, and those resources are taking too long to load. (this is likely the most common error)
Definitive solution: move all the scripts, images and css needed to some local folders and load them locally ...
Performance will be increased and error will be effectively solved.
Check you index.html
file. If you use external resources, that not available when you run application then you can get this error.
In my case I forgot to delete link on debugger script (weinre).
<script src="http://192.168.0.102:8080/target/target-script-min.js#anonymous"></script>
So application worked on emulator because http://192.168.0.102:8080/
was on my localhost and available for emulator.
But when I setup application on mobile phone I had same error, because 192.168.0.102 was not available from mobile network.
fixing this on an ionic app, simply add
<preference name="loadUrlTimeoutValue" value="700000" />
to your config.xml file immediately after this line
<platform name="android">
In my case I am using ionic and I simply closed the dialog went to apps in the emulator and ran my app from there instead. This worked. I got the idea of that from here since it was just a time out issue.
If you are using visual studio. After changing config.xml sometimes you need this
clean build solution rebuild your app
It is working for me.
For my case, the problem was due to losing of the internet connection in my WiFi.
I was facing the same issue. I noticed that in my index i had both the "on device ready" and the "document.ready" function, so removing one of them fixed my problem :)
Another reason this error might occur is: there is no index.html
in .../YourApp/www/
!
I just followed the ionic guide, and one of the steps is:
$ rm www/index.html
On iOS this is no problem as during the build the compiler takes some default HTML instead. However, when building for android, NO example index.html
is used. Took me sometime to find out ("WHY does it work on iOS, but not on android...?)
Easy solution: create a index.html, save it under .../YourApp/www
, rebuild ...et voila!
'IT' 카테고리의 다른 글
속성과 속성의 차이점은 무엇입니까? (0) | 2020.06.10 |
---|---|
Homebrew로 수식을 업데이트하려면 어떻게합니까? (0) | 2020.06.10 |
Matplotlib tight_layout ()은 Figure Suptitle을 고려하지 않습니다. (0) | 2020.06.10 |
Entity Framework 롤백 및 잘못된 마이그레이션 제거 (0) | 2020.06.10 |
"long long"= "long long int"= "long int long"= "int long long"입니까? (0) | 2020.06.10 |