2016-11-30 1 views
0

von meiner App Ich verweise auf externe API, um Daten zu erhalten. auf Browser und Build-Version funktioniert alles gut, aber auf Emulator-Anfrage werden abgelehnt. auf tatsächlichen Gerät App funktioniert gut. zum Debuggen muss ich auf Emulator testen, aber ich bekomme diesen Fehler. Ich habe jeden Artikel geprüft, konnte aber keine Lösung finden. hier ist meine KonfigurationIonic Android Emulator Ausgabe

IONIC INFO

Cordova CLI: 6.4.0 
Ionic CLI Version: 2.1.4 
Ionic App Lib Version: 2.1.2 
OS: Distributor ID: Ubuntu Description: Ubuntu 15.10 
Node Version: v6.3.1 

Config.XML

<?xml version="1.0" encoding="UTF-8" standalone="yes"?> 
<widget id="com.ionicframework.freemusic372670" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0"> 
    <name> 
     FreeMusic 
    </name> 
    <description> 
     An Ionic Framework and Cordova project. 
    </description> 
    <author email="[email protected]" href="http://example.com.com/"> 
     Your Name Here 
    </author> 
    <access origin="*"/> 
    <allow-intent href="*"/> 
    <allow-navigation href="http://*/*"/> 
    <allow-navigation href="https://*/*"/> 
    <allow-navigation href="data:*"/> 
    <allow-navigation href="http://10.11.11.127:8100"/> 
    <allow-navigation href="http://10.11.11.127:8101"/> 
    <allow-navigation href="http://192.168.42.87:8100"/> 
    <content src="index.html"/> 
    <preference name="webviewbounce" value="false"/> 
    <preference name="UIWebViewBounce" value="false"/> 
    <preference name="DisallowOverscroll" value="true"/> 
    <preference name="SplashScreenDelay" value="2000"/> 
    <preference name="FadeSplashScreenDuration" value="2000"/> 
    <preference name="android-minSdkVersion" value="16"/> 
    <preference name="BackupWebStorage" value="none"/> 
    <preference name="SplashScreen" value="screen"/> 
    <feature name="StatusBar"> 
    <param name="ios-package" onload="true" value="CDVStatusBar"/> 
    </feature> 
    <plugin name="cordova-plugin-device" spec="~1.1.3"/> 
    <plugin name="cordova-plugin-console" spec="~1.0.4"/> 
    <plugin name="cordova-plugin-whitelist" spec="~1.3.0"/> 
    <plugin name="cordova-plugin-splashscreen" spec="~4.0.0"/> 
    <plugin name="cordova-plugin-statusbar" spec="~2.2.0"/> 
    <plugin name="ionic-plugin-keyboard" spec="~2.2.1"/> 
    <platform name="android"> 
    <icon src="resources/android/icon/drawable-ldpi-icon.png" density="ldpi"/> 
    <icon src="resources/android/icon/drawable-mdpi-icon.png" density="mdpi"/> 
    <icon src="resources/android/icon/drawable-hdpi-icon.png" density="hdpi"/> 
    <icon src="resources/android/icon/drawable-xhdpi-icon.png" density="xhdpi"/> 
    <icon src="resources/android/icon/drawable-xxhdpi-icon.png" density="xxhdpi"/> 
    <icon src="resources/android/icon/drawable-xxxhdpi-icon.png" density="xxxhdpi"/> 
    <splash src="resources/android/splash/drawable-land-ldpi-screen.png" density="land-ldpi"/> 
    <splash src="resources/android/splash/drawable-land-mdpi-screen.png" density="land-mdpi"/> 
    <splash src="resources/android/splash/drawable-land-hdpi-screen.png" density="land-hdpi"/> 
    <splash src="resources/android/splash/drawable-land-xhdpi-screen.png" density="land-xhdpi"/> 
    <splash src="resources/android/splash/drawable-land-xxhdpi-screen.png" density="land-xxhdpi"/> 
    <splash src="resources/android/splash/drawable-land-xxxhdpi-screen.png" density="land-xxxhdpi"/> 
    <splash src="resources/android/splash/drawable-port-ldpi-screen.png" density="port-ldpi"/> 
    <splash src="resources/android/splash/drawable-port-mdpi-screen.png" density="port-mdpi"/> 
    <splash src="resources/android/splash/drawable-port-hdpi-screen.png" density="port-hdpi"/> 
    <splash src="resources/android/splash/drawable-port-xhdpi-screen.png" density="port-xhdpi"/> 
    <splash src="resources/android/splash/drawable-port-xxhdpi-screen.png" density="port-xxhdpi"/> 
    <splash src="resources/android/splash/drawable-port-xxxhdpi-screen.png" density="port-xxxhdpi"/> 
    </platform> 
</widget> 

META HEADER in index.html

<meta http-equiv="Content-Security-Policy" content="default-src *; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval'"> 

PLUGINS

cordova-plugin-whitelist 

ERROR

{"data":null,"status":-1,"config":{"method":"GET","transformRequest":[null],"transformResponse":[null],"url":"http://databrainz.com/api/search_api.cgi?qry=metallica&format=json&mh=50&where=mpl","headers":{"Accept":"application/json, text/plain, */*"}},"statusText":""} 

Logcat ERROR

11-30 11:51:50.971 3179-3179/com.ionicframework.freemusic372670 D/SystemWebChromeClient: http://10.11.11.127:8100/#/tab/dash: Line 0 : XMLHttpRequest cannot load http://databrainz.com/api/search_api.cgi?qry=metallica&format=json&mh=50&where=mpl. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://10.11.11.127:8100' is therefore not allowed access. 

Antwort

0

Sie CORS von Ihrem Webserver aktivieren. Ihr Fehler hat folgendes erwähnt:

…No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://10.11.11.127:8100' is therefore not allowed access.… 
+0

ich laufe mit ionic run android -l -c. Irgendwelche Ideen, wie man es dort aktivieren kann? – user2513301

+0

Sie müssen es auf Ihrer Webserver-Konfiguration (Apache oder Nginx) aktivieren, nicht auf Ihrem Gerät. – RWAM