坑一:connect to maven.google.com:443 connect timed out 连接不上的解决办法
这是weex打包后的build.gradle文件中的配置信息,maven仓库是 google仓库,刚开始觉得是因为没有"科学上网"导致,当我用科学上网的方式再次打包编译时,还是会出现这个问题,原因暂时还没搞清楚。。
allprojects {
repositories {
maven {url 'https://maven.google.com'}
maven {url 'https://www.jitpack.io'}
jcenter()
}
}
解决方法:
最新版的Android Studio(Canary 9) + Gradle 已经使用google()来指代google仓库了,会自动解析到https://dl.google.com/dl/android/maven2/。因此用这个方法不需要翻墙也不需要修改其他依赖包了
修改后如下:
将 maven {url 'https://maven.google.com'}
修改为maven { url 'https://dl.google.com/dl/android/maven2/' name 'Google' }
buildscript {
repositories {
mavenLocal()
jcenter()
mavenCentral()
maven {
url 'https://dl.google.com/dl/android/maven2/'
name 'Google'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:4.2.0'
classpath 'com.taobao.android:weexplugin-gradle-plugin:1.3'
}
}
allprojects {
repositories {
mavenLocal()
jcenter()
mavenCentral()
maven {
url 'https://dl.google.com/dl/android/maven2/'
name 'Google'
}
}
}
重新打包编译问题解决!!
坑二:Android Gradle Plugin Version 与Gradle Version版本问题
这两个问题,应该算是Android Studio的问题把,这两个版本是有关系的,不可以随便去搞,我把官网上的图贴出来
建议选择:
坑三:weex build android 时无法设置 outputFile 的问题
这个坑是坑二带过来的
问题如下:
BUILD FAILED in 11s
at checkExecSyncError (child_process.js:601:13)
at Object.execSync (child_process.js:641:13)
at C:\Users\feng\.xtoolkit\node_modules\weexpack\lib\build\android.js:156:20
at new Promise (<anonymous>)
at buildApp (C:\Users\feng\.xtoolkit\node_modules\weexpack\lib\build\android.js:152:10)
at <anonymous>
Error: Error: Command failed: call gradlew.bat assembleRelease
isLibProject: false, isAppProject: true
weex_plugin: []
FAILURE: Build failed with an exception.
* Where:
Build file 'C:\Users\feng\Desktop\app\app\platforms\android\app\build.gradle' line: 24
* What went wrong:
A problem occurred configuring project ':app'.
> groovy.lang.GroovyRuntimeException: Cannot set the value of read-only property 'outputFile' for ApkVariantOutputImpl_Decorated{apkData=Main{type=MAIN, fullName=debug, filters=[], versionCode=1, versionName=1.0.0}} of type com.android.build.gradle.internal.api.ApkVariantOutputImpl.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 11s
坑的原因
Android plugin 升级到3.0之后,platforms\android\app\build.gradle
文件中的 outputFile变成了只读属性
解决办法
- 用
all()
代替each()
- 用
outputFileName
代替output.outoutFile
修改之前的platforms\android\app\build.gradle
内容如下:
代码如下
applicationVariants.all { variant ->
variant.outputs.all {
outputFileName = "${variant.name}-${variant.versionName}.apk"
}
}
再重新编译就行了