编程语言
首页 > 编程语言> > javascript-图像不会在Titan Build Android应用程序中显示

javascript-图像不会在Titan Build Android应用程序中显示

作者:互联网

虽然代码在iOS设备上运行时效果很好,但是当我为android构建图像时却无法显示.图像是navbar.png& menubuttonimage.png,到目前为止,我已经将它们复制到几乎每个文件夹中

控制台日志

[INFO] Compiling Android Resources... This could take some time
[DEBUG] "/android sdk/sdk/build-tools/17.0.0/dx" -JXmx1536M -JXX:-UseGCOverheadLimit --dex --output=/Users/daanluttik/Documents/Titanium_Studio_Workspace/OuderKonnect/build/android/bin/classes.dex /Users/daanluttik/Documents/Titanium_Studio_Workspace/OuderKonnect/build/android/bin/classes "/Users/daanluttik/Library/Application Support/Titanium/mobilesdk/osx/3.1.3.GA/android/kroll-v8.jar" "/Users/daanluttik/Library/Application Support/Titanium/mobilesdk/osx/3.1.3.GA/android/jaxen-1.1.1.jar" "/Users/daanluttik/Library/Application Support/Titanium/mobilesdk/osx/3.1.3.GA/android/modules/titanium-media.jar" "/Users/daanluttik/Library/Application Support/Titanium/mobilesdk/osx/3.1.3.GA/android/modules/titanium-platform.jar" "/Users/daanluttik/Library/Application Support/Titanium/mobilesdk/osx/3.1.3.GA/android/modules/titanium-ui.jar" "/Users/daanluttik/Library/Application Support/Titanium/mobilesdk/osx/3.1.3.GA/android/titanium.jar" "/Users/daanluttik/Library/Application Support/Titanium/mobilesdk/osx/3.1.3.GA/android/modules/titanium-analytics.jar" "/Users/daanluttik/Library/Application Support/Titanium/mobilesdk/osx/3.1.3.GA/android/modules/titanium-app.jar" "/Users/daanluttik/Library/Application Support/Titanium/mobilesdk/osx/3.1.3.GA/android/modules/titanium-android.jar" "/Users/daanluttik/Library/Application Support/Titanium/mobilesdk/osx/3.1.3.GA/android/kroll-common.jar" "/Users/daanluttik/Library/Application Support/Titanium/mobilesdk/osx/3.1.3.GA/android/modules/titanium-filesystem.jar" "/Users/daanluttik/Library/Application Support/Titanium/mobilesdk/osx/3.1.3.GA/android/modules/titanium-locale.jar" "/Users/daanluttik/Library/Application Support/Titanium/mobilesdk/osx/3.1.3.GA/android/ti-commons-codec-1.3.jar" "/Users/daanluttik/Library/Application Support/Titanium/mobilesdk/osx/3.1.3.GA/android/android-support-v4.jar" "/Users/daanluttik/Library/Application Support/Titanium/mobilesdk/osx/3.1.3.GA/android/lib/titanium-verify.jar" "/Users/daanluttik/Library/Application Support/Titanium/mobilesdk/osx/3.1.3.GA/android/lib/titanium-debug.jar" "/Users/daanluttik/Library/Application Support/Titanium/mobilesdk/osx/3.1.3.GA/android/lib/titanium-profiler.jar" "/Users/daanluttik/Library/Application Support/Titanium/mobilesdk/osx/3.1.3.GA/android/modules/titanium-network.jar"
[DEBUG] Android classes.dex built
[DEBUG] "/android sdk/sdk/build-tools/17.0.0/aapt" package -f -M AndroidManifest.xml -A /Users/daanluttik/Documents/Titanium_Studio_Workspace/OuderKonnect/build/android/bin/assets -S res -I "/android sdk/sdk/platforms/android-10/android.jar" -I "/Users/daanluttik/Library/Application Support/Titanium/mobilesdk/osx/3.1.3.GA/android/titanium.jar" -F /Users/daanluttik/Documents/Titanium_Studio_Workspace/OuderKonnect/build/android/bin/app.ap_
[DEBUG] creating unsigned apk: /Users/daanluttik/Documents/Titanium_Studio_Workspace/OuderKonnect/build/android/bin/app-unsigned.apk
[DEBUG] from resource zip => assets/Resources/images/menubuttonimage.png
[DEBUG] from resource zip => assets/Resources/images/navbar.png
[DEBUG] from resource zip => assets/Resources/statics/Statics.js
[DEBUG] from resource zip => assets/Resources/utils/Navigation.js
[DEBUG] from resource zip => assets/Resources/utils/NavigationController.js
[DEBUG] from resource zip => assets/Resources/views/viewParts/NavigationBar.js
[DEBUG] from resource zip => assets/Resources/views/viewParts/SlideMenu.js
[DEBUG] from resource zip => assets/Resources/views/FotoAlbum.js
[DEBUG] from resource zip => assets/Resources/views/Schriftje.js
[DEBUG] from resource zip => assets/Resources/views/ViewBase.js
[DEBUG] from resource zip => assets/Resources/KS_nav_ui.png
[DEBUG] from resource zip => assets/Resources/KS_nav_views.png
[DEBUG] from resource zip => assets/Resources/app.js
[DEBUG] from resource zip => assets/Resources/appicon.png
[DEBUG] from resource zip => assets/Resources/default.png
[DEBUG] from resource zip => assets/Resources/menubuttonimage.png
[DEBUG] from resource zip => assets/Resources/navbar.png
[DEBUG] from resource zip => assets/app.json
[DEBUG] from resource zip => assets/index.json
[DEBUG] from resource zip => res/drawable/appicon.png
[DEBUG] from resource zip => res/drawable/background.png
[DEBUG] from resource zip => res/drawable/btn_check_buttonless_on_64.png
[DEBUG] from resource zip => res/drawable/btn_more_64.png
[DEBUG] from resource zip => res/drawable/disclosure_64.png
[DEBUG] from resource zip => res/layout/titanium_tabgroup.xml
[DEBUG] from resource zip => res/layout/titanium_ui_list_header_or_footer.xml
[DEBUG] from resource zip => res/layout/titanium_ui_list_item.xml
[DEBUG] from resource zip => AndroidManifest.xml
[DEBUG] from resource zip => resources.arsc
[DEBUG] from resource zip => res/drawable-long-land-hdpi/background.png
[DEBUG] from resource zip => res/drawable-long-land-hdpi/menubuttonimage_aa179f5596.png
[DEBUG] from resource zip => res/drawable-long-land-hdpi/navbar_e8e9044f98.png
[DEBUG] from resource zip => res/drawable-long-land-ldpi/background.png
[DEBUG] from resource zip => res/drawable-long-land-ldpi/menubuttonimage_aa179f5596.png
[DEBUG] from resource zip => res/drawable-long-land-ldpi/navbar_e8e9044f98.png
[DEBUG] from resource zip => res/drawable-long-port-hdpi/background.png
[DEBUG] from resource zip => res/drawable-long-port-hdpi/menubuttonimage_aa179f5596.png
[DEBUG] from resource zip => res/drawable-long-port-hdpi/navbar_e8e9044f98.png
[DEBUG] from resource zip => res/drawable-long-port-ldpi/background.png
[DEBUG] from resource zip => res/drawable-long-port-ldpi/menubuttonimage_aa179f5596.png
[DEBUG] from resource zip => res/drawable-long-port-ldpi/navbar_e8e9044f98.png
[DEBUG] from resource zip => res/drawable-notlong-land-hdpi/background.png
[DEBUG] from resource zip => res/drawable-notlong-land-hdpi/menubuttonimage_aa179f5596.png
[DEBUG] from resource zip => res/drawable-notlong-land-hdpi/navbar_e8e9044f98.png
[DEBUG] from resource zip => res/drawable-notlong-land-ldpi/background.png
[DEBUG] from resource zip => res/drawable-notlong-land-ldpi/menubuttonimage_aa179f5596.png
[DEBUG] from resource zip => res/drawable-notlong-land-ldpi/navbar_e8e9044f98.png
[DEBUG] from resource zip => res/drawable-notlong-land-mdpi/background.png
[DEBUG] from resource zip => res/drawable-notlong-land-mdpi/menubuttonimage_aa179f5596.png
[DEBUG] from resource zip => res/drawable-notlong-land-mdpi/navbar_e8e9044f98.png
[DEBUG] from resource zip => res/drawable-notlong-port-hdpi/background.png
[DEBUG] from resource zip => res/drawable-notlong-port-hdpi/menubuttonimage_aa179f5596.png
[DEBUG] from resource zip => res/drawable-notlong-port-hdpi/navbar_e8e9044f98.png
[DEBUG] from resource zip => res/drawable-notlong-port-ldpi/background.png
[DEBUG] from resource zip => res/drawable-notlong-port-ldpi/menubuttonimage_aa179f5596.png
[DEBUG] from resource zip => res/drawable-notlong-port-ldpi/navbar_e8e9044f98.png
[DEBUG] from resource zip => res/drawable-notlong-port-mdpi/background.png
[DEBUG] from resource zip => res/drawable-notlong-port-mdpi/menubuttonimage_aa179f5596.png
[DEBUG] from resource zip => res/drawable-notlong-port-mdpi/navbar_e8e9044f98.png
[DEBUG] from JAR /Users/daanluttik/Library/Application Support/Titanium/mobilesdk/osx/3.1.3.GA/android/modules/titanium-ui.jar => ti/modules/titanium/ui/widget/webview/binding.js
[DEBUG] from JAR /Users/daanluttik/Library/Application Support/Titanium/mobilesdk/osx/3.1.3.GA/android/modules/titanium-ui.jar => ti/modules/titanium/ui/widget/webview/binding.min.js
[DEBUG] from JAR /Users/daanluttik/Library/Application Support/Titanium/mobilesdk/osx/3.1.3.GA/android/modules/titanium-ui.jar => ti/modules/titanium/ui/widget/webview/json2.js
[DEBUG] from JAR /Users/daanluttik/Library/Application Support/Titanium/mobilesdk/osx/3.1.3.GA/android/modules/titanium-ui.jar => ti/modules/titanium/ui/widget/webview/polling.js
[DEBUG] from JAR /Users/daanluttik/Library/Application Support/Titanium/mobilesdk/osx/3.1.3.GA/android/modules/titanium-ui.jar => ti/modules/titanium/ui/widget/webview/polling.min.js
[DEBUG] from JAR /Users/daanluttik/Library/Application Support/Titanium/mobilesdk/osx/3.1.3.GA/android/titanium.jar => org/appcelerator/titanium/build.properties
[DEBUG] from JAR /Users/daanluttik/Library/Application Support/Titanium/mobilesdk/osx/3.1.3.GA/android/titanium.jar => org/appcelerator/titanium/res/drawable/background.png
[DEBUG] from JAR /Users/daanluttik/Library/Application Support/Titanium/mobilesdk/osx/3.1.3.GA/android/titanium.jar => org/appcelerator/titanium/res/drawable/btn_check_buttonless_on.png
[DEBUG] from JAR /Users/daanluttik/Library/Application Support/Titanium/mobilesdk/osx/3.1.3.GA/android/titanium.jar => org/appcelerator/titanium/res/drawable/btn_check_buttonless_on_18.png
[DEBUG] from JAR /Users/daanluttik/Library/Application Support/Titanium/mobilesdk/osx/3.1.3.GA/android/titanium.jar => org/appcelerator/titanium/res/drawable/btn_check_buttonless_on_48.png
[DEBUG] from JAR /Users/daanluttik/Library/Application Support/Titanium/mobilesdk/osx/3.1.3.GA/android/titanium.jar => org/appcelerator/titanium/res/drawable/btn_check_buttonless_on_64.png
[DEBUG] from JAR /Users/daanluttik/Library/Application Support/Titanium/mobilesdk/osx/3.1.3.GA/android/titanium.jar => org/appcelerator/titanium/res/drawable/btn_more.png
[DEBUG] from JAR /Users/daanluttik/Library/Application Support/Titanium/mobilesdk/osx/3.1.3.GA/android/titanium.jar => org/appcelerator/titanium/res/drawable/btn_more_18.png
[DEBUG] from JAR /Users/daanluttik/Library/Application Support/Titanium/mobilesdk/osx/3.1.3.GA/android/titanium.jar => org/appcelerator/titanium/res/drawable/btn_more_48.png
[DEBUG] from JAR /Users/daanluttik/Library/Application Support/Titanium/mobilesdk/osx/3.1.3.GA/android/titanium.jar => org/appcelerator/titanium/res/drawable/btn_more_64.png
[DEBUG] from JAR /Users/daanluttik/Library/Application Support/Titanium/mobilesdk/osx/3.1.3.GA/android/titanium.jar => org/appcelerator/titanium/res/drawable/btn_picker_normal.9.png
[DEBUG] from JAR /Users/daanluttik/Library/Application Support/Titanium/mobilesdk/osx/3.1.3.GA/android/titanium.jar => org/appcelerator/titanium/res/drawable/btn_picker_pressed.9.png
[DEBUG] from JAR /Users/daanluttik/Library/Application Support/Titanium/mobilesdk/osx/3.1.3.GA/android/titanium.jar => org/appcelerator/titanium/res/drawable/btn_picker_selected.9.png
[DEBUG] from JAR /Users/daanluttik/Library/Application Support/Titanium/mobilesdk/osx/3.1.3.GA/android/titanium.jar => org/appcelerator/titanium/res/drawable/default_icon.png
[DEBUG] from JAR /Users/daanluttik/Library/Application Support/Titanium/mobilesdk/osx/3.1.3.GA/android/titanium.jar => org/appcelerator/titanium/res/drawable/photoDefault.png
[DEBUG] installing native SDK libs
[DEBUG] keytool -v -list -keystore "/Users/daanluttik/Library/Application Support/Titanium/mobilesdk/osx/3.1.3.GA/android/dev_keystore" -storepass ******* -alias tidev
[DEBUG] jarsigner -sigalg MD5withRSA -digestalg SHA1 -storepass ******* -keystore "/Users/daanluttik/Library/Application Support/Titanium/mobilesdk/osx/3.1.3.GA/android/dev_keystore" -signedjar /Users/daanluttik/Documents/Titanium_Studio_Workspace/OuderKonnect/build/android/bin/app.apk /Users/daanluttik/Documents/Titanium_Studio_Workspace/OuderKonnect/build/android/bin/app-unsigned.apk tidev
[DEBUG] "/android sdk/sdk/tools/zipalign" -v 4 /Users/daanluttik/Documents/Titanium_Studio_Workspace/OuderKonnect/build/android/bin/app.apk /Users/daanluttik/Documents/Titanium_Studio_Workspace/OuderKonnect/build/android/bin/app.apkz
[DEBUG] "/android sdk/sdk/platform-tools/adb" -d get-state
[DEBUG] Waiting for device to be ready ...
[TRACE] adb devices returned 1 devices/emulators
[DEBUG] Device connected... (waited 0 seconds)
[DEBUG] waited 0.017152 seconds on emulator to get ready
[INFO] Installing application on device
[DEBUG] "/android sdk/sdk/platform-tools/adb" -d install -r /Users/daanluttik/Documents/Titanium_Studio_Workspace/OuderKonnect/build/android/bin/app.apk
[INFO] Application installed. Launch from drawer on Home Screen
[INFO] :   Project built successfully in 41s 853ms
[INFO] :   Launching application on device: /android sdk/sdk/platform-tools/adb "-d" "shell" "am" "start" "-a" "android.intent.action.MAIN" "-c" "android.intent.category.LAUNCHER" "-n" "com.konnect.ouderkonnect/.OuderkonnectActivity" "-f" "0x10200000"
Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.konnect.ouderkonnect/.OuderkonnectActivity }
[INFO] :   App installer shutdown successfully

码:

self.background = Ti.UI.createImageView(
    {
        top : '0dp',
        left : '0dp',
        width : '100%',
        height : '50dp',
        image : 'navbar.png',
        backgroundImage : 'navbar.png',
        //backgroundColor:'black'
    });
    self.add(self.background);

    var label = Ti.UI.createImageView(
    {
        top : '10dp',
        left : '10dp',
        width : '30dp',
        height : '30dp',
        image : 'menubuttonimage.png',
        backgroundImage : 'menubuttonimage.png',
        //backgroundColor:'red'
    });

解决方法:

使用图像的绝对路径,这样它们就可以在Android和iOS平台上使用.在您的情况下,只需在文件名前添加“ /”即可.

self.background = Ti.UI.createImageView({
    top : '0dp',
    left : '0dp',
    width : '100%',
    height : '50dp',
    image : '/navbar.png',
    backgroundImage : '/navbar.png',
});
self.add(self.background);

var label = Ti.UI.createImageView({
    top : '10dp',
    left : '10dp',
    width : '30dp',
    height : '30dp',
    image : '/menubuttonimage.png',
    backgroundImage : '/menubuttonimage.png',
});

标签:titanium,commonjs,ios,javascript,android
来源: https://codeday.me/bug/20191030/1966004.html