改变cordova项目的android目标 [英] Changing the android target of a cordova project

查看:149
本文介绍了改变cordova项目的android目标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚开始使用cordova,并且使用这个命令创建了我的第一个cordova项目,如以下站点
https://cordova.apache.org/docs/en/4.0.0/guide_cli_index.md.html

  cordova create hello com.example.hello HelloWorld 

使用这些命令添加一个平台到项目中,

  cd hello 
cordova platform添加android

命令行给出这些输出

 添加android项目... 
为Android平台创建Cordova项目:
路径:platforms\android
包:com.exampple.hell
名称:helloWorld
Android目标:android-21
复制模板文件...
项目成功创建。

根据这个Android项目的Android目标是android-21,但是在我的机器上安装了android SDK只有所以当我将这些项目导入eclipse IDE进行进一步的更改时,它会在控制台上给出错误

 无法解析目标'android-21'

我将AndroidManifest.xml文件更改为

 < uses-sdk android:minSdkVersion =10android:targetSdkVersion =19/> 

但仍然有问题。



当平台被添加到项目中时,我可以将android目标更改为19,还是有另一种方法来解决这个问题,并使用android API等级19运行项目

解决方案

您应该首先在您的机器上更新您的SDK。兼容性取决于您的 config.xml 文件内容。



例如,您要支持从16到19,那么这部分 config.xml 应该如下所示:

 < preference name =android-minSdkVersionvalue =16/> 
< preference name =android-targetSdkVersionvalue =19/>

然后,构建方法负责 AndroidManifest.xml


i'm new to cordova development and i created my first cordova project using this command as in following site https://cordova.apache.org/docs/en/4.0.0/guide_cli_index.md.html

 cordova create hello com.example.hello HelloWorld

After used these commands to add a platform to project,

 cd hello
 cordova platform add android

and command line gives these output

    Adding android project...
    Creating Cordova project for the Android platform:        
    Path: platforms\android
    Package: com.exampple.hell
    Name: helloWorld
    Android target: android-21
    Copying template files...
    Project successfully created.

according to this Android target of this project is android-21 but installed android SDK on my machine only has up to android API level 19. So when i import these project to eclipse IDE to make further changes to project it gives error on console

Unable to resolve target 'android-21'

I changed AndroidManifest.xml file as

<uses-sdk android:minSdkVersion="10" android:targetSdkVersion="19" /> 

but still have the problem.

can i change the android target to 19 when the platform is added to project or is there another way to fix this and run project with android API level 19

解决方案

You should update your SDK on your machine first of all. The compatibility depends on your config.xml file content.

For example you want to support android levels from 16 to 19, then this part of the config.xml should look like this:

<preference name="android-minSdkVersion" value="16"/>
<preference name="android-targetSdkVersion" value="19"/>

The build method then takes care of AndroidManifest.xml.

这篇关于改变cordova项目的android目标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆