zhibo/编译错误修复.md
2026-01-03 17:01:58 +08:00

43 lines
999 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 编译错误修复
## 问题
```
错误: 找不到符号
Integer streamerId = AuthHelper.getUserId(this);
符号: 方法 getUserId(StreamerCenterActivity)
位置: 类 AuthHelper
```
## 原因
`AuthHelper` 类没有 `getUserId()` 方法。应该使用 `AuthStore.getUserId()` 方法,且该方法返回的是 `String` 类型,不是 `Integer`
## 解决方案
已修复 `StreamerCenterActivity.java` 中的 `loadTotalLikes()` 方法:
```java
// 修复前(错误)
Integer streamerId = AuthHelper.getUserId(this);
// 修复后(正确)
String streamerIdStr = AuthStore.getUserId(this);
if (streamerIdStr == null) return;
try {
int streamerId = Integer.parseInt(streamerIdStr);
// ... 使用streamerId
} catch (NumberFormatException e) {
// 用户ID格式错误忽略
}
```
## 状态
✅ 已修复,现在可以正常编译了。
## 编译命令
```bash
cd android-app
./gradlew assembleDebug
```
或在Android Studio中直接点击"Build" -> "Make Project"。