-6

I have some directories I need to be included in the root of the apk (no I cannot put them in the assets or res/raw folders). How can I include them in the apk build?

My build.gradle:

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.1.0'
    }
}
apply plugin: 'android'

android {
    compileSdkVersion 'android-23'
    buildToolsVersion '24'

    compileOptions {
      sourceCompatibility JavaVersion.VERSION_1_7
      targetCompatibility JavaVersion.VERSION_1_7
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFile getDefaultProguardFile('proguard-android.txt')
        }
    }

    dependencies {
        compile fileTree(include: ['*.jar'], dir: 'libs')
    }
}
Ava
  • 2,038
  • 3
  • 23
  • 45
  • "no I cannot put them in the assets or res/raw folders". But then you also not gonna have access to them during runtime. – Budius Jul 22 '16 at 09:41

2 Answers2

0

you can add your directories like

include ':directory1'
project(':directory').projectDir = new File(settingsDir, '../Project B/Directory 1')

Refer this for more information

Community
  • 1
  • 1
Vamsi Abbineni
  • 479
  • 3
  • 7
  • 23
0

Here's another way to accomplish this:

Inside your "app/src/main" directory create a "resources" directory. Then inside the resources directory add the directory structure you want created. There's one trick you need to know, you must add one dummy file and each ending directory. It can be a 0 length file. If you don't add that dummy file, then the extraneous directories won't be created. The directory structure that you specified will be built at the root of the apk. (i.e. the "resources" directory will not be part of the path name)

Comment: Note the apk is installed in a directory that only has read access. You will not be able to add any content to the directory structure you created. Generally the technique I described is used to store data that won't change such as a "default.properties" file. The content is accessed using the getResource method of it classloader.

Tom Rutchik
  • 1,183
  • 1
  • 12
  • 15