问题
I'm trying to rebuild the Android agent with custom keystores (to allow SSL with own SSL certificates) and optionally other customizations. When building the project as described in the documentation (product-emm 2.0.1), the Android studio (Android studio 2.2, Androind 5.1.1, API 22) claims the following methods are unknow:
- org.wso2.emm.agent.api.RuntimeInfo - Environment.getLegacyExternalStorageDirectory (line 159)
- org.wso2.emm.agent.services.AlarmReceiver - intent.getExtra (line 56)
- org.wso2.emm.agent.services.NetworkConnectedReceiver - context.startServiceAsUser (line 42)
- org.wso2.emm.agent.utils.CommonUtils - context.startServiceAsUser (line 432, 445)
Do I need different API level (according the docs it should be ok), difference tools or something? According to this post, the "startServiceAsUser" is not a public method..
Edit: now I see the project to rebuild should be product-mdm (???) I assume the MDM platform is (should be) part of the EMM, however - the codebase is slightly differenct. Seems this issue concerns the product-emm 2.2.0-SNAPSHOT
回答1:
EMM 2.0.1 is quite outdated (IMO for a half of year at least), there were many changes / bug fixes since then, which you probably want to have.
And if you make any contribution to EMM Android agent source code then you definitely need to compile against the latest EMM (2.2.0 at the moment).
I also face the same errors compiling EMM 2.2 android agent - it's because they use hidden system API which are not available in regular Android SDK, this API can be accessed via Reflection API (WSO2 maintainers should go this way) or with "extended" android.jar from ASDK including hidden API. Such jars files can be extracted from system jars on devices (you need a rooted device with appropriate Android API version on board) or from AOSP build, where Android ROM is being built, and system apps are built against system jars with hidden APIs.
See How do I build the Android SDK with hidden and internal APIs available? for more info on the matter.
Apparently WSO2 maintainers compile android agent with such "extended" system libs.
EDITED: Indeed WSO2 maintainers compile against ASDK with hidden API, this is a conceptual point, since the agent can be deployed to COPE devices with hidden APIs available. See more info here: https://wso2.org/jira/browse/EMM-141
My personal preference is to update android.jar in ASDK with hidden API, can be downloaded here: library that provides access to Android hidden API and internal resources
回答2:
Apparently I've used the incorrect project source (2.2.0-SNAPSHOT). When using the provided source code of the official release (2.0.1). the build is successful.
来源:https://stackoverflow.com/questions/39827724/wso2emm-rebuilding-the-mobile-agent-fails