AndroidStudio(Gradle)日常問(wèn)題匯總持續(xù)更新

先寫在前面,相信很多android er都碰到過(guò)不少gradle的坑,但是不得不說(shuō),gradle還是很強(qiáng)大的,寫代碼難免爬坑,還在用Eclipse的朋友們真的得早點(diǎn)換了。

下面是我和身邊朋友碰到過(guò)的gradle的常見的問(wèn)題和解決方案,會(huì)持續(xù)更新,雖然平時(shí)還是挺忙的,但是我會(huì)盡量做到不太監(jiān)。

  • 1.打包時(shí)報(bào)the same input jar is specified twice
    解決:
混淆文件中刪除-libraryjars libs/***.jarfrom your proguard-rules.pro file.
  • 2.Duplicate files copied in APK META-INF/DEPENDENCIES
    解決:
build.gradle中添加如下代碼
packagingOptions {
    exclude 'META-INF/DEPENDENCIES.txt'
    exclude 'META-INF/LICENSE.txt'
    exclude 'META-INF/NOTICE.txt'
    exclude 'META-INF/NOTICE'
    exclude 'META-INF/LICENSE'
    exclude 'META-INF/DEPENDENCIES'
    exclude 'META-INF/notice.txt'
    exclude 'META-INF/license.txt'
    exclude 'META-INF/dependencies.txt'
    exclude 'META-INF/LGPL2.1'
}
  • 3.android studio加載不到so文件
    解決:
sourceSet.main中添加 jniLibs.srcDirs= ['libs']
  • 4.終端輸入./gradlew提示 bash: ./gradlew : Permission denied
    解決:
chmod 777 ./gradlew
  • 5.終端命令./gradlew assemble時(shí)候報(bào)錯(cuò),Caused by:org.gradle.api.InvalidUserDataException: File specified for property 'signingConfig.storeFile' does not exist.
    解決:
build.gradle中配置的signingConfig中的key地址不對(duì)
  • 6.終端命令./gradlew assemble時(shí)候報(bào)錯(cuò),com.android.builder.packaging.SigningException: Failed to read key from keystore
    解決:
檢查build.gradle中配置的signingConfig中的alias和password是否正確
  • 7.de.greenrobot.dao.DaoException: Could not init DAOConfig
    解決:
混淆文件中添加greenDao的混淆
-keepclassmembersclass * extends de.greenrobot.dao.AbstractDao {
    public static java.lang.String TABLENAME;
}
-keepclass **$Properties
  • 8.AndroidStudio2.0正式版項(xiàng)目build failed,console里報(bào)錯(cuò)your project contains non-asicII characters
    解決:
本地項(xiàng)目路徑中包含中文,把項(xiàng)目所在的目錄名改為英文即可
  • 9.AndroidStudio在小米手機(jī)上run不起來(lái),報(bào)install_failed_canceled_by_user
    解決:
小米手機(jī)安全中心的問(wèn)題,設(shè)置-更多應(yīng)用-安全中心,點(diǎn)擊卸載更新,然后就可以運(yùn)行了。應(yīng)該是安全中心最新的更新包,導(dǎo)致run不起來(lái)
  • 10.could not find com.android.support.constraint-layout
    解決:
在工具欄選擇 Tools --> Android --> SDK Manager,勾選上 Support Repository中 的 ConstraintLayout for Android 和 Solver for 
  • 11.some file crunching failed see logs for d
    解決:
module的build.gradle中,在android{}中新增aaptOptions.cruncherEnabled = false
    aaptOptions.useNewCruncher = false

-12.release-stripped.ap_' specified for property 'resourceFile' does not exist.
解決:

設(shè)置buildTypes里的release的shrinkResources為false即可,如果是 release-stripped.ap_' specified for property 'resourceFile' does not exist.則設(shè)置buildTypes里的debug的shrinkResources為false
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容