现在的位置: 首页 > 移动开发> 正文
AIR for Android
2011年07月02日 移动开发 暂无评论 ⁄ 被围观 6,961+

工程项目,建立步骤如下:

1. 下载工程项目所需的资源文件 air_for_android-flex_4_5-air_2_6-v_1

2. 建立 Android 工程 TestAIR (注意不要勾选Create Activity,先不创建Activity)

Porject Name: TestAIR
Standard Android Platform: 2.2
Application Name: TestAIR
Package Name: com.carey
Min SDK Version: 8

3. 将下载下来的资源文件覆盖新创建工程的同名目录和文件,包括 assets 和 res,airbootstap.jar 将作为链接库

4. 删除"res/layout" 目录

5. 将 airbootstrap.jar 添加到 Build Path

6. 新建一个Class文件,名称为 MainApp,内容如下:

1
2
3
4
5
6
7
8
9
10
11
12
package com.carey;  
import air.app.AppEntry;
import android.os.Bundle;  
 
public class MainApp extends AppEntry {    
 
  @Override   
  public void onCreate(Bundle arg0) {        
      System.out.println("carey test adobe air for android!!!");        
      super.onCreate(arg0);    
  }
}
package com.carey;  
import air.app.AppEntry;
import android.os.Bundle;  

public class MainApp extends AppEntry {    

  @Override   
  public void onCreate(Bundle arg0) {        
      System.out.println("carey test adobe air for android!!!");        
      super.onCreate(arg0);    
  }
}

7. 更新 Manifest 文件中的 Activity 为 MainApp

内容如下:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.carey" android:versionCode="1" android:versionName="1.0">
     <uses-sdk android:minSdkVersion="8" />
     <application android:icon="@drawable/icon" android:label="TestAIR">
          <activity android:theme="@style/Theme.NoShadow" android:label="app" android:name=".MainApp"
                        android:launchMode="singleTask" android:screenOrientation="nosensor"
                        android:configChanges="keyboardHidden|orientation" android:windowSoftInputMode="stateHidden|adjustResize">
            <intent-filter>
                   <action android:name="android.intent.action.MAIN" />
                   <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
         </activity>
  </application>
</manifest>

8. 运行程序,可以看到log的输出和屏幕的显示 log输出如下:

06-05 12:38:40.855: INFO/System.out(422): carey test adobe air for android!!!  

9. 如果现在手机还没有安装Adobe AIR for Androi的话,屏幕会提示是否需要安装,

 Adobe AIR for Android_2.6.0.1915.apk  下载 

10. 如果安装过程中出现 Failure [INSTALL_FAILED_INVALID_APK] 的错误   

     解决方法如下:   

     there is a change when creating an apk for a device or an emulator.   

     So adt.exe/jar is ok, you just need to provide different -target value, i.e.:    

     1.   For physical device:       
           

 adt.bat -package -target apk -storetype pkcs12 -keystore [keystore_positon] mobitest.apk MobileEmuTest-app.xml .   

     2.   For emulator:       
           

adt.bat -package -target apk-emulator -storetype pkcs12 -keystore [keystore_positon] mobitest.apk MobileEmuTest-app.xml .  

     或者

     修改 build.xml 如下: 

     change     

 <property name="apk.target" value="apk"/>  

to     

 <property name="apk.target" value="apk-emulator"/> 

     in build.xml file, and can install on the emulator device

本文源代码 下载

给我留言

留言无头像?


×
腾讯微博