当前位置: 首页 > article >正文

Android 开发 Gradle 相关问题

1、Gradle 无法下载 / 下载慢的问题

Could not install Gradle distribution from 'https://services.gradle.org/distributions/gradle-8.10.2-all.zip'. Reason: java.net.SocketTimeoutException: Read timed out

解决:使用国内的镜像站点加速下载。

以下是一些国内镜像站点提供的Gradle下载地址:

官网 Gradle 下载地址: https://services.gradle.org/distributions/
腾讯云镜像 Gradle下载地址: https://mirrors.cloud.tencent.com/gradle/
阿里云镜像 Gradle下载地址: https://mirrors.aliyun.com/macports/distfiles/gradle/
阿里云镜像 Gradle下载地址: https://mirrors.aliyun.com/gradle/

国内镜像站点可以更快地获取Gradle的安装包,避免官方下载地址带来的下载速度问题,提高效率。

在这里插入图片描述

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https://mirrors.aliyun.com/macports/distfiles/gradle/gradle-8.10.2-all.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

2、Gradle 插件版本不匹配问题

The project is using an incompatible version (AGP 8.7.2) of the Android Gradle plugin. Latest supported version is AGP 8.5.0See Android Studio & AGP compatibility options.

解决:升级到最新的 Android Studio 即可

参考:https://blog.csdn.net/shulianghan/article/details/130194426

3、RN 真机或模拟器无法连接的一种情况

path: android\app\src\main\AndroidManifest.xml

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools">

    <uses-permission android:name="android.permission.INTERNET" />

    <application
        android:networkSecurityConfig="@xml/network_security_config"
        android:name=".MainApplication"
        android:allowBackup="false"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme"
        >
        <activity
            android:name=".MainActivity"
            android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|screenSize|smallestScreenSize|uiMode"
            android:exported="true"
            android:theme="@style/SplashTheme"
            android:launchMode="singleTask"
            android:windowSoftInputMode="adjustResize">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
</manifest>

解决办法: 检查 network-security-config 配置


<domain-config> 中,允许特定​域名及其子域名使用明文传输(HTTP)非加密连接(cleartextTrafficPermitted="true"):
10.0.2.2(通常用于 Android 模拟器访问本地开发服务器)
localhost(本地调试)
​默认禁止其他所有明文传输

<base-config> 中,设置了 cleartextTrafficPermitted=“false”,这意味着除了上述明确列出的域名外,其他所有网络请求都必须使用 HTTPS 加密连接。同时只信任系统预装的 CA 证书(<certificates src="system" />),这是推荐的安全做法。`

<network-security-config>
    <domain-config cleartextTrafficPermitted="true">
        <domain includeSubdomains="true">api.example.net</domain>
        <domain includeSubdomains="true">10.0.2.2</domain>
        <domain includeSubdomains="true">localhost</domain>
    </domain-config>
    <base-config cleartextTrafficPermitted="false">
        <trust-anchors>
            <certificates src="system" />
        </trust-anchors>
    </base-config>
</network-security-config>

4、command node 错误

FAILURE: Build failed with an exception.
What went wrong: Execution failed for task ':expo-constants:createDebugExpoConfig'. A problem occurred starting process 'command 'node''

解决:更改 Android Studio 设置 使用 JDK 17

参考:
https://github.com/expo/expo/issues/28309
https://reactnative.dev/docs/set-up-your-environment?platform=android#installing-dependencies

-> java --version
openjdk 17.0.10 2024-01-16 LTS
OpenJDK Runtime Environment Zulu17.48+15-CA (build 17.0.10+7-LTS)
OpenJDK 64-Bit Server VM Zulu17.48+15-CA (build 17.0.10+7-LTS, mixed mode, sharing)

在这里插入图片描述

5、新架构下的 RN cmake 编译问题

[CXX1429] error when building with cmake using xxx\node_modules\react-native-gesture-handler\android\src\main\jni\CMakeLists.txt: -- The C compiler identification is Clang 17.0.2

Caused by: org.gradle.process.internal.ExecException: Process 'command '/Android/sdk/cmake/3.22.1/bin/cmake'' finished with non-zero exit value 1

在这里插入图片描述

初步判断是 第三方依赖包没有自动 autolink 导致 Android Studio 找不到包。

重新拉取新项目可能解决。

https://github.com/facebook/react-native/issues/47666

原文地址:https://blog.csdn.net/qq_44721831/article/details/146152524
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.kler.cn/a/612796.html

相关文章:

  • IIS (Internet Information Services) 基本配置指南
  • 计算机二级WPS Office第四套电子表格
  • 快速排序不啦不啦
  • 工作记录 2017-03-10
  • Success is the sum of small efforts repeated day in and day out.
  • VLAN 聚合
  • skynet.socket.limit 使用详解
  • Ubuntu里安装Jenkins
  • 整理和记录前端常见问题
  • 科技快讯 | 谷歌发布新一代推理模型;我国成功发射天链二号04星;Manus:将举行线下活动 正努力让更多人用上Manus
  • 如何查看 SQL Server 的兼容性级别
  • MySQL 表连接(内连接与外连接)
  • HCIA-Datacom高阶:基础的单区域 OSPF 与多区域 OSPF的配置
  • OpenGL —— 流媒体播放器 - ffmpeg解码rtsp流,opengl渲染yuv视频(附源码,glfw+glad)
  • Docker安装MySql 8.0
  • Modbus主站EtherNet/IP转ModbusRTU/ASCII工业EIP网关串口服务器
  • 企业签名app部分用户能安装,部分用户不能安装
  • Java基础——面向对象
  • vue3 数据监听(watch、watchEffect)
  • Go常用的设计模式