You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Android Studio报错‘Package name doesnt match regex’,包名合规性问题求助

解决Android Studio中“Package name doesn't match regex”报错问题

Hey there, let's break down why you're hitting that "Package name doesn't match regex" error and how to fix it quickly!

问题根源

The core issue here is the uppercase "Utils" in your package name com.mondelicious.yuomi.Utils. Android (and Java/Kotlin) enforces strict rules for package naming, and uppercase letters are not allowed.

官方包名规则回顾

Android requires package names to follow these conventions:

  • All characters must be lowercase letters (a-z), digits (0-9), underscores (_), or dots (.)
  • Cannot start with a digit or underscore
  • Should follow the reverse-domain format (e.g., com.yourcompany.appname)

具体修复步骤

  1. Rename the package to use lowercase
    Change Utils to utils, so your full package name becomes com.mondelicious.yuomi.utils.

  2. Use Android Studio's Refactor tool to update references safely

    • Right-click the Utils package folder in your project structure
    • Select Refactor > Rename
    • Choose Rename Package from the popup options
    • Enter the new lowercase name utils and click Refactor
    • Android Studio will automatically update all related files: your manifest, class declarations, import statements, etc.
  3. Verify key files are updated

    • Check your AndroidManifest.xml to ensure the package attribute matches the new lowercase name:
      <manifest xmlns:android="http://schemas.android.com/apk/res/android"
          package="com.mondelicious.yuomi.utils">
      
    • Open any Kotlin/Java class in the package and confirm the top package declaration is:
      package com.mondelicious.yuomi.utils
      
      (or the equivalent for Java)

额外提醒

Avoid manually editing package names across files—this is error-prone and can leave hidden references broken. The refactor tool is designed to handle all these changes in one go.

内容的提问来源于stack exchange,提问作者Marcus Mondel

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.25 06:38:52