2

I'm developing a mobile application using Titanium web view, angularjs and mobile angular ui. I've create a mobile angular ui site that I load in locally using the Titanium web view.

My problem is that when I try to load the local site in a web view I see a blank page. To test the app I've uploaded the site to a php server and If I try to load the site using the mobile browser (for example chrome) everything is working fine.

I've noticed that if I do not include the css mobile-angular-ui-base.min I can see a not blank page in the Titanium web view

Plunker site example

this is my app.js in titanium

var link = 'app/index.html';
var win = Ti.UI.createWindow();
var webview = Ti.UI.createWebView({
    url:link
});
win.add(webview);
win.open({
  modal : true
});

Create a new titanium project, create a folder called app inside Resource folder and copy inside all html,js,css files.

If you execute the mobile application the result will be a blank page. If you remove from index.html you will see the login page. And finally you try to launch the browser in the android device (chrome for example) and load the same site in a remote server (without remove the mobile-angular-ui-base.min.cs) you will see the correct login page (like in plunker example)

this is my Android Emulator settings:

Name: Nexus_5_API_23_x86
CPU/ABI: Google APIs Intel Atom (x86)
Target: Google APIs (API level 23)
Skin: 1080x1920
SD Card: 200M
hw.dPad: no
hw.accelerometer: yes
hw.device.name: Nexus 5
vm.heapSize: 64
skin.dynamic: no
hw.device.manufacturer: Google
hw.gps: yes
hw.audioInput: yes
tag.id: google_apis
hw.camera.back: emulated
hw.mainKeys: no
hw.camera.front: emulated
hw.lcd.density: 480
hw.device.hash2: MD5:2fa0e16c8cceb7d385183284107c0c88
hw.ramSize: 1536
hw.trackBall: no
hw.battery: yes
hw.sdCard: yes
tag.display: Google APIs
hw.keyboard: yes
hw.sensors.proximity: yes
disk.dataPartition.size: 200M
hw.sensors.orientation: yes
avd.ini.encoding: UTF-8
hw.gpu.enabled: yes

Please help. Thanxs

Fabry
  • 1,498
  • 4
  • 23
  • 47

1 Answers1

1

I think the problem is that all <link> and <script> etc resources are resolved relative to the app's resources directory. You should be able to debug WebViews via Chrome (for Android) and Safari (for iOS) Developer Tools to debug the exact cause. You probably then need to change some paths to get it working.

Fokke Zandbergen
  • 3,866
  • 1
  • 11
  • 28
  • I Think that the path are right because if I try to change the path of angular.min.js to "app/js/libs/angular/angular.min.js" in the logcat I see this error "Unable to open asset URL: file:///android_asset/Resources/app/app/js/libs/angular/angular.min.js" otherwise I didn't receive any errors – Fabry Dec 31 '15 at 11:50
  • I tryed to use AndroidStrudio and with this IDE I get an error. I don't remember exactly the error description, it was like "Unable to load signIn.html .... ". This file is downloaded using ajax by angularjs. I solved this error (in Android Strudio) setting this settings for the webView "setAllowFileAccessFromFileURLs(true)". The strange thing is that in my phisical Device connected via usb (Galaxy TAB 2) the Titanium application was working fine. I sent the .apk to another android phone and I had the same problem as in the emulator – Fabry Jan 07 '16 at 17:18
  • May I ask why you use AndroidStudio for building a Titanium app? Judging by that error description you'd have to play with the paths for that file. As I said it might be because it assumes the wrong base. – Fokke Zandbergen Jan 08 '16 at 19:01
  • Sorry but maybe you missunderstood. For building the titanium app i'm using Appcelerator. I try to create a new app in Android Studio with the same concept (a web view with a local web app). In Android studio the app worked (I didn't change any path, just set true the setAllowAccessFromFileUrl.) – Fabry Jan 09 '16 at 20:55
  • Ah, OK. Well that would make a good case for a JIRA ticket. If you can include a small sample app made in android studio and one made in titanium with identical HTML than the engineers can reproduce and try to fix. – Fokke Zandbergen Jan 10 '16 at 07:00
  • Thank you very much. I'll do it – Fabry Jan 11 '16 at 17:47