How to add other file into android build

magic

Active member
3rd Party Module Dev
3rd Party Tool Dev
Joined
Mar 5, 2018
Messages
226
I see the implimentation of admob in admob.cxs file:
Code:
#LIBS+="${CD}/native/GoogleMobileAds.framework"

I don't fully understand what the command LIBS do. I guess it add the file GoogleMobileAds.framework into build. But I wonder where should command LIBS add the file into. The command just give source location but where do it destination at?

Is there any other command we can use to add file into build. For example if I want to add some.java file into this location: "..build\android\app\src\main\java\my\other\package\some.java".

How do I do that in code?
 

MikeHart

Administrator
Joined
Jun 19, 2017
Messages
3,298
The libs prepocessor statememt tells Android studio to link to that standard library.
To add native files, the import statement does just that. Admob does this.
 

magic

Active member
3rd Party Module Dev
3rd Party Tool Dev
Joined
Mar 5, 2018
Messages
226
Sometime, when i creating a modules, I need to add other packages which should be put on it own package structure like:
se.simbio.encryption below:

addfile.jpg


Can I copy those files and folders (trees) into ..main/java/com/*.* folder by code? Is it possible
 

MikeHart

Administrator
Joined
Jun 19, 2017
Messages
3,298
Sorry for taking so long to answer. The #SRCS directive can do that.

For an example, this:

Cerberus:
#SRCS+="${CD}/native/android_iab/src/main/aidl/com/android/vending/billing/IInAppBillingService.aidl;"

Copies this:

1653817743784.png


Into the build folder at

1653817797374.png


Hope it helps
 

MikeHart

Administrator
Joined
Jun 19, 2017
Messages
3,298
The code responsible to copy this in the android builder of Trans is the following:

Cerberus:
        'copy src files
        For Local src:=Eachin GetConfigVar( "SRCS" ).Split( ";" )
            Select ExtractExt( src )
            Case "java","aidl"
                Local i:=src.FindLast( "/src/" )
                If i<>-1
                    Local dst:=src[i+1..]
                    If CreateDirRecursive( ExtractDir( "app/"+dst ) )
                        CopyFile src,"app/"+dst
                    Endif
                Endif
            Case "xml"
                Local i:=src.FindLast( "/src/" )
                If i<>-1
                    Local dst:=src[i+1..]
                    If CreateDirRecursive( ExtractDir( "app/"+dst ) )
                        Local str:=LoadString( src )
                        str=ReplaceEnv( str )
                        SaveString str,"app/"+dst
                    Endif
                Endif
            End
        Next

So you can see it only copies files with the ending java, xml or aidl. The destination is everything after the /src/ string in the statement and placed inside the app folder.
 

magic

Active member
3rd Party Module Dev
3rd Party Tool Dev
Joined
Mar 5, 2018
Messages
226
Thank you so much. This really clear things up.

So you can see it only copies files with the ending java, xml or aidl
Look like only 3 file types. Sometimes we need other filetypes like json (for example google-service) and sometimes a folder. I can see that the extension is used to determine the target location.

suggestion: I think we can do something to trans to be able to copy something else or a folder like this:

Cerberus:
#SRCS+="${CD}/native/bla/src/bla1/bla2/*;"
will copy all files in src dir into this dir: build/android/bla1/bla2/*

This is the draft trans code:
Cerberus:
            Case "*"
                Local i:=src.FindLast( "/src/" )
                If i<>-1
                    Local dst:=src[i+1..]
                    If CreateDirRecursive( ExtractDir( dst ) )
                        CopyDirContent str,dst
                    Endif
                Endif
            End
 
Top Bottom