Android更改源码后编译错误unknown package name of class file

http://blog.csdn.net/u013686019/article/details/77140477

最近往core_minimal.mk(build/target/product/)的PRODUCT_BOOT_JARS变量中加了一个自己的模块,编译报错:

unknown package name of class file

用grep查找错误的来源,发现出自一个Python脚本:
build/core/tasks/check_boot_jars/check_boot_jars.py

build/core/tasks/check_boot_jars/check_boot_jars.py
def CheckJar(jar):
  """Check a jar file.
  """
  # Get the list of files inside the jar file.
  p = subprocess.Popen(args='jar tf %s' % jar,
      stdout=subprocess.PIPE, shell=True)
  stdout, _ = p.communicate()
  if p.returncode != 0:
    return False
  items = stdout.split()
  for f in items:
    if f.endswith('.class'):
      package_name = os.path.dirname(f)
      package_name = package_name.replace('/', '.')
      # Skip class without a package name
      if package_name and not whitelist_re.match(package_name):
        print >> sys.stderr, ('Error: %s: unknown package name of class file %s'
                              % (jar, f))
        return False
  return True

很明显,如果自己的jar的包名(package name)不在whitelist_re里面的话,编译报错,通过添加log发现whitelist_re来自一个txt文件:

build/core/tasks/check_boot_jars/package_whitelist.txt


查看该文件发现PRODUCT_BOOT_JARS的其他jar的包名都有在这里定义,仿照文件格式把自己的包名添加到这里就OK!

你可能感兴趣的:(Android源码)