Android | 开发过程遇到的报错以及解决方法

注: 此博客为记录个人开发过程中遇到的报错问题以及解决方案。

        由于不同版本环境等因素影响,解决方案对其他人可能无效。

        本博客仅提供一种解决思路,具体问题请具体分析。

  • 报错: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.
Java版本与Gradle版本对应
Java versionFirst Gradle version to support it
82.0
94.3
104.7
115.0
125.4
136.0
146.3
156.7
167.0
177.3
187.5
197.6
208.1

                注:在Android Studio修改Java版本方法:

  • 报错:Gradle时报错:
Caused by: org.gradle.api.internal.plugins.PluginApplicationException: 
Failed to apply plugin [id 'com.android.application']
# 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
# 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
http://192.168.173.132:8080
http://10.0.2.2:8080
  • 报错:
  • 参考:
  • 解决:
  • 报错:
  • 参考:
  • 解决:

(未完待续...) 

  • 4
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值