Android Studio Gradle - JavaExec classpath configuration - Java Reflection - class access -


im working on android project have process .java-files possibly generate .java-files should compiled , packed .apk-file.

lets assume have 2 files processed library, file_a.java , file_b.java.

now need access these files within library via reflection, e.g. with:

class.forname("com.test.entities.file_a");  class.forname("com.test.entities.file_b"); 

the problem i'm not able access class files, think because of missing classpath configuration. use task call .jar-file:

task (mytask, type: org.gradle.api.tasks.javaexec) {     classpath(files('libs/myjar.jar'))     main('com.test.testmain') }  prebuild.dependson mytask 

i found ressources on web, don't work.

i tried add following classpath:

sourcesets.main.runtimeclasspath (main unknown) android.sourcesets.main.runtimeclasspath (runtimeclasspath unkown).

so how can access class files in library?

try

task execute(dependson: ['compilereleasejavawithjavac'], type:javaexec) {     main = 'com.geniml.main'     classpath(files('build/intermediates/classes/release',"${android.getsdkdirectory().getabsolutepath() + '/platforms/' + android.compilesdkversion + '/android.jar'}")) } 

android gralde 1.5.

as build dir, can use rootproject.getbuilddir(). build dir convention. static way ok.


Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -