用Maven构建AIR2项目实践记录

本文介绍如何使用Maven、Flexmojos等工具构建Adobe AIR应用程序,并详细记录了从环境搭建到项目构建的具体步骤。同时针对构建过程中可能遇到的问题给出了相应的解决方案。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

-------------------------------------------------------------------------------------------------------------------------------------------------------------------

参考:

Building an AIR Application

-------------------------------------------------------------------------------------------------------------------------------------------------------------------

 

一、相关环境

OS: Ubuntu 9.10

Maven V2.2.1

Flexmojos V3.7.1

Flex SDK 4.1

Adobe AIR 2.0.2 SDK

 

二、 构建过程

1、似乎目前 Flexmojos 还没有公布创建AIR应用的模板,所以通过其SVN获取AIR应用的样例源码:

SVN地址: http://svn.sonatype.org/flexmojos/trunk/flexmojos-testing/flexmojos-test-harness/projects/concept/simple-air/

simple-air 项目结构如下:


 

2、修改 simple-air / pom.xml文件:

      增加 仓库配置 和 Flexmojos 、FlexSDK 版本属性、指定SDK编译版本等,修改后的 pom.xml 如下:

<?xml version="1.0" encoding="UTF-8"?>
<!-- Copyright 2008 Marvin Herman Froeder Licensed 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. -->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
	<modelVersion>4.0.0</modelVersion>

	<groupId>info.rvin.itest</groupId>
	<artifactId>simple-air</artifactId>
	<version>1.0-SNAPSHOT</version>

	<packaging>pom</packaging>

	<modules>
		<module>air</module>
		<module>swf</module>
		<module>swc</module>
	</modules>

	<properties>
		<flexmojos.version>3.7.1</flexmojos.version>
		<flex.sdk.version>4.0.0.13555</flex.sdk.version>
	</properties>

	<repositories>
		<repository>
			<id>flexmojos</id>
			<url>http://repository.sonatype.org/content/groups/flexgroup/</url>
			<releases>
				<enabled>true</enabled>
			</releases>
			<snapshots>
				<enabled>true</enabled>
			</snapshots>
		</repository>
	</repositories>

	<pluginRepositories>
		<pluginRepository>
			<id>flexmojos</id>
			<url>http://repository.sonatype.org/content/groups/flexgroup/</url>
			<releases>
				<enabled>true</enabled>
			</releases>
			<snapshots>
				<enabled>true</enabled>
			</snapshots>
		</pluginRepository>
	</pluginRepositories>

	<build>
		<sourceDirectory>src/main/flex</sourceDirectory>
		<plugins>
			<plugin>
				<groupId>org.sonatype.flexmojos</groupId>
				<artifactId>flexmojos-maven-plugin</artifactId>
				<version>${flexmojos.version}</version>
				<extensions>true</extensions>
				<configuration>
					<targetPlayer>10.0.0</targetPlayer>
				</configuration>
				<dependencies>
					<dependency>
						<groupId>com.adobe.flex</groupId>
						<artifactId>compiler</artifactId>
						<version>${flex.sdk.version}</version>
						<type>pom</type>
					</dependency>

					<dependency>
						<groupId>com.adobe.flex</groupId>
						<artifactId>adt</artifactId>
						<version>${flex.sdk.version}</version>
						<scope>compile</scope>
					</dependency>
				</dependencies>
			</plugin>
		</plugins>
	</build>

	<dependencies>
		<!-- Air SDK dependencies -->
		<dependency>
			<groupId>com.adobe.flex.framework</groupId>
			<artifactId>air-framework</artifactId>
			<version>${flex.sdk.version}</version>
			<type>pom</type>
		</dependency>
	</dependencies>

</project>
 

 3、修改 simple-air / air / pom.xml, simple-air / swf / pom.xml , simple-air / swc / pom.xml 文件中的 

%{flexmojos.version}

     为

${flexmojos.version}

 

4、修改 simple-air/air/src/main/resources/descriptor.xml 中的

<application xmlns="http://ns.adobe.com/air/application/1.0">

     为

<application xmlns="http://ns.adobe.com/air/application/1.5">
 

5、编译项目,终端执行:

mvn install  

 

成功后, 在 simple-air/air/target 文件夹下会有成品:simple-air-air-1.0-SNAPSHOT.air,

运行该文件(需已安装AIR runtime),按提示安装并运行,运行结果如下:


   至此,构建过程实践成功。

 

三、 遇到问题与解决

Q1、未修改 simple-air/air/src/main/resources/descriptor.xml 中的

<application xmlns="http://ns.adobe.com/air/application/1.0">

运行 mvn install 时出现错误:

error 305: Intial window content SWF version 10 exceeds namespace version http://ns.adobe.com/air/application/1.0

 

Q2、修改 simple-air/air/src/main/resources/descriptor.xml 中的 namespace为:

<application xmlns="http://ns.adobe.com/air/application/2.0">

运行 mvn install 时出现错误:

error 102: Invalid namespace http://ns.adobe.com/air/application/2.0

 

以上2个错误的原因及解决是相通的:

 

原因:Flash Player , Flex SDK, adt 的版本彼此之间是有关联的,Q1是由于pom.xml指定了Flash Player版本为10 (<targetPlayer>10.0.0</targetPlayer>),  Q2是由于pom.xml指定了Flex SDK为4.0.0.13555(<flex.sdk.version>4.0.0.13555</flex.sdk.version>) ,该版本对应的 adt 版本为1.5。

 

注1:该原因是根据一些资料得出的,更多请参考:

 1) http://help.adobe.com/zh_CN/air/build/WS5b3ccc516d4fbf351e63e3d118666ade46-7ff1.html#WSe3d2d52902616553396777a311d6a2e014f-8000

2) http://forums.adobe.com/message/2894373

注2: 目前 flex.sdk.version 版本似乎最高只能是 4.0.0.13555,仓库中 adt 最高只有这个版本。

 

解决: 将命名空间URL改为:http://ns.adobe.com/air/application/1.5

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值