赞
踩
注: 此博客为记录个人开发过程中遇到的报错问题以及解决方案。
由于不同版本环境等因素影响,解决方案对其他人可能无效。
本博客仅提供一种解决思路,具体问题请具体分析。
- 报错:Connection timed out: connect
- 解决:在Gradle目录下的build.gradle中Google()和jcenter()中间增加
maven{ url 'http://maven.aliyun.com/nexus/content/groups/public/'}
buildscript { repositories { google() maven{ url 'http://maven.aliyun.com/nexus/content/groups/public/'} jcenter() } }
- 报错:Gradle报错:
1: Task failed with an exception. ----------- * What went wrong: A problem was found with the configuration of task ':app:checkDebugManifest' (type 'CheckManifest'). - Type 'com.android.build.gradle.internal.tasks.CheckManifest' property 'manifest' has @Input annotation used on property of type 'File'. Reason: A property of type 'File' annotated with @Input cannot determine how to interpret the file. Possible solutions: 1. Annotate with @InputFile for regular files. 2. Annotate with @InputDirectory for directories. 3. If you want to track the path, return File.absolutePath as a String and keep @Input. Please refer to https://docs.gradle.org/7.0.2/userguide/validation_problems.html#incorrect_use_of_input_annotation for more details about this problem. * Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights. ==============================================================================
- 解决:将gradle-wrapper.properties中的gradle版本降级
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip
修改为
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip
- 报错:降级 Gradle 之后可能会出现 Gradle 与 Java 版本不匹配
Unsupported Java. Your build is currently configured to use Java 17.0.6 and Gradle 6.8.3.
- 参考:Your build is currently configured to use Java 17.0.6 and Gradle 6.8.3
- 解决:
- 方法一:修改 gradle 版本
- 方法二:修改 java 版本
Java版本与Gradle版本对应 Java version First Gradle version to support it 8 2.0 9 4.3 10 4.7 11 5.0 12 5.4 13 6.0 14 6.3 15 6.7 16 7.0 17 7.3 18 7.5 19 7.6 20 8.1 注:在Android Studio修改Java版本方法:
- 报错:Gradle时报错:
Caused by: org.gradle.api.internal.plugins.PluginApplicationException: Failed to apply plugin [id 'com.android.application']
- 参考:解决Gradle报错Caused by: org.gradle.api.internal.plugins.PluginApplicationException
- 解决:在gradle.properties添加 android.overridePathCheck=true
# Project-wide Gradle settings. # IDE (e.g. Android Studio) users: # Gradle settings configured through the IDE *will override* # any settings specified in this file. # For more details on how to configure your build environment visit # http://www.gradle.org/docs/current/userguide/build_environment.html # Specifies the JVM arguments used for the daemon process. # The setting is particularly useful for tweaking memory settings. # Default value: -Xmx10248m -XX:MaxPermSize=256m # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 # When configured, Gradle will run in incubating parallel mode. # This option should only be used with decoupled projects. More details, visit # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects # org.gradle.parallel=true android.overridePathCheck=true
- 报错:Gradle时报错:
Invalid escape sequence at line 1 column 26 path $[0].name
- 参考:android编译时出现Invalid escape sequence at line 1 column 26 path $[0].name
- 解决:在gradle.properties添加 org.gradle.jvmargs=-Dfile.encoding=UTF-8
# Project-wide Gradle settings. # IDE (e.g. Android Studio) users: # Gradle settings configured through the IDE *will override* # any settings specified in this file. # For more details on how to configure your build environment visit # http://www.gradle.org/docs/current/userguide/build_environment.html # Specifies the JVM arguments used for the daemon process. # The setting is particularly useful for tweaking memory settings. # Default value: -Xmx10248m -XX:MaxPermSize=256m # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 # When configured, Gradle will run in incubating parallel mode. # This option should only be used with decoupled projects. More details, visit # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects # org.gradle.parallel=true android.overridePathCheck=true org.gradle.jvmargs=-Dfile.encoding=UTF-8
- 报错:想通过 Android 连接本地搭建一个 SpringBoot 服务器,在浏览器浏览时是 http://127.0.0.1:8080,在 Android 运行时报错:
java.net.ConnectException: Failed to connect to /127.0.0.1:8080
- 参考:java.net.ConnectException: Failed to connect to /127.0.0.1:80-CSDN博客
- 解决:在虚拟机上访问 http://127.0.0.1:8080 ,访问的是虚拟机的本地地址,而不是服务器(即本机)的地址,所以需要把地址改成 10.0.2.2 或者 本机IP地址 来访问。例如:
http://192.168.173.132:8080
http://10.0.2.2:8080
- 报错:
- 参考:
- 解决:
- 报错:
- 参考:
- 解决:
(未完待续...)
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。