Using cordova to set values in the android project.properties file

别等时光非礼了梦想. 提交于 2019-12-10 21:53:23

问题


TL;DR

I have a cordova app that is targeting both iOS and Android. Is there a way using config.xml to set the values inside the cordova generated file platforms/android/project.properties?

More details:

There is an issue using certain plugins that make use of google play services that prevents me from building the app:

FAILURE: Build failed with an exception. What went wrong: Execution failed for task ':transformClassesWithDexForRelease'. com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.dex.DexException: Multiple dex files define Lcom/google/android/gms/auth/api/signin/internal/zzo;

In my case it has to due with the fact that I'm using both the cordova-plugin-googleplus and google-analytics-plugin plugins in the same project.

One way to fix this is to edit the platforms/android/project.properties file to include which version of google play services to use:

cordova.system.library.3=com.google.android.gms:play-services-analytics:11.8.0
cordova.system.library.4=com.google.android.gms:play-services-auth:11.8.0
cordova.system.library.5=com.google.android.gms:play-services-identity:11.8.0

The issue is that of course everything under platforms is generated by cordova and is blown away on a regular basis, requiring us to continually replace the platforms/android/project.properties file.

Is there a way using config.xml to set the values inside the cordova generated file platforms/android/project.properties?


回答1:


the good solution for me was using the variable tag like this:

<plugin name="pluginA" spec="npm">
  <variable name=”PLAY_SERVICES_VERSION” value="15.0.0" />
</plugin>
<plugin name="pluginB" spec="npm">
  <variable name=”PLAY_SERVICES_VERSION” value="15.0.0" />
</plugin>

The source



来源:https://stackoverflow.com/questions/49638322/using-cordova-to-set-values-in-the-android-project-properties-file

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