Eclipse THyM与Cordova默认应用程序XML错误

时间:2016-08-25 10:10:56

标签: android xml eclipse cordova

我目前正在玩Cordova并且刚开始想知道我是否可以从Eclipse Neon开发。

下载了最新的JBoss tools并将它们安装在我的Javascript Eclipse Neon上,因此我可以使用新的Hybrid移动开发功能。

使用新项目向导创建默认的Hybrid mobile(Cordova)应用程序项目。添加了Android平台(cordova-android@5.2.2)。

Eclipse构建并配置新项目,但出现了一些有关XML验证的错误。我可以在我的Android设备或cordova模拟器上运行这个示例应用程序。它运行并显示OK,但错误仍然在eclipse代码上标记。

这些是我得到的错误:

cvc-attribute.3: The value 'loglevel' of attribute 'name' on element 'preference' is not valid with respect to its type, 'null'.    defaults.xml    /Test/platforms/android/cordova line 25 XML Problem

cvc-enumeration-valid: Value 'loglevel' is not facet-valid with respect to enumeration '[AllowInlineMediaPlayback, AndroidLaunchMode, android-maxSdkVersion, android-targetSdkVersion, AppendUserAgent, BackgroundColor, BackupWebStorage, ChildBrowser, CordovaWebViewEngine, DefaultVolumeStream, DisallowOverscroll, EnableViewportScale, EnableWebGL, ErrorUrl, FullScreen, GapBetweenPages, HideKeyboardFormAccessoryBar, HideMousePointer, InAppBrowserStorageEnabled, KeepRunning, KeyboardDisplayRequiresUserAction, LoadUrlTimeoutValue, LoadingDialog, LogLevel, MediaPlaybackAllowsAirPlay, MediaPlaybackRequiresUserAction, Min/Max Version, Orientation, OSXLocalStoragePath, OverrideUserAgent, PageLength, PaginationBreakingMode, PaginationMode, PopupBlocker, SetFullscreen, ShowTitle, Suppresses3DTouchGesture, SuppressesIncrementalRendering, SuppressesLongPressGesture, TopActivityIndicator, UIWebViewDecelerationSpeed, WebSecurity, WindowSize, WindowsDefaultUriPrefix, WindowsStoreDisplayName, WindowsStoreIdentityName, WindowsStorePublisherName, WindowsToastCapable, deployment-target, target-device, windows-phone-target-version, windows-target-version]'. It must be a value from the enumeration.   defaults.xml    /Test/platforms/android/cordova line 25 XML Problem

cvc-attribute.3: The value 'loglevel' of attribute 'name' on element 'preference' is not valid with respect to its type, 'null'.    config.xml  /Test/platforms/android/res/xml line 22 XML Problem

cvc-enumeration-valid: Value 'loglevel' is not facet-valid with respect to enumeration '[AllowInlineMediaPlayback, AndroidLaunchMode, android-maxSdkVersion, android-targetSdkVersion, AppendUserAgent, BackgroundColor, BackupWebStorage, ChildBrowser, CordovaWebViewEngine, DefaultVolumeStream, DisallowOverscroll, EnableViewportScale, EnableWebGL, ErrorUrl, FullScreen, GapBetweenPages, HideKeyboardFormAccessoryBar, HideMousePointer, InAppBrowserStorageEnabled, KeepRunning, KeyboardDisplayRequiresUserAction, LoadUrlTimeoutValue, LoadingDialog, LogLevel, MediaPlaybackAllowsAirPlay, MediaPlaybackRequiresUserAction, Min/Max Version, Orientation, OSXLocalStoragePath, OverrideUserAgent, PageLength, PaginationBreakingMode, PaginationMode, PopupBlocker, SetFullscreen, ShowTitle, Suppresses3DTouchGesture, SuppressesIncrementalRendering, SuppressesLongPressGesture, TopActivityIndicator, UIWebViewDecelerationSpeed, WebSecurity, WindowSize, WindowsDefaultUriPrefix, WindowsStoreDisplayName, WindowsStoreIdentityName, WindowsStorePublisherName, WindowsToastCapable, deployment-target, target-device, windows-phone-target-version, windows-target-version]'. It must be a value from the enumeration.   config.xml  /Test/platforms/android/res/xml line 22 XML Problem

这是Eclipse生成的默认config.xml文件:

<?xml version='1.0' encoding='utf-8'?>
<widget id="org.adn.test" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
    <name>Prueba</name>
    <description>
        A sample Apache Cordova application that responds to the
        deviceready
        event.
    </description>
    <author email="thym-dev@eclipse.org" href="http://www.eclipse.org/thym">
        Eclipse.org -
        Thym
    </author>
    <content src="index.html" />
    <access origin="*" />
    <allow-intent href="http://*/*" />
    <allow-intent href="https://*/*" />
    <allow-intent href="tel:*" />
    <allow-intent href="sms:*" />
    <allow-intent href="mailto:*" />
    <allow-intent href="geo:*" />
    <allow-intent href="market:*" />
    <preference name="loglevel" value="DEBUG" />
</widget>

这是defaults.xml文件,也是自动生成的:

<?xml version="1.0" encoding="UTF-8"?>
<!--
 Licensed to the Apache Software Foundation (ASF) under one
 or more contributor license agreements.  See the NOTICE file
 distributed with this work for additional information
 regarding copyright ownership.  The ASF licenses this file
 to you under the Apache License, Version 2.0 (the
 "License"); you may not use this file except in compliance
 with the License.  You may obtain a copy of the License at

 http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing,
 software distributed under the License is distributed on an
 "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 KIND, either express or implied.  See the License for the
 specific language governing permissions and limitations
 under the License.
-->
<widget xmlns     = "http://www.w3.org/ns/widgets"
        id        = "io.cordova.helloCordova"
        version   = "2.0.0">

    <!-- Preferences for Android -->
    <preference name="loglevel" value="DEBUG" />
</widget>

我的计算机上安装的Cordova版本为6.3.1 ,但我不确定它是否与Eclipse正在使用相同...

我一直在搜索但无法找到有关Eclipse THyM的任何教程或指南。甚至没有在他们的eclipse项目的页面中。解决这个问题很难解决。我真的不明白为什么我会在自动生成的基本示例项目中出错。

1 个答案:

答案 0 :(得分:0)

我想我刚刚找到了自己问题的答案:

关于Cordova文档,Eclipse生成name的{​​{1}}属性必须为loglevel。错误导致错误出现,正如错误所描述的那样。

在Config.xml here上链接Cordova的文档。只需向下滚动,直至找到LogLevel。以防万一有人觉得这很有用。

我真的不知道是否有人向LogLevel小组报告此问题,或者甚至值得报道。