我想将 android-22 设置为目标 android sdk。我需要它作为 Android 6 及更高版本相机的工作权限问题。(此处描述https://developer.android.com/training/permissions/requesting.html,此处建议Android 6.0 Permissions 的解决方法)但是我的cordova 6.2.1 设置了默认 sdk 23。我在 AndroidManifest.xml 中更改了它
<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="22" />
已构建,但 apk 的大小与我为 android-23 构建的大小相同。所以,为了确保它是为 android-22 构建的,我删除了 sdk-23,只留下了 sdk-22。Build 没有开始,Cordova 说,我需要 android-23 sdk
e:\projects\android\qp2>cordova build --release
Error: Please install Android target: "android-23".
Hint: Open the SDK manager by running: "c:\android\android-sdk\tools\android.bat
"
You will require:
1. "SDK Platform" for android-23
2. "Android SDK Platform-tools (latest)
3. "Android SDK Build-tools" (latest)
,所以我按照这里的建议将 project.properties 和 CordovaLib/project.properties 中的目标更改为 android-22 。构建失败。
E:\projects\android\qp2\platforms\android\CordovaLib\src\org\apache\cordova\CordovaInterfaceImpl.java:191: error: cannot find symbol
getActivity().requestPermissions(permissions, requestCode);
^
symbol: method requestPermissions(String[],int)
location: class Activity
E:\projects\android\qp2\platforms\android\CordovaLib\src\org\apache\cordova\CordovaInterfaceImpl.java:197: error: cannot find symbol
getActivity().requestPermissions(permissions, requestCode);
^
symbol: method requestPermissions(String[],int)
location: class Activity
E:\projects\android\qp2\platforms\android\CordovaLib\src\org\apache\cordova\CordovaInterfaceImpl.java:202: error: cannot find symbol
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)
^
symbol: variable M
location: class VERSION_CODES
E:\projects\android\qp2\platforms\android\CordovaLib\src\org\apache\cordova\CordovaInterfaceImpl.java:204: error: cannot find symbol
int result = activity.checkSelfPermission(permission);
^
symbol: method checkSelfPermission(String)
location: variable activity of type Activity
E:\projects\android\qp2\platforms\android\CordovaLib\src\org\apache\cordova\CordovaActivity.java:493: error: method does not override or implement a method from a supertype
@Override
^
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
5 errors
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':CordovaLib:compileReleaseJava'.
> Compilation failed; see the compiler error output for details.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
Error: cmd: Command failed with exit code 1
不久,我的问题是,除了最新的 android-23 平台之外,我不知道如何定位其他平台。项目是空的,刚刚创建,没有插件也没有代码。
是否可以在 cordova 6.2.1 中为 android-22 创建和构建。我应该降级科尔多瓦吗?