cordova phonegap - How to use android API level 21

半世苍凉 提交于 2019-12-11 14:48:31

问题


Hey I forked the push notification plugin (https://github.com/alexislg2/PushPlugin) and added it to my project.

The project won't compile with cordova build because I have a error: cannot find symbol error.

The reason is that I use in the plugin Notification.setCategory() method which is Android SDK 21.

How to force cordova to compile using API level 21?

I installed the android 21 sdk build tools + I set <preference name="android-targetSdkVersion" value="21" /> in my config.xml

But cordova keeps trying to compile with android 19. What is wrong?

Thanks


回答1:


This is the progress of Cordova updating to android-21, android platform plugin v4.0 will support lollipop: https://issues.apache.org/jira/browse/CB-8026

There is an issue about cookie and a temporary workaround: http://tol8.blogspot.ca/2014/11/fixed-apps-cordovaphonegap-targeting.html

I would suggest waiting for the next version, looks like 3.7.1 also updated the target api level.

I am not using cookie related feature in my project, so I just replaced "android-19" with "android-21" in

platforms/android/CordovaLib/project.properties

And adds preference in config.xml

<platform name="android">
    <preference name="android-targetSdkVersion" value="21" />
</platform>

Another workaround (but ugly) is change the system cache of android plugin code:

~/.cordova/lib/npm_cache/cordova-android/3.6.4/package/framework/project.properties

---- Update ----

A better way of updating platform plugin will added in Cordova 4.2.1 (currently 4.1.2): https://issues.apache.org/jira/browse/CB-8239

$ cordova platform add <URL>


来源:https://stackoverflow.com/questions/28527902/cordova-phonegap-how-to-use-android-api-level-21

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!