用android studio运行weex项目错误汇总

在本地使用命令weex run android运行weex项目时报错:“Error: No android devices found.”,后面发现这是个坑,需要使用android studio启动项目来运行。

在本地下载安装好android studio环境和工具后,将weex项目下platforms-》android文件引入(如果是ios则引入ios文件夹),然后编译运行,在编译运行中遇到了如下几个问题,在此汇总记录:

1.Could not find com.android.tools.build:gradle:xxx.xx(xxx为版本号)

这个问题是由于gradle版本问题造成,解决版本就是将android.build.gradle下面的gradle版本号与studio版本一致(通过help->about查看android studio版本)

 

android.build.gradle配置如下(红色部分与android studio版本):


2.Gradle DSL method not found: 'google()'
这个问题需修改android.build.gradle里面repositories里面的配置,修改后内容如下:

maven {
url 'http://maven.aliyun.com/nexus/content/groups/public'
}

 

3.Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'

此问题修改android/app/build.gradle下的配置,将dependencies下的compile用implementation代替,修改完后效果如下

 

4.Android Gradle 3.0.0-alpha2 plugin, Cannot set the value of read-only property 'outputFile'

此问题将 app/build.gradle中 all() 代替 each(),改完后配置为

以下内容供复制使用:

variant.outputs.all {
outputFileName = "${variant.name}-${variant.versionName}.apk"
}
https://stackoverflow.com/questions/44239235/android-gradle-3-0-0-alpha2-plugin-cannot-set-the-value-of-read-only-property

 

 

 最后模拟器运行出的demo效果如下,具体内容可能会有差异

 

以上为我本地运行用studio运行weex问题的汇总,遇到最多的是关于gradle版本问题,此时参考问题一和二中的配置方案应该就可以了。

如果遇到别的问题,欢迎在评论区交流

 



posted @ 2018-12-08 14:48  专业打杂  阅读(1394)  评论(0编辑  收藏  举报