How can I compile the exported Android project?

From my understanding, OpenFL creates a complete Android project which it then compiles to create the final apk. I know this is generally a bad idea, but I would like to make some changes to that exported project, and then compile it exactly like OpenFL would. For example, is there a script or somewhere where I can view which commands are called when I compile from FlashDevelop? Thanks.

Try using templates. In the “openfl” or “lime” projects, you’ll find a “templates” directory. This works like a class path. If you add <template path="templates" /> with your own folder, you can create your own files to override or add to the files generated when OpenFL creates the project.

In this way, you should be able to tweak things completely, but if there’s something you want to do that’s fairly common, we’ll definitely want to see if we can help support in a simpler way :slight_smile:

In case the directory thing is too confusing.

It seems that the cpp files in export/android/obj/src can’t be changed by that method?

What I was trying to do, was seeing if I could easily integrate an ad network by implementing it into the exported project… I know this is not a good long-term solution, since whenever I would need to change something in the haxe project it would overwrite my changes, but I was just checking if this could be used as a quick last resort solution, in case I don’t have time to create native extensions.

Oh, that’s a different different story. Yeah, templates won’t work for those files, but there is a way to inject custom C++ using metadata:

private var testVar:Int = 4;

@functionCode("this->testVar += 1;")
@functionTailCode("printf(\"testVar is %d.\", this->testVar);")
private function testCpp():Void {
    testVar *= 2;
}

I never actually tried this, but if all goes well it should print “testVar is 10.

In theory, it would go like this. testVar starts at 4, @:functionCode adds 1, the function body multiplies it by 2, and then @:functionTailCode prints it.

That’s interesting. So it seems that @functionCode will inject the code at the beginning of the function, and @functionTailCode at the end? I’ll give this a try.

You can also lime create extension MyNewExtension to get a basic sample of a new native extension, which should be able to plug in new Java code or C++ code