使用Cordova在android project.properties文件中设置值 [英] Using cordova to set values in the android project.properties file

查看:95
本文介绍了使用Cordova在android project.properties文件中设置值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个针对iOS和Android的cordova应用.有没有办法使用config.xml设置cordova生成的文件platforms/android/project.properties中的值?

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?

使用某些使用Google Play服务的插件时出现问题,导致我无法构建该应用程序:

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

失败:生成失败,发生异常. 出了什么问题:执行任务失败 ':transformClassesWithDexForRelease'. com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException:com.android.dex.DexException: 多个dex文件定义 Lcom/google/android/gms/auth/api/signin/internal/zzo;

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;

就我而言,这必须归因于我同时使用了 cordova-同一项目中的plugin-googleplus google-analytics-plugin 插件

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.

解决此问题的一种方法是编辑platforms/android/project.properties文件,以包括要使用的Google Play服务版本:

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

问题在于,platforms下的所有内容都是由cordova生成的,并且会定期删除,这要求我们不断替换platforms/android/project.properties文件.

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.

是否可以使用config.xml设置cordova生成的文件platforms/android/project.properties中的值?

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

推荐答案

对我来说,好的解决方案是使用 variable 标签,如下所示:

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>

来源

这篇关于使用Cordova在android project.properties文件中设置值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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