Monacaでアプリを開発しようとしています。
初歩的なことと思われ申し訳ありません。
●発生している問題
Androidデバッグビルドをして実機にインストールした際に、外部サーバに保管している画像(http://やhttps://で取得するもの)が表示されずに困っています。
ただし、クラウドIDEのプレビュー、Monacaデバッガーアプリを実機にインストールしたもの、またiOSではデバッグビルドでも問題なく画像が表示されていますので、Androidのビルドに関連した「ホワイトリスト」??などの初期設定だと思うのですが・・・。
●調べたこと
https://docs.monaca.io/ja/reference/cordova_9.0/whitelist/
を参照。
①Content-Security-Policyの設定? デフォルトではだめ??
②config.xml の設定? 下記の2つではだめ??
<allow-navigation href="*"/>
<access origin="*"/>
●コード
使用しているMonacaのテンプレートは、Javascript + OnsenUI2です。
「index.html」に追加したコードは、<body>部分のみで、その他はデフォルトです。
<!DOCTYPE HTML> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no, viewport-fit=cover"> <meta http-equiv="Content-Security-Policy" content="default-src * data: gap: https://ssl.gstatic.com; style-src * 'unsafe-inline'; script-src * 'unsafe-inline' 'unsafe-eval'"> <script src="components/loader.js"></script> <script src="lib/onsenui/js/onsenui.min.js"></script> <link rel="stylesheet" href="components/loader.css"> <link rel="stylesheet" href="lib/onsenui/css/onsenui.css"> <link rel="stylesheet" href="lib/onsenui/css/onsen-css-components.css"> <link rel="stylesheet" href="css/style.css"> <script> ons.ready(function() { console.log("Onsen UI is ready!"); }); if (ons.platform.isIPhoneX()) { document.documentElement.setAttribute('onsflag-iphonex-portrait', ''); document.documentElement.setAttribute('onsflag-iphonex-landscape', ''); } </script> </head> <body> <p><img src="http://xxxx.jp/uploads/photo_001.jpg" width="50%"></p> ↑http(表示されない) <p><img src="https://xxxx.jp/uploads/photo_001.jpg" width="50%"></p> ↑https(表示されない) </body> </html>
「config.xml」 こちらもデフォルトのままですが、2行目のidのみ伏せています。実際には正しく設定しています。
<?xml version="1.0" encoding="UTF-8"?> <widget xmlns="http://www.w3.org/ns/widgets" id="jp.xxxxx" version="1.0.0"> <name>Minimum Template</name> <description>Made with Monaca (http://monaca.mobi)</description> <author/> <content src="index.html"/> <allow-navigation href="*"/> <allow-intent href="itms:*"/> <allow-intent href="itms-apps:*"/> <preference name="Orientation" value="default"/> <preference name="loglevel" value="DEBUG"/> <preference name="AndroidLaunchMode" value="singleTop"/> <preference name="ErrorUrl" value=""/> <preference name="Fullscreen" value="false"/> <preference name="KeepRunning" value="true"/> <preference name="SplashScreen" value="screen"/> <preference name="SplashScreenDelay" value="1000"/> <preference name="AllowInlineMediaPlayback" value="false"/> <preference name="BackupWebStorage" value="cloud"/> <preference name="FadeSplashScreenDuration" value="250"/> <preference name="KeyboardDisplayRequiresUserAction" value="true"/> <preference name="MediaPlaybackRequiresUserAction" value="false"/> <preference name="SuppressesIncrementalRendering" value="false"/> <preference name="TopActivityIndicator" value="gray"/> <preference name="GapBetweenPages" value="0"/> <preference name="PageLength" value="0"/> <preference name="PaginationBreakingMode" value="page"/> <preference name="PaginationMode" value="unpaginated"/> <feature name="LocalStorage"> <param name="ios-package" value="CDVLocalStorage"/> </feature> <preference name="UIWebViewDecelerationSpeed" value="normal"/> <preference name="monaca:AndroidIsPackageNameSeparate" value="false"/> <platform name="ios"> <splash src="/res/ios/screen/Default@2x~universal~anyany.png"/> <icon src="/res/ios/icon/icon.png" width="57" height="57"/> <icon src="/res/ios/icon/icon@2x.png" width="114" height="114"/> <icon src="/res/ios/icon/icon-72.png" width="72" height="72"/> <icon src="/res/ios/icon/icon-72@2x.png" width="144" height="144"/> <icon src="/res/ios/icon/icon-60.png" width="60" height="60"/> <icon src="/res/ios/icon/icon-60@2x.png" width="120" height="120"/> <icon src="/res/ios/icon/icon-60@3x.png" width="180" height="180"/> <icon src="/res/ios/icon/icon-76.png" width="76" height="76"/> <icon src="/res/ios/icon/icon-76@2x.png" width="152" height="152"/> <icon src="/res/ios/icon/icon-40.png" width="40" height="40"/> <icon src="/res/ios/icon/icon-40@2x.png" width="80" height="80"/> <icon src="/res/ios/icon/icon-50.png" width="50" height="50"/> <icon src="/res/ios/icon/icon-50@2x.png" width="100" height="100"/> <icon src="/res/ios/icon/icon-small.png" width="29" height="29"/> <icon src="/res/ios/icon/icon-small@2x.png" width="58" height="58"/> <icon src="/res/ios/icon/icon-small@3x.png" width="87" height="87"/> <icon src="/res/ios/icon/icon-83.5@2x~ipad.png" width="167" height="167"/> <icon src="/res/ios/icon/icon-1024.png" width="1024" height="1024"/> <config-file platform="ios" parent="CFBundleLocalizations" target="*-Info.plist"> <array> <string>en</string> </array> </config-file> </platform> <platform name="android"> <icon src="/res/android/icon/ldpi.png" density="ldpi"/> <icon src="/res/android/icon/mdpi.png" density="mdpi"/> <icon src="/res/android/icon/hdpi.png" density="hdpi"/> <icon src="/res/android/icon/xhdpi.png" density="xhdpi"/> <icon src="/res/android/icon/xxhdpi.png" density="xxhdpi"/> <icon src="/res/android/icon/xxxhdpi.png" density="xxxhdpi"/> <splash src="/res/android/screen/splash-port-ldpi.9.png" density="port-ldpi"/> <splash src="/res/android/screen/splash-port-mdpi.9.png" density="port-mdpi"/> <splash src="/res/android/screen/splash-port-hdpi.9.png" density="port-hdpi"/> <splash src="/res/android/screen/splash-port-xhdpi.9.png" density="port-xhdpi"/> <splash src="/res/android/screen/splash-port-xxhdpi.9.png" density="port-xxhdpi"/> <splash src="/res/android/screen/splash-port-xxxhdpi.9.png" density="port-xxxhdpi"/> <splash src="/res/android/screen/splash-mdpi.png" density="mdpi"/> </platform> <platform name="electron"> <icon src="/res/electron/icon/icon_electron_512.png" width="512" height="512"/> <splash src="/res/electron/screen/electron_splash_image.png" width="620" height="300"/> <preference name="SplashScreenWidth" value="620"/> <preference name="SplashScreenHeight" value="300"/> </platform> <preference name="WindowsStorePublisherName" value="My Name"/> <preference name="WindowsStoreIdentityName" value="12aaccc0-707c-4b4e-088c-106db6be91ac"/> <preference name="ios-XCBuildConfiguration-TARGETED_DEVICE_FAMILY" value="1,2"/> <preference name="AutoHideSplashScreen" value="true"/> <preference name="FadeSplashScreen" value="true"/> <preference name="ShowSplashScreenSpinner" value="false"/> <access origin="*"/> <preference name="DisallowOverscroll" value="true"/> <preference name="EnableViewportScale" value="false"/> </widget>
あなたの回答
tips
プレビュー