常見問題
Minimum supported Gradle version is 7.2. Current version is 6.8. If using the gradle wrapper
看下當前工程目錄中是否存在gradle目錄,如果不存在,創(chuàng)建一個新的工程,拷貝新工程的gradle文件夾到當前工程。gradle中有兩個文件。
androidjava.io.IOException: Unable to tunnel through proxy. Proxy returns “HTTP/1.1 400 Bad Request“
解決方法:
1.找到c盤下的gradle.properties文件
2.將代理注釋
3.在gradle中設置不使用代理,重新加載,問題解決
Could not initialize class com.android.sdklib.repository.AndroidSdkHandler
gradle的版本太老了。將gradle升級。
https://blog.csdn.net/qq_36317441/article/details/122325618
Lint found errors in the project; aborting build.
打包AAR報錯 lint 進行代碼檢查,防止代碼不規(guī)范—如使用了過時的 api。
Lint found errors in the project; aborting build.
Fix the issues identified by lint, or create a baseline to see only new errors:
android {
lint {
baseline = file("lint-baseline.xml")
}
}
解決方法:
在將要打包的模塊中的 build.gradle 文件中添加如下內容,并單擊 sync now。
android {
//...
lintOptions {
abortOnError false
}
}
Android如何引用jar包
Android如何引用jar包
將打包好的jar包添加到需要引入工程的Lib文件夾下。
右鍵點擊此jar包,選擇add as library。
https://developer.android.com/studio/build/dependencies?hl=zh-cn
其他方法
implementation fileTree(dir: 'libs', include: ['*.jar','*.aar'])
Gradle 聲明了對項目的 module_name/libs/ 目錄中 JAR 文件的依賴關系(因為 Gradle 會讀取 build.gradle 文件的相對路徑)。
也就是說Gradle會讀取build.gradle的相對路徑,然后找build.gradle相對路徑/libs/下路徑的libs文件導入到項目中。所以創(chuàng)建的libs的目錄要和build.gradle同級
Android模塊如何使用本地的依賴,忽略項目的依賴。
- 在android的setting中進行以下設置。
- 根據(jù)gradle-wrapper中distributionUrl的值,找到相應的gradle文件,并修改gradle文件添加
android.useAndroidX=true
android.enableJetifier=true
Android Studio R文件爆紅但是項目可以運行
這種原因是你的R文件太大了(超過了Android Studio的上限25.6M了)
解決辦法如下:
Help -> Edit Custom Properties -> create custom properties?(yes) ->添加 idea.max.intellisense.filesize=5000
轉載:https://blog.csdn.net/LosingCarryJie/article/details/79489403
Android查看gradle版本
avc: denied { read } for name=“stat” dev=“proc” ino=4026532449 scontext=u:r:untrusted_app
https://blog.csdn.net/tung214/article/details/72734086
SELinex限制,
限制之后有三種結果:
- An Enforcing SELinux writes that Log AND denied the access. // 強制拒絕 記錄日志且無法獲取信息。
- A Permissive SELinux writes that Log BUT allow the access. // 寫下日志并允許獲取值
- A Disabled SELinux do NOT writes the log AND allow the access. // 不記錄日志并且可以獲取值
缺少權限的補救方法:
https://cloud.tencent.com/developer/article/1662137
Android主動殺死進程
Process.killProcess(Process.myPid());
https://blog.csdn.net/hwe_xc/article/details/50803454
Android導入項目時未具備相應平臺版本。
下載相應平臺版本導入后,在重新sync工程。
Failed to find Platform SDK with path: platforms;android-33
We recommend using a newer Android Gradle plugin to use compileSdk = 33
This Android Gradle plugin (7.1.3) was tested up to compileSdk = 32
清空并退出當前activity所在棧
activity.finishAffinity();
https://blog.csdn.net/xieluoxixi/article/details/53469553
assets 資源存放文檔
https://www.jianshu.com/p/5974fcf88170
webView
https://blog.csdn.net/harvic880925/article/details/51523983
So庫問題
問題:
couldn't find "libHplayers.so"
解決方法:
android {
// 添加so庫
sourceSets{
main{
jniLibs.srcDirs = ['libs']
}
}
}
core版本問題
C:\Users\xxx\.gradle\caches\transforms-2\files-2.1\319492c62ad32ad530467d6d0d6c17f1\core-1.8.0\res\values\values.xml:104:5-113:25: AAPT: error: resource android:a
ttr/lStar not found.
core版本過高導致編譯未通過。可以在build.gradle中添加
}
configurations.all {
resolutionStrategy{
force 'androidx.core:core:1.6.0'
}
}
dependencies {
}
基礎問題
0x0000 十六進制
使用AndroidX報錯
Caused by: com.android.builder.errors.EvalIssueException: This project uses AndroidX dependencies, but the 'android.useAndroidX' property is not enabled. Set this property to true in the gradle.properties file and retry.
解決方法:
添加下面的代碼:
android.useAndroidX=true
android.enableJetifier=true
Android31以及以上可能出現(xiàn)的問題
將測試應用安裝到高版本android手機的時候會報下面的錯誤。
解決此錯誤,在activity的屬性中添加
android:exported="true"
文章來源:http://www.zghlxwxcb.cn/news/detail-646909.html
GC:
文章來源地址http://www.zghlxwxcb.cn/news/detail-646909.html
gradle構建AAR時遇到的問題
到了這里,關于Android開發(fā)常見問題的文章就介紹完了。如果您還想了解更多內容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關文章,希望大家以后多多支持TOY模板網(wǎng)!