Skip to content

Commit 5f64507

Browse files
authored
Merge pull request #1000 from NativeScript/trifonov/multidex-fix
fix: Enable multidex support for versions older than API 21
2 parents 2756545 + 9143206 commit 5f64507

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

build-artifacts/project-template-gradle/app/src/main/java/com/tns/NativeScriptApplication.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package com.tns;
22

33
import android.app.Application;
4+
import android.os.Build;
5+
import android.support.multidex.MultiDex;
46

57
public class NativeScriptApplication extends Application {
68

@@ -23,6 +25,14 @@ public void onCreate() {
2325
}
2426
}
2527

28+
public void attachBaseContext(android.content.Context base) {
29+
super.attachBaseContext(base);
30+
if (Build.VERSION.SDK_INT < 21) {
31+
// As the new gradle plugin automatically uses multidex if necessary we need to call this for older android API versions
32+
MultiDex.install(this);
33+
}
34+
}
35+
2636
public static Application getInstance() {
2737
return thiz;
2838
}

test-app/app/build.gradle

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,8 @@ dependencies {
198198
if (project.hasProperty("supportVersion")) {
199199
supportVer = supportVersion
200200
}
201+
202+
compile "com.android.support:multidex:1.0.2"
201203
compile "com.android.support:support-v4:$supportVer"
202204
compile "com.android.support:appcompat-v7:$supportVer"
203205
debugCompile "com.android.support:design:$supportVer"
@@ -272,7 +274,7 @@ task addDependenciesFromAppResourcesLibraries {
272274
println "\t + adding jar plugin dependency: $jarFileAbsolutePath"
273275
pluginsJarLibraries.add(jarFile.getAbsolutePath())
274276
}
275-
277+
276278
project.dependencies.add("compile", jarFiles)
277279
}
278280
}

0 commit comments

Comments
 (0)