1. 程式人生 > >用android studio運行weex項目錯誤匯總

用android studio運行weex項目錯誤匯總

引入 16px 命令 flow set epo ces 發現 ace

在本地使用命令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版本問題,此時參考問題一和二中的配置方案應該就可以了。

如果遇到別的問題,歡迎在評論區交流



用android studio運行weex項目錯誤匯總