Skip to content

Snapshots with ABI splits do not work since Android Runtime 4.1.0 #1234

@darind

Description

@darind

Environment

Provide version numbers for the following components (information can be retrieved by running tns info in your project folder or by inspecting the package.json of the project):

  • CLI: 5.1.0
  • Cross-platform modules: 5.1.0
  • Android Runtime: 5.1.0

Describe the bug

ABI splits with snapshot do not work since android runtime 4.1.0.

To Reproduce

Enable ABI splits with snapshot as described in the documentation:

  1. Create an angular app: tns create test --ng
  2. Set useLibs and androidNdkPath in webpack.config.js:
if (snapshot) {
    config.plugins.push(new nsWebpack.NativeScriptSnapshotPlugin({
        .............
        targetArchs: [ "arm", "arm64", "ia32" ],
        useLibs: true,
        androidNdkPath: "/home/ubuntu/ndkr18b/android-ndk-r18b"
    }));
}
  1. Enable ABI splits in App_Resources/Android/app.gradle:
android {
  defaultConfig {
    generatedDensities = []
    ndk {
      abiFilters.clear()
    }
  }
  aaptOptions {
    additionalParameters "--no-version-vectors"
  }
  splits {
    abi {
        enable true
        reset()
        include 'arm64-v8a', 'armeabi-v7a', 'x86'
        universalApk true
    }
  }
  sourceSets {
    main {
        jniLibs.srcDirs = ["$projectDir/libs/jni", "$projectDir/snapshot-build/build/ndk-build/libs"]
    }
  }
}
  1. Run the application in release mode with snapshot enabled:
tns run android --env.snapshot --bundle --release --key-store-path ~/some_key.jks --key-store-password some_secret --key-store-alias some_alias --key-store-alias-password some_secret

Expected behavior

The application starts correctly

Actual Behavior

The application crashes with the following exception:

12-17 17:43:14.340  5764  5764 W System.err: java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{org.nativescript.snap2/com.tns.NativeScriptActivity}: com.tns.NativeScriptException: Failed to create JavaScript extend wrapper for class 'com/tns/NativeScriptActivity'
12-17 17:43:14.340  5764  5764 W System.err:    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2391)
12-17 17:43:14.340  5764  5764 W System.err:    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2540)
12-17 17:43:14.340  5764  5764 W System.err:    at android.app.ActivityThread.access$900(ActivityThread.java:150)
12-17 17:43:14.340  5764  5764 W System.err:    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1390)
12-17 17:43:14.340  5764  5764 W System.err:    at android.os.Handler.dispatchMessage(Handler.java:102)
12-17 17:43:14.340  5764  5764 W System.err:    at android.os.Looper.loop(Looper.java:168)
12-17 17:43:14.340  5764  5764 W System.err:    at android.app.ActivityThread.main(ActivityThread.java:5781)
12-17 17:43:14.340  5764  5764 W System.err:    at java.lang.reflect.Method.invoke(Native Method)
12-17 17:43:14.340  5764  5764 W System.err:    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:797)
12-17 17:43:14.340  5764  5764 W System.err:    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:687)
12-17 17:43:14.340  5764  5764 W System.err: Caused by: com.tns.NativeScriptException: Failed to create JavaScript extend wrapper for class 'com/tns/NativeScriptActivity'
12-17 17:43:14.340  5764  5764 W System.err:    at com.tns.Runtime.createJSInstanceNative(Native Method)
12-17 17:43:14.340  5764  5764 W System.err:    at com.tns.Runtime.createJSInstance(Runtime.java:656)
12-17 17:43:14.340  5764  5764 W System.err:    at com.tns.Runtime.initInstance(Runtime.java:629)
12-17 17:43:14.340  5764  5764 W System.err:    at com.tns.NativeScriptActivity.<init>(NativeScriptActivity.java:12)
12-17 17:43:14.340  5764  5764 W System.err:    at java.lang.Class.newInstance(Native Method)
12-17 17:43:14.340  5764  5764 W System.err:    at android.app.Instrumentation.newActivity(Instrumentation.java:1085)
12-17 17:43:14.340  5764  5764 W System.err:    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2381)
12-17 17:43:14.340  5764  5764 W System.err:    ... 9 more

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions