安卓Android各种报错网络(会连续更新)

手机游戏开发者 2024-9-27 05:52:36 58 0 来自 中国
条件

Android Studio版本

1.png Android Studio Bumblebee | 2021.1.1 Patch 2Build #AI-211.7628.21.2111.8193401, built on February 17, 2022Runtime version: 11.0.11+0-b60-7590822 x86_64VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.macOS 12.3.1GC: G1 Young Generation, G1 Old GenerationMemory: 1280MCores: 12Registry: external.system.auto.import.disabled=true, debugger.watches.in.variables=falseNon-Bundled Plugins: com.huangmb.idea (1.1), Dart (211.7808), com.localizely.flutter-intl (1.17.1-2020.3), org.moe.community (1.4.10), org.jetbrains.kotlin (211-1.6.10-release-923-AS7442.40), io.flutter (65.2.2), org.intellij.plugins.markdown (211.7142.37)工程设置,targetSdk 32,支持Android12
plugins {    id 'com.android.application'}android {    compileSdk 32    defaultConfig {        applicationId "com.example.espprovisiondemo"        minSdk 21        targetSdk 32        versionCode 1        versionName "1.0"        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"    }    buildTypes {        release {            minifyEnabled false            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'        }    }    compileOptions {        sourceCompatibility JavaVersion.VERSION_1_8        targetCompatibility JavaVersion.VERSION_1_8    }}dependencies {    implementation 'androidx.appcompat:appcompat:1.3.0'    implementation 'com.google.android.material:material:1.4.0'    implementation 'androidx.constraintlayout:constraintlayout:2.0.4'    testImplementation 'junit:junit:4.13.2'    androidTestImplementation 'androidx.test.ext:junit:1.1.3'    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'    implementation 'com.github.espressif:esp-idf-provisioning-android:lib-2.0.11'}报错一

安卓12大概更高版本,新建的android工程,直接run,有大概会报下面的错
Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8
Failed to apply plugin 'com.android.internal.application'.
Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8.
You can try some of the following options:
- changing the IDE settings.
- changing the JAVA_HOME environment variable.
- changing org.gradle.java.home in gradle.properties.
办理办法
Android Studio --> Preferences --> Build,Execution,Deployment -->Build Tools --> Gradle  选择Java11的SDK
2.png 报错二

安卓12大概更高版本,新建的android工程,直接run,安装得手机上有大概会报下面的错
Installation did not succeed. The application could not be installed: INSTALL_FAILED_TEST_ONLY
3.png 办理办法
在项目根目次下,找到gradle.properties文件,并打开,添加下面的代码,
android.injected.testOnly=false添加完成,点击右上角,同步一下,如下图所示
报错三

安卓12大概更高版本,用Gradle的方式,导入第三方库时大概会碰到下面报错
Failed to resolve:XXX,导入第三方库没有乐成
案例:
用Gradle的方式,集成第三方库ESP32到工程内里
按照第三方库ESP32作者的指导,



  • 在工程根路径下的build.gradle,加入如下代码maven { url 'https://jitpack.io' }
allprojects {    repositories {     ...     maven { url 'https://jitpack.io' }    }}

  • 在app目次下build.gradle,加入如下代码
implementation 'com.github.espressif:esp-idf-provisioning-android:lib-2.0.11' 8.png 按正常是会合成乐成,但结果是如下报错Build was configured to prefer settings repositories over project repositories but repository 'Google' was added by build file 'build.gradle'
Build was configured to prefer settings repositories over project repositories but repository 'Google' was added by build file 'build.gradle'办理办法
在工程根路径下的build.gradle,加入如下代码maven { url 'https://jitpack.io' }
上面的第一步,不应该加在根路径下的build.gradle,而是加到根路径下的settings.gradle,这个应该是安卓12大概高版本的设置要求,如下:

10.png
这个时间,再去同步一下,就可以了。在Activity内里实验引入,如下,发现已经有提示,乐成了!!!

报错四

2 files found with path 'META-INF/DEPENDENCIES' from inputs:报错
> Task :app:mergeDebugJavaResource FAILEDExecution failed for task ':app:mergeDebugJavaResource'.> A failure occurred while executing com.android.build.gradle.internal.tasks.MergeJavaResWorkAction   > 2 files found with path 'META-INF/DEPENDENCIES' from inputs:      - C:\Users\admin\.gradle\wrapper\dists\gradle-6.8-bin\caches\transforms-3\c9524869f844e5aa0e4c08903f15e41f\transformed\jetified-httpclient-4.5.6.jar      - C:\Users\admin\.gradle\wrapper\dists\gradle-6.8-bin\caches\transforms-3\d37663de769a65fb667ce308a29d0c3c\transformed\jetified-httpcore-4.4.10.jar     Adding a packagingOptions block may help, please refer to     https://google.github.io/android-gradle-dsl/current/com.android.build.gradle.internal.dsl.PackagingOptions.html     for more information * Try:Run with --info or --debug option to get more log output. Run with --scan to get full insights.办理办法
在报该编译错误的module的build.gradle中加入如下设置项,扫撤除中心天生的META-INF/DEPENDENCIES文件 ,
android {     packagingOptions    {        exclude'META-INF/DEPENDENCIES'    }}结尾

本日的分享至此靠近尾声喽,小伴们,觉得有点用的话,大概已经看到这内里来的请点赞加关注吧~~
后续分享更多Android原生技能及物联网技能相干文章。假如有任何疑问的话,接待在下方留言~
您需要登录后才可以回帖 登录 | 立即注册

Powered by CangBaoKu v1.0 小黑屋藏宝库It社区( 冀ICP备14008649号 )

GMT+8, 2024-11-22 01:31, Processed in 0.172649 second(s), 35 queries.© 2003-2025 cbk Team.

快速回复 返回顶部 返回列表