A simple vs-android C++ Update android UI example

1.创建工程

   创建一个空项目。如下图:

 

项目创建之后,生成以下的文件目录:

 

打开新建立的解决方案之后,按如下方式来Adding The Android Platform。

  • Now go to the 'Build' menu and pick 'Configuration Manager...'.
  • In the top right of this dialog, the solution dropdown box, choose 'New...'

 

  • In the next dialog choose 'Android' from the dropdown list. If it is not present, then there was a problem with installing vs-android.
  • Copy settings from 'empty', and ensure 'Create new project platforms' is checked.

把解决方案和项目的平台配置成刚才新建的平台。

这样之后,会自动生成相关配置:

 

创建Android native项目test.保证项目能在NDK环境中能编译运行。

在vs中工程所在目录创建AndroidApk文件,将创建的Android native项目的文件拷贝进去。删除不必要的文件,留下如下文件如图:

按如下方式生成build.xml文件。

如果AndroidApk文件夹中没有project.properties文件,将会出现如下提示。

这是解决方式有两种,通过指定target,如下图:

这时将会自动生成project.properties文件。另外一种方法是手动加上这个project.propertie文件。

在vs中工程配置Ant Build属性,如下图:

这里要修改的是Ant Build Root Path的值,其他的默认。
 
在vs中工程所在目录创建CppSource文件夹。
将AndroidApk中的jni文件中的Cpp文件复制到CppSource文件夹中。
打开VS解决方案,将CPP文件包含在项目中。这样,生成解决方案时才会编译这些C/C++源文件。
 
然后生成解决方案。
 
注:在这个vs-adroid平台上,如果是release版本,在Ant Build配置中,配置了Deploy and Run,将会是有问题的。部署的包名和打包生成的包名不一样。运行官方提供的例子san-angeles,同样有这个问题。
 
posted on 2013-10-04 16:00  青山隐隐,绿水迢迢  阅读(738)  评论(0编辑  收藏  举报