Coder Social home page Coder Social logo

Comments (4)

maxim-petlyuk avatar maxim-petlyuk commented on June 14, 2024

Sorry, any update on this?

from android-fat-aar.

jolly336 avatar jolly336 commented on June 14, 2024

@siddpande Hi,did you solved this already?any idea?Thanks~

from android-fat-aar.

sipande avatar sipande commented on June 14, 2024

No, had to move away from fat arr due to this issue.

from android-fat-aar.

goolong avatar goolong commented on June 14, 2024

you can filter none exist id,hope this will help you
`task generateRJava << {
println "Running FAT-AAR Task :generateRJava"

// Now generate the R.java file for each embedded dependency
def mainManifestFile = android.sourceSets.main.manifest.srcFile;
def libPackageName = "";

if(mainManifestFile.exists()) {

    libPackageName = new XmlParser().parse(mainManifestFile).@package
}

def rClassFile = file("$generated_rsrc_dir/com/didi/unified/pay/R.java")
def rClassMap = new ConfigObject()

def subClassName = null

if (rClassFile.exists()) {
    rClassFile.eachLine {
        line ->
            line = line.trim()
            if(line.contains("public static final class ")) {
                def subline = line.substring(("public static final class ").length())
                subClassName = subline.substring(0, subline.indexOf(" "))
            } else if (line.contains("public static int ")) {
                def subline = line.substring(("public static int ").length())
                def name = subline.substring(0, subline.indexOf("="))
                rClassMap[subClassName].putAt(name, 1)
            }
    }
}


embeddedAarDirs.each { aarPath ->

    def manifestFile = file("$aarPath/AndroidManifest.xml");
    if(!manifestFile.exists()) {
        manifestFile = file("./src/main/AndroidManifest.xml");
    }

    if(manifestFile.exists()) {
        def aarManifest = new XmlParser().parse(manifestFile);
        def aarPackageName = aarManifest.@package

        String packagePath = aarPackageName.replace('.', '/')

        // Generate the R.java file and map to current project's R.java
        // This will recreate the class file
        def rTxt = file("$aarPath/R.txt")
        def rMap = new ConfigObject()

        if (rTxt.exists()) {
            rTxt.eachLine {
                line ->
                    //noinspection GroovyUnusedAssignment
                    def (type, subclass, name, value) = line.tokenize(' ')
                    try {
                        if (rClassMap[subclass].containsKey(name)) {
                            rMap[subclass].putAt(name, type)
                        }
                    } catch (Exception e) {
                        e.printStackTrace()
                    }
            }
        }

        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'

        mkdir("$generated_rsrc_dir/$packagePath")
        file("$generated_rsrc_dir/$packagePath/R.java").write(sb.toString())

        embeddedRClasses += "$packagePath/R.class"
        embeddedRClasses += "$packagePath/R\$*.class"
    }

}

}`

from android-fat-aar.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.