feat: 添加模拟器卸载应用测试功能并优化构建配置
- 新增模拟器卸载应用UI测试功能及相关测试图片 - 添加本地Gradle初始化脚本和构建脚本 - 更新Gradle版本至9.0并优化仓库配置 - 修复布局文件中的重复元素和警告 - 增加构建警告修复文档 - 优化模拟器控制类功能
This commit is contained in:
2
.idea/compiler.xml
generated
2
.idea/compiler.xml
generated
@@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="CompilerConfiguration">
|
<component name="CompilerConfiguration">
|
||||||
<bytecodeTargetLevel target="17" />
|
<bytecodeTargetLevel target="21" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
||||||
8
.idea/deploymentTargetSelector.xml
generated
8
.idea/deploymentTargetSelector.xml
generated
@@ -4,6 +4,14 @@
|
|||||||
<selectionStates>
|
<selectionStates>
|
||||||
<SelectionState runConfigName="app">
|
<SelectionState runConfigName="app">
|
||||||
<option name="selectionMode" value="DROPDOWN" />
|
<option name="selectionMode" value="DROPDOWN" />
|
||||||
|
<DropdownSelection timestamp="2026-02-27T15:49:43.818231300Z">
|
||||||
|
<Target type="DEFAULT_BOOT">
|
||||||
|
<handle>
|
||||||
|
<DeviceId pluginId="LocalEmulator" identifier="path=C:\Users\xiaji\.android\avd\Medium_Phone_API_34.avd" />
|
||||||
|
</handle>
|
||||||
|
</Target>
|
||||||
|
</DropdownSelection>
|
||||||
|
<DialogSelection />
|
||||||
</SelectionState>
|
</SelectionState>
|
||||||
</selectionStates>
|
</selectionStates>
|
||||||
</component>
|
</component>
|
||||||
|
|||||||
13
.idea/deviceManager.xml
generated
Normal file
13
.idea/deviceManager.xml
generated
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="DeviceTable">
|
||||||
|
<option name="columnSorters">
|
||||||
|
<list>
|
||||||
|
<ColumnSorterState>
|
||||||
|
<option name="column" value="Name" />
|
||||||
|
<option name="order" value="ASCENDING" />
|
||||||
|
</ColumnSorterState>
|
||||||
|
</list>
|
||||||
|
</option>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
3
.idea/misc.xml
generated
3
.idea/misc.xml
generated
@@ -1,7 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_21" default="true" project-jdk-name="jbr-17" project-jdk-type="JavaSDK">
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_21" default="true" project-jdk-name="jbr-21" project-jdk-type="JavaSDK">
|
||||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectType">
|
<component name="ProjectType">
|
||||||
|
|||||||
138
FIX_GRADLE_WARNINGS.md
Normal file
138
FIX_GRADLE_WARNINGS.md
Normal file
@@ -0,0 +1,138 @@
|
|||||||
|
# Gradle 构建警告修复完成报告
|
||||||
|
|
||||||
|
## 🎉 修复成果总结
|
||||||
|
|
||||||
|
经过本次优化,我们成功解决了项目中的大部分 Gradle 构建警告:
|
||||||
|
|
||||||
|
✅ **已完成的修复:**
|
||||||
|
- 移除了项目中重复的仓库定义
|
||||||
|
- 统一了仓库配置到 settings.gradle.kts
|
||||||
|
- 创建了符合最新语法规范的本地初始化脚本
|
||||||
|
- 项目内部已无 Convention API 警告
|
||||||
|
|
||||||
|
⚠️ **仍存在的警告:**
|
||||||
|
- 用户全局 Gradle 初始化脚本 (`C:\Users\xiaji\.gradle\init.gradle`) 中的已弃用语法警告
|
||||||
|
|
||||||
|
## 📁 新增文件说明
|
||||||
|
|
||||||
|
### 1. 本地初始化脚本
|
||||||
|
`gradle/init/init.gradle` - 符合最新 Gradle 语法规范的初始化脚本
|
||||||
|
|
||||||
|
### 2. 构建脚本
|
||||||
|
`build.ps1` - PowerShell 脚本,可使用本地初始化脚本进行构建
|
||||||
|
|
||||||
|
## 🚀 使用方法
|
||||||
|
|
||||||
|
### 方法一:使用本地初始化脚本(推荐)
|
||||||
|
```powershell
|
||||||
|
powershell -ExecutionPolicy Bypass -File .\build.ps1
|
||||||
|
```
|
||||||
|
|
||||||
|
### 方法二:直接使用 Gradle 命令
|
||||||
|
```bash
|
||||||
|
.\gradlew clean build
|
||||||
|
```
|
||||||
|
|
||||||
|
## 📊 当前状态
|
||||||
|
|
||||||
|
执行 `./gradlew clean --warning-mode=all` 后:
|
||||||
|
- 项目内部警告已全部解决 ✅
|
||||||
|
- 仅剩用户全局配置的警告(不影响项目构建)
|
||||||
|
- 构建过程正常完成 ✅
|
||||||
|
|
||||||
|
## 📝 后续建议
|
||||||
|
|
||||||
|
如需完全消除所有警告,建议:
|
||||||
|
1. 备份当前的 `C:\Users\xiaji\.gradle\init.gradle`
|
||||||
|
2. 将其中的 `url 'xxx'` 语法修改为 `url = uri('xxx')`
|
||||||
|
3. 或者删除该文件,让项目使用我们提供的本地配置
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
# 原始修复指南
|
||||||
|
|
||||||
|
## 问题分析
|
||||||
|
|
||||||
|
当前构建过程中出现两类警告:
|
||||||
|
|
||||||
|
1. **Groovy DSL 已弃用语法警告** (12个)
|
||||||
|
- 位置:用户全局 Gradle 初始化脚本 `C:\Users\xiaji\.gradle\init.gradle`
|
||||||
|
- 原因:使用了 `url 'xxx'` 语法,应改为 `url = uri('xxx')`
|
||||||
|
|
||||||
|
2. **Convention API 已弃用警告** (2个)
|
||||||
|
- 位置:项目构建配置中
|
||||||
|
- 原因:使用了已弃用的 Convention API
|
||||||
|
|
||||||
|
## 解决方案
|
||||||
|
|
||||||
|
### 1. 修复用户全局 Gradle 初始化脚本
|
||||||
|
|
||||||
|
将 `C:\Users\xiaji\.gradle\init.gradle` 文件中的以下语法:
|
||||||
|
|
||||||
|
```groovy
|
||||||
|
// ❌ 错误写法(已弃用)
|
||||||
|
maven { url 'https://repo.huaweicloud.com/repository/gradle/' }
|
||||||
|
|
||||||
|
// ✅ 正确写法
|
||||||
|
maven { url = uri('https://repo.huaweicloud.com/repository/gradle/') }
|
||||||
|
```
|
||||||
|
|
||||||
|
需要修改的所有位置:
|
||||||
|
- 第7行:pluginManagement.repositories.maven.url
|
||||||
|
- 第8行:pluginManagement.repositories.maven.url
|
||||||
|
- 第9行:pluginManagement.repositories.maven.url
|
||||||
|
- 第18行:dependencyResolutionManagement.repositories.maven.url
|
||||||
|
- 第19行:dependencyResolutionManagement.repositories.maven.url
|
||||||
|
- 第20行:dependencyResolutionManagement.repositories.maven.url
|
||||||
|
- 第31行:buildscript.repositories.maven.url
|
||||||
|
- 第32行:buildscript.repositories.maven.url
|
||||||
|
- 第33行:buildscript.repositories.maven.url
|
||||||
|
- 第37行:repositories.maven.url
|
||||||
|
- 第38行:repositories.maven.url
|
||||||
|
- 第39行:repositories.maven.url
|
||||||
|
|
||||||
|
### 2. 项目配置优化建议
|
||||||
|
|
||||||
|
虽然项目本身配置正确,但可以进一步优化:
|
||||||
|
|
||||||
|
#### 修改 settings.gradle.kts
|
||||||
|
```kotlin
|
||||||
|
dependencyResolutionManagement {
|
||||||
|
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) // 保持现状
|
||||||
|
repositories {
|
||||||
|
google()
|
||||||
|
mavenCentral()
|
||||||
|
maven { url = uri("https://jitpack.io") }
|
||||||
|
// 移除重复的阿里云镜像,因为已在全局配置中设置
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
#### 修改 build.gradle.kts
|
||||||
|
```kotlin
|
||||||
|
allprojects {
|
||||||
|
repositories {
|
||||||
|
// 移除这些仓库定义,因为已在 settings 中统一管理
|
||||||
|
// google()
|
||||||
|
// mavenCentral()
|
||||||
|
// maven { url = uri("https://jitpack.io") }
|
||||||
|
// 阿里云镜像源也移除(由全局配置处理)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## 验证修复结果
|
||||||
|
|
||||||
|
执行以下命令验证警告是否消除:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
./gradlew clean --warning-mode=all
|
||||||
|
```
|
||||||
|
|
||||||
|
预期结果:应该不再出现 Groovy DSL 语法警告和 Convention API 警告。
|
||||||
|
|
||||||
|
## 注意事项
|
||||||
|
|
||||||
|
1. 修改全局 init.gradle 文件会影响所有 Gradle 项目
|
||||||
|
2. 如果只希望影响当前项目,可以将镜像配置移到项目本地的 settings.gradle.kts 中
|
||||||
|
3. 建议备份原始 init.gradle 文件后再进行修改
|
||||||
@@ -87,24 +87,30 @@
|
|||||||
android:layout_marginTop="16dp"
|
android:layout_marginTop="16dp"
|
||||||
android:orientation="vertical" />
|
android:orientation="vertical" />
|
||||||
|
|
||||||
|
<!-- 图片选择区域 -->
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/choosepictextView"
|
android:id="@+id/textViewImageHint"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="设置主页的背景图片"
|
android:text="点击按钮选择图片作为背景"
|
||||||
android:textSize="16sp" />
|
android:layout_below="@id/buttonChooseImage"
|
||||||
|
android:layout_centerHorizontal="true"
|
||||||
|
android:layout_marginTop="10dp" />
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/choseePicbutton"
|
android:id="@+id/buttonChooseImage"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_below="@id/choosepictextView"
|
android:text="选择图片"
|
||||||
android:text="选择图片" />
|
android:layout_centerHorizontal="true"
|
||||||
|
android:layout_marginTop="20dp" />
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
|
<!-- 颜色选择区域 -->
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="wrap_content">
|
||||||
@@ -177,27 +183,5 @@
|
|||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
<RelativeLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/textViewImageHint"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="点击按钮选择图片作为背景"
|
|
||||||
android:layout_below="@id/buttonChooseImage"
|
|
||||||
android:layout_centerHorizontal="true"
|
|
||||||
android:layout_marginTop="10dp" />
|
|
||||||
|
|
||||||
<Button
|
|
||||||
android:id="@+id/buttonChooseImage"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="选择图片"
|
|
||||||
android:layout_centerHorizontal="true"
|
|
||||||
android:layout_marginTop="20dp" />
|
|
||||||
</RelativeLayout>
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
187
app/src/main/res/layout/activity_second_fixed.xml
Normal file
187
app/src/main/res/layout/activity_second_fixed.xml
Normal file
@@ -0,0 +1,187 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:padding="16dp"
|
||||||
|
tools:ignore="ExtraText">
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/btnGoBack"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/back_to_main" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="30dp"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:text="文字处理AI区的配置"
|
||||||
|
android:textSize="16sp" />
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/etApiButtonName"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="16dp"
|
||||||
|
android:hint="API 按钮显示名称"
|
||||||
|
android:minHeight="48dp" />
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/etApiName"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="16dp"
|
||||||
|
android:hint="API 名称"
|
||||||
|
android:minHeight="48dp" />
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/etApiUrl"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="8dp"
|
||||||
|
android:hint="API URL"
|
||||||
|
android:minHeight="48dp" />
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/etApiKey"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="8dp"
|
||||||
|
android:hint="@string/api_key"
|
||||||
|
android:minHeight="48dp" />
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/etApiSecretKey"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="8dp"
|
||||||
|
android:hint="API Secret Key"
|
||||||
|
android:minHeight="48dp" />
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/etApiModel"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="8dp"
|
||||||
|
android:hint="API 模型类型"
|
||||||
|
android:minHeight="48dp" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/btnSave"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="16dp"
|
||||||
|
android:text="@string/save_config" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/llConfigList"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="16dp"
|
||||||
|
android:orientation="vertical" />
|
||||||
|
|
||||||
|
<!-- 图片选择区域 -->
|
||||||
|
<RelativeLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/textViewImageHint"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="点击按钮选择图片作为背景"
|
||||||
|
android:layout_below="@id/buttonChooseImage"
|
||||||
|
android:layout_centerHorizontal="true"
|
||||||
|
android:layout_marginTop="10dp" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/buttonChooseImage"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="选择图片"
|
||||||
|
android:layout_centerHorizontal="true"
|
||||||
|
android:layout_marginTop="20dp" />
|
||||||
|
</RelativeLayout>
|
||||||
|
|
||||||
|
<!-- 颜色选择区域 -->
|
||||||
|
<RelativeLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/statustextView"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="点击以下按钮,设置主页状态栏的颜色"
|
||||||
|
android:textSize="16sp" />
|
||||||
|
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_below="@id/statustextView">
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/button_holo_red_light"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="20dp"
|
||||||
|
android:layout_marginEnd="5dp"
|
||||||
|
android:background="@android:color/holo_red_light"
|
||||||
|
app:layout_constraintEnd_toStartOf="@+id/button_holo_green_light"
|
||||||
|
app:layout_constraintHorizontal_bias="0.5"
|
||||||
|
app:layout_constraintHorizontal_weight="1"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
tools:ignore="TouchTargetSizeCheck,SpeakableTextPresentCheck" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/button_holo_green_light"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="20dp"
|
||||||
|
android:layout_marginEnd="5dp"
|
||||||
|
android:background="@android:color/holo_green_light"
|
||||||
|
app:layout_constraintEnd_toStartOf="@+id/button_holo_blue_light"
|
||||||
|
app:layout_constraintHorizontal_bias="0.5"
|
||||||
|
app:layout_constraintHorizontal_weight="1"
|
||||||
|
app:layout_constraintStart_toEndOf="@+id/button_holo_red_light"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
tools:ignore="TouchTargetSizeCheck,SpeakableTextPresentCheck" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/button_holo_blue_light"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="20dp"
|
||||||
|
android:layout_marginEnd="5dp"
|
||||||
|
android:background="@android:color/holo_blue_light"
|
||||||
|
app:layout_constraintEnd_toStartOf="@+id/button_holo_orange_light"
|
||||||
|
app:layout_constraintHorizontal_bias="0.5"
|
||||||
|
app:layout_constraintHorizontal_weight="1"
|
||||||
|
app:layout_constraintStart_toEndOf="@+id/button_holo_green_light"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
tools:ignore="TouchTargetSizeCheck,SpeakableTextPresentCheck" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/button_holo_orange_light"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="20dp"
|
||||||
|
android:layout_marginEnd="5dp"
|
||||||
|
android:background="@android:color/holo_orange_light"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintHorizontal_bias="0.5"
|
||||||
|
app:layout_constraintHorizontal_weight="1"
|
||||||
|
app:layout_constraintStart_toEndOf="@+id/button_holo_blue_light"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
tools:ignore="TouchTargetSizeCheck,SpeakableTextPresentCheck" />
|
||||||
|
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|
||||||
|
</RelativeLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
</ScrollView>
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<background android:drawable="@drawable/ic_launcher_background" />
|
||||||
|
<foreground android:drawable="@drawable/ic_launcher_foreground" />
|
||||||
|
<monochrome android:drawable="@drawable/ic_launcher_foreground" />
|
||||||
|
</adaptive-icon>
|
||||||
37
build-quick.bat
Normal file
37
build-quick.bat
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
@echo off
|
||||||
|
REM 快速构建脚本 - 使用项目本地配置避免警告
|
||||||
|
|
||||||
|
echo ========================================
|
||||||
|
echo Flomo-AI 项目快速构建脚本
|
||||||
|
echo ========================================
|
||||||
|
echo.
|
||||||
|
|
||||||
|
REM 检查是否提供了参数
|
||||||
|
if "%1"=="" (
|
||||||
|
echo 用法: build-quick.bat [gradle命令参数]
|
||||||
|
echo 示例: build-quick.bat clean
|
||||||
|
echo build-quick.bat assembleDebug
|
||||||
|
echo build-quick.bat test
|
||||||
|
echo.
|
||||||
|
pause
|
||||||
|
exit /b 1
|
||||||
|
)
|
||||||
|
|
||||||
|
echo 正在使用项目本地 Gradle 配置进行构建...
|
||||||
|
echo 命令: %*
|
||||||
|
|
||||||
|
REM 设置使用项目本地初始化脚本
|
||||||
|
set LOCAL_INIT_SCRIPT=%~dp0gradle\init\init.gradle
|
||||||
|
set GRADLE_OPTS=%GRADLE_OPTS% -Dorg.gradle.daemon=false
|
||||||
|
|
||||||
|
echo 初始化脚本路径: %LOCAL_INIT_SCRIPT%
|
||||||
|
echo.
|
||||||
|
|
||||||
|
REM 执行构建
|
||||||
|
call "%~dp0gradlew.bat" %* --init-script="%LOCAL_INIT_SCRIPT%" --warning-mode=summary
|
||||||
|
|
||||||
|
echo.
|
||||||
|
echo ========================================
|
||||||
|
echo 构建完成
|
||||||
|
echo ========================================
|
||||||
|
pause
|
||||||
@@ -1,16 +1,7 @@
|
|||||||
plugins {
|
plugins {
|
||||||
alias(libs.plugins.android.application).apply(false)
|
alias(libs.plugins.android.application) apply false
|
||||||
alias(libs.plugins.kotlin.android).apply(false)
|
alias(libs.plugins.kotlin.android) apply false
|
||||||
}
|
}
|
||||||
|
|
||||||
buildscript {
|
// 仓库配置已移至 settings.gradle.kts 中统一管理
|
||||||
repositories {
|
// 避免重复定义和潜在的配置冲突
|
||||||
google()
|
|
||||||
mavenCentral()
|
|
||||||
}
|
|
||||||
dependencies {
|
|
||||||
classpath(libs.gradle) // 确保这里的版本号是最新的
|
|
||||||
classpath(libs.kotlin.gradle.plugin) // 确保这里的版本号是最新的
|
|
||||||
classpath(libs.gson) // 使用 classpath 而不是 implementation
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
12
build.ps1
Normal file
12
build.ps1
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
# Local Gradle init script PowerShell wrapper
|
||||||
|
|
||||||
|
Write-Host "Using local Gradle init script..." -ForegroundColor Green
|
||||||
|
|
||||||
|
# Set environment variable
|
||||||
|
$env:GRADLE_OPTS = "-Dorg.gradle.init.script=$PWD\gradle\init\init.gradle"
|
||||||
|
|
||||||
|
# Execute Gradle command
|
||||||
|
& "$PWD\gradlew.bat" clean --warning-mode=all
|
||||||
|
|
||||||
|
Write-Host ""
|
||||||
|
Write-Host "Build completed with local init script." -ForegroundColor Green
|
||||||
52
gradle/init/init.gradle
Normal file
52
gradle/init/init.gradle
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
// 项目本地 Gradle 初始化脚本:阿里云镜像源配置
|
||||||
|
// 用于替代用户全局配置,避免已弃用语法警告
|
||||||
|
|
||||||
|
// 1. 插件管理仓库配置
|
||||||
|
gradle.settingsEvaluated { settings ->
|
||||||
|
settings.pluginManagement {
|
||||||
|
repositories {
|
||||||
|
maven { url = uri('https://maven.aliyun.com/repository/google') }
|
||||||
|
maven { url = uri('https://maven.aliyun.com/repository/gradle-plugin') }
|
||||||
|
mavenCentral()
|
||||||
|
gradlePluginPortal()
|
||||||
|
// 备用官方源
|
||||||
|
google {
|
||||||
|
content {
|
||||||
|
includeGroupByRegex("com\\.android.*")
|
||||||
|
includeGroupByRegex("com\\.google.*")
|
||||||
|
includeGroupByRegex("androidx.*")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2. 依赖解析管理配置
|
||||||
|
settings.dependencyResolutionManagement {
|
||||||
|
repositoriesMode.set(RepositoriesMode.PREFER_SETTINGS)
|
||||||
|
repositories {
|
||||||
|
maven { url = uri('https://maven.aliyun.com/repository/google') }
|
||||||
|
maven { url = uri('https://maven.aliyun.com/repository/central') }
|
||||||
|
mavenCentral()
|
||||||
|
google()
|
||||||
|
maven { url = uri('https://jitpack.io') }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3. 兼容旧版 Gradle 的配置
|
||||||
|
allprojects {
|
||||||
|
buildscript {
|
||||||
|
repositories {
|
||||||
|
maven { url = uri('https://maven.aliyun.com/repository/google') }
|
||||||
|
maven { url = uri('https://maven.aliyun.com/repository/gradle-plugin') }
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
repositories {
|
||||||
|
maven { url = uri('https://maven.aliyun.com/repository/google') }
|
||||||
|
maven { url = uri('https://maven.aliyun.com/repository/central') }
|
||||||
|
mavenCentral()
|
||||||
|
google()
|
||||||
|
maven { url = uri('https://jitpack.io') }
|
||||||
|
}
|
||||||
|
}
|
||||||
4
gradle/wrapper/gradle-wrapper.properties
vendored
4
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,6 +1,6 @@
|
|||||||
#Thu Sep 05 19:22:20 CST 2024
|
#Thu Feb 26 22:34:06 CST 2026
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
|
distributionUrl=https\://repo.huaweicloud.com/gradle/gradle-9.0-milestone-1-bin.zip
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
|||||||
13
gradlew-local.bat
Normal file
13
gradlew-local.bat
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
@echo off
|
||||||
|
REM 使用项目本地的 Gradle 初始化脚本,避免全局配置的已弃用语法警告
|
||||||
|
|
||||||
|
echo 正在使用项目本地 Gradle 初始化脚本...
|
||||||
|
|
||||||
|
REM 设置 Gradle 初始化脚本路径
|
||||||
|
set GRADLE_OPTS=%GRADLE_OPTS% -Dorg.gradle.init.script=%~dp0gradle\init\init.gradle
|
||||||
|
|
||||||
|
REM 执行 Gradle 命令
|
||||||
|
call "%~dp0gradlew.bat" %*
|
||||||
|
|
||||||
|
echo.
|
||||||
|
echo 构建完成。使用了项目本地的初始化脚本以避免警告。
|
||||||
BIN
mumu-pytest/__pycache__/conftest.cpython-313-pytest-8.3.4.pyc
Normal file
BIN
mumu-pytest/__pycache__/conftest.cpython-313-pytest-8.3.4.pyc
Normal file
Binary file not shown.
BIN
mumu-pytest/__pycache__/test_mumu.cpython-313-pytest-8.3.4.pyc
Normal file
BIN
mumu-pytest/__pycache__/test_mumu.cpython-313-pytest-8.3.4.pyc
Normal file
Binary file not shown.
@@ -100,6 +100,36 @@ class MumuEmulator:
|
|||||||
pyautogui.press("enter")
|
pyautogui.press("enter")
|
||||||
print("按下回车")
|
print("按下回车")
|
||||||
|
|
||||||
|
def press_home(self):
|
||||||
|
"""按 Home 键返回桌面"""
|
||||||
|
pyautogui.press("home")
|
||||||
|
print("按下 Home 键")
|
||||||
|
|
||||||
|
def right_click(self):
|
||||||
|
"""右键点击"""
|
||||||
|
pyautogui.rightClick()
|
||||||
|
print("右键点击")
|
||||||
|
|
||||||
|
def wait_for_image(self, image_name, confidence=0.8, timeout=30):
|
||||||
|
"""等待图片出现并返回位置"""
|
||||||
|
image_path = os.path.join(self.script_dir, f"{image_name}.png")
|
||||||
|
if not os.path.exists(image_path):
|
||||||
|
print(f"图片不存在: {image_path}")
|
||||||
|
return None
|
||||||
|
|
||||||
|
start_time = time.time()
|
||||||
|
while time.time() - start_time < timeout:
|
||||||
|
try:
|
||||||
|
location = pyautogui.locateOnScreen(image_path, confidence=confidence)
|
||||||
|
if location:
|
||||||
|
print(f"找到图片: {image_name}")
|
||||||
|
return location
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
time.sleep(1)
|
||||||
|
print(f"未找到图片: {image_name}")
|
||||||
|
return None
|
||||||
|
|
||||||
def wait_for_boot(self, timeout=120):
|
def wait_for_boot(self, timeout=120):
|
||||||
"""等待模拟器启动完成"""
|
"""等待模拟器启动完成"""
|
||||||
boot_completed = False
|
boot_completed = False
|
||||||
@@ -126,7 +156,7 @@ class MumuEmulator:
|
|||||||
def run_sequence(self):
|
def run_sequence(self):
|
||||||
"""按顺序执行任务"""
|
"""按顺序执行任务"""
|
||||||
self.bring_to_front()
|
self.bring_to_front()
|
||||||
time.sleep(30)
|
time.sleep(5)
|
||||||
sequence = [
|
sequence = [
|
||||||
"web",
|
"web",
|
||||||
"web_address",
|
"web_address",
|
||||||
@@ -141,7 +171,7 @@ class MumuEmulator:
|
|||||||
|
|
||||||
for image_name in sequence:
|
for image_name in sequence:
|
||||||
if image_name == "web_address":
|
if image_name == "web_address":
|
||||||
for _ in range(60):
|
for _ in range(10):
|
||||||
if self.check_image_exists("web_address"):
|
if self.check_image_exists("web_address"):
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
self.type_text(WEB_URL)
|
self.type_text(WEB_URL)
|
||||||
@@ -152,7 +182,7 @@ class MumuEmulator:
|
|||||||
else:
|
else:
|
||||||
print("web_address 图片不存在,跳过输入URL")
|
print("web_address 图片不存在,跳过输入URL")
|
||||||
else:
|
else:
|
||||||
self.find_and_click(image_name, timeout=60)
|
self.find_and_click(image_name, timeout=10)
|
||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
@@ -162,6 +192,44 @@ class MumuEmulator:
|
|||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def uninstall_app_ui(self):
|
||||||
|
"""通过 UI 卸载 app:按 Home 键 -> 找到 flomo -> 右键 -> Uninstall -> Uninstall Confirm"""
|
||||||
|
self.bring_to_front()
|
||||||
|
time.sleep(2)
|
||||||
|
|
||||||
|
self.press_home()
|
||||||
|
time.sleep(3)
|
||||||
|
|
||||||
|
location = self.wait_for_image("flomo", timeout=30)
|
||||||
|
if not location:
|
||||||
|
print("未找到 flomo 应用图标")
|
||||||
|
return False
|
||||||
|
|
||||||
|
center = pyautogui.center(location)
|
||||||
|
pyautogui.rightClick(center)
|
||||||
|
time.sleep(1)
|
||||||
|
|
||||||
|
location = self.wait_for_image("uninstall", timeout=10)
|
||||||
|
if not location:
|
||||||
|
print("未找到 uninstall 选项")
|
||||||
|
return False
|
||||||
|
|
||||||
|
center = pyautogui.center(location)
|
||||||
|
pyautogui.click(center)
|
||||||
|
time.sleep(1)
|
||||||
|
|
||||||
|
location = self.wait_for_image("uninstall-confirm", timeout=10)
|
||||||
|
if not location:
|
||||||
|
print("未找到卸载确认按钮")
|
||||||
|
return False
|
||||||
|
|
||||||
|
center = pyautogui.center(location)
|
||||||
|
pyautogui.click(center)
|
||||||
|
time.sleep(2)
|
||||||
|
|
||||||
|
print("卸载完成")
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
class AdbHelper:
|
class AdbHelper:
|
||||||
"""ADB命令辅助类"""
|
"""ADB命令辅助类"""
|
||||||
|
|||||||
BIN
mumu-pytest/flomo.png
Normal file
BIN
mumu-pytest/flomo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 11 KiB |
@@ -57,3 +57,13 @@ def test_close_emulator(emulator):
|
|||||||
if emulator.is_running():
|
if emulator.is_running():
|
||||||
emulator.close()
|
emulator.close()
|
||||||
assert not emulator.is_running(), "模拟器关闭失败"
|
assert not emulator.is_running(), "模拟器关闭失败"
|
||||||
|
|
||||||
|
|
||||||
|
def test_uninstall_app(emulator):
|
||||||
|
"""测试卸载 flomo app"""
|
||||||
|
time.sleep(3)
|
||||||
|
if not emulator.is_running():
|
||||||
|
pytest.skip("模拟器未运行")
|
||||||
|
|
||||||
|
result = emulator.uninstall_app_ui()
|
||||||
|
assert result, "卸载 app 失败"
|
||||||
|
|||||||
BIN
mumu-pytest/uninstall-confirm.png
Normal file
BIN
mumu-pytest/uninstall-confirm.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.4 KiB |
BIN
mumu-pytest/uninstall.png
Normal file
BIN
mumu-pytest/uninstall.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.4 KiB |
@@ -1,5 +1,11 @@
|
|||||||
pluginManagement {
|
pluginManagement {
|
||||||
repositories {
|
repositories {
|
||||||
|
// 使用阿里云镜像加速
|
||||||
|
maven { url = uri("https://maven.aliyun.com/repository/google") }
|
||||||
|
maven { url = uri("https://maven.aliyun.com/repository/gradle-plugin") }
|
||||||
|
mavenCentral()
|
||||||
|
gradlePluginPortal()
|
||||||
|
// 备用官方源
|
||||||
google {
|
google {
|
||||||
content {
|
content {
|
||||||
includeGroupByRegex("com\\.android.*")
|
includeGroupByRegex("com\\.android.*")
|
||||||
@@ -7,15 +13,18 @@ pluginManagement {
|
|||||||
includeGroupByRegex("androidx.*")
|
includeGroupByRegex("androidx.*")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mavenCentral()
|
|
||||||
gradlePluginPortal()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
dependencyResolutionManagement {
|
dependencyResolutionManagement {
|
||||||
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
|
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
|
||||||
repositories {
|
repositories {
|
||||||
google()
|
// 使用阿里云镜像加速
|
||||||
|
maven { url = uri("https://maven.aliyun.com/repository/google") }
|
||||||
|
maven { url = uri("https://maven.aliyun.com/repository/central") }
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
|
google()
|
||||||
|
// 添加 JitPack 仓库以支持 PermissionX 等开源库
|
||||||
|
maven { url = uri("https://jitpack.io") }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user