美文网首页
android-fat-aar打包问题修复

android-fat-aar打包问题修复

作者: linwaiwai | 来源:发表于2017-11-03 16:35 被阅读102次

    使用android-fat-aar打包出现R.java文件找不到symbol的问题。

    if (rTxt.exists()) {
        rTxt.eachLine {
            line ->
                //noinspection GroovyUnusedAssignment
                def (type, subclass, name, value) = line.tokenize(' ')
                rMap[subclass].putAt(name, type)
        }
    }
    
    def sb = "package $aarPackageName;" << '\n' << '\n'
    sb << 'public final class R {' << '\n'
    
    rMap.each {
        subclass, values ->
            sb << "  public static final class $subclass {" << '\n'
            values.each {
                name, type ->
                    sb << "    public static $type $name = ${libPackageName}.R.${subclass}.${name};" << '\n'
            }
            sb << "    }" << '\n'
    }
    
    sb << '}' << '\n'
    
    
    if (rTxt.exists()) {
        rTxt.eachLine {
            line ->
                //noinspection GroovyUnusedAssignment
                def (type, subclass, name, value) = line.tokenize(' ')
                // 修改处理无法找到资源依赖问题
                rMap[subclass].putAt(type + " " + name , line.replace(type+ " " + subclass + " " + name, "" ))
        }
    }
    
    def sb = "package $aarPackageName;" << '\n' << '\n'
    sb << 'public final class R {' << '\n'
    
    rMap.each {
        subclass, values ->
            sb << "  public static final class $subclass {" << '\n'
            values.each {
                name, value ->
                    sb << "    public static $name = ${value};" << '\n'
            }
            sb << "    }" << '\n'
    }
    
    sb << '}' << '\n'     
    

    相关文章

      网友评论

          本文标题:android-fat-aar打包问题修复

          本文链接:https://www.haomeiwen.com/subject/cdwtmxtx.html