Kudan AR Simple Sample Android does not work

1.1k views Asked by At

I use Kudan SDK v.1.4 on Android Studio with package: eu.kudan.ar

The project builds with no errors , but when i run the app, I have this error:

12-29 16:17:33.669 22875-22875/? I/art: Late-enabling -Xcheck:jni 12-29 16:17:33.689 22875-22889/? E/art: Failed writing handshake bytes (-1 of 14): Broken pipe 12-29 16:17:33.689 22875-22889/? I/art: Debugger is no longer active 12-29 16:17:33.709 22875-22875/? W/ResourcesManager: before getResources()--------------config= {1.0 ?mcc?mnc it_IT ldltr sw800dp w1280dp h726dp 240dpi xlrg land finger -keyb/v/h -nav/h suim:1 s.6} 12-29 16:17:33.719 22875-22875/? I/InstantRun: Instant Run Runtime started. Android package is eu.kudan.ar, real application class is null. 12-29 16:17:33.729 22875-22875/? W/art: Failed to find OatDexFile for DexFile /data/data/eu.kudan.ar/files/instant-run/dex/slice-slice_9-classes.dex ( canonical path /data/data/eu.kudan.ar/files/instant-run/dex/slice-slice_9-classes.dex) with checksum 0x47fac275 in OatFile /data/data/eu.kudan.ar/cache/slice-slice_9-classes.dex 12-29 16:17:33.909 22875-22875/? I/CachedDir: file changed, refill cache - 1357 12-29 16:17:33.919 22875-22875/? W/linker: libKudan.so: unused DT entry: type 0x6ffffffe arg 0x66c50 12-29 16:17:33.919 22875-22875/? W/linker: libKudan.so: unused DT entry: type 0x6fffffff arg 0x3 12-29 16:17:33.949 22875-22875/? I/kudan-ndk: Your API key is valid. 12-29 16:17:34.099 22875-22875/? I/ARFragment: onResume 12-29 16:17:34.159 22875-22875/? I/View: ssignParent(ViewParent parent) parent is: android.view.ViewRootImpl@2d5754ef 12-29 16:17:34.179 22875-22925/? I/OpenGLRenderer: Initialized EGL, version 1.4 12-29 16:17:34.189 22875-22875/? I/KudanAR: screen: 1920x1128 12-29 16:17:34.499 22875-22875/? I/HwCust: Constructor found for class android.media.HwCustMediaPlayerImpl 12-29 16:17:34.509 22875-22875/? E/MediaPlayer: Should have subtitle controller already set 12-29 16:17:34.519 22875-22875/? W/System.err: java.io.FileNotFoundException: This file can not be opened as a file descriptor; it is probably compressed 12-29 16:17:34.519 22875-22875/? W/System.err: at android.content.res.AssetManager.openAssetFd(Native Method) ... java.lang.reflect.Method.invoke(Method.java:372) 12-29 16:17:34.519 22875-22875/? W/System.err: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:964) 12-29 16:17:34.519 22875-22875/? W/System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:759) 12-29 16:17:34.529 22875-22875/? E/AndroidRuntime: FATAL EXCEPTION: main Process: eu.kudan.ar, PID: 22875 java.lang.NullPointerException: Attempt to invoke virtual method 'eu.kudan.kudan.ARWorld eu.kudan.kudan.ARImageTrackable.getWorld()' on a null object reference at eu.kudan.ar.MainActivity.setup(MainActivity.java:56) at eu.kudan.kudan.ARView.setup(ARView.java:104) at eu.kudan.kudan.ARView.onSizeChanged(ARView.java:306) at android.view.View.sizeChange(View.java:15848) at android.view.View.setFrame(View.java:15813) at android.view.SurfaceView.setFrame(SurfaceView.java:316) at android.view.View.layout(View.java:15729) at ....

The assets are imported well. The problem is :

trackableSet.loadFromAsset("demo.KARMarker");

This my Activity:

public class MainActivity  extends ARActivity implements ARImageTrackableListener {

public void onCreate(Bundle savedInstanceState) {
    // set api key for this package name.
    ARAPIKey key = ARAPIKey.getInstance();
    key.setAPIKey("lwoY4cyKEI+suoK+VyK2RtCjSMnzQRcsJmgAP8Uwt5MIJvxKCrE8rwLTCRxKQeuMMG9yG61W5J/53GpU0FdrDSNI6DDYoMWTQYcjvZ9kRWL2qW8782mk8Wem6T8orsVN977Ft+6biQIoTLWE4ZKJgd0BKjqwwkX17RYgjp1NCTTFnxhYzzmbA16ocun1Ks88bLjN2ONVlOwTrPBET+cFFTieoAx1HlPhT0G32k5qCDDhb/OkVYWHPtBxLfHW1HmRJLpC1Q7GIKVgHH+WAekrMDm6Sf7r+CrVxKsmTPmONojOvWo59y1EqwYOjntUOVtnptHpMNlM9MSC9gA9hl7A90lXRhVqoxGVJDPrNjFOYzCVhzECKZ7WupYjBvfHLq7LRSiT1dXVqMCU496QlF2pXlmVaICOMV0MtfkEQqstQBXvkFEAJVVbLr8eUQZZbXAYw5Rd3syT2zPYNIDpxJn2+vyIXFHR2AD1B7cUZxuYOJfbUSODUdkhUWB/MpFtYG8o677/ReB+vDmngFlvz16hR0gOdauHzX0nhl8l0N3MjhjKF4dxqIrqmc0W2g2fSDHga7frddX2JRgOgJEsmJYldNe7FXMjUNsUdCuMEEf9YVwpDoyqQYZzNNseZOBtIPS+1eHhtlmTg7egvIIU9XQPrz7b/zxEVuw7ObTv8PmmxyI=");
    super.onCreate(savedInstanceState);
}

public void setup() {
    // create a trackable from a bundled image.
    ARImageTrackable wavesTrackable = new ARImageTrackable("waves");
    wavesTrackable.loadFromAsset("waves.png");

    // create video texture.
    ARVideoTexture videoTexture = new ARVideoTexture();
    videoTexture.loadFromAsset("waves.mp4");
    ARVideoNode videoNode = new ARVideoNode(videoTexture);

    // add video to the waves trackable.
    wavesTrackable.getWorld().addChild(videoNode);

    // load a set of trackables from a bundled file.
    ARTrackableSet trackableSet = new ARTrackableSet();
    trackableSet.loadFromAsset("demo.KARMarker");

    ARImageTracker tracker = ARImageTracker.getInstance();

    // add our trackables to the tracker.
    tracker.addTrackableSet(trackableSet);
    tracker.addTrackable(wavesTrackable);

    // create an image node.
    ARImageTrackable legoTrackable = tracker.findTrackable("lego");
    ARImageNode imageNode = new ARImageNode("BatmanLegoMovie.png");

    // make it smaller.
    imageNode.scaleBy(0.5f, 0.5f, 0.5f);

    // add it to the lego trackable.
    legoTrackable.getWorld().addChild(imageNode);
}

@Override
public void didDetect(ARImageTrackable trackable) {
    Log.i("KudanSamples", "detected " + trackable.getName());
}


@Override
public void didTrack(ARImageTrackable trackable) {
    Log.i("KudanSamples", "tracked");
}

@Override
public void didLose(ARImageTrackable trackable) {
    Log.i("KudanSamples", "lost " + trackable.getName());
}
}

Solved

I moved the assets in /sdcard/marker/asset/ and instead of

trackableSet.loadFromAsset("demo.KARMarker");

I used method:

trackableSet.loadFromPath("sdcard/marker/demo.KARMarker");

Also license to use:

sVmoznmKZ+4nFEHD6HoslwpC26PNuBZGHrikUwyon2BKSvza1yu2CqbSrae+pHPr1NHjhsf5pHQOZn8IEqXlqXFodGsrOJhxJANbMOdvnRLUi9/QWGqyRL9FViDmyohw6e5R7U4Ex8H7d7spLLvhfp5HFv56DgLr8c8sC2ipDtv9g1IjOTaY7UGxata3eulG2A/UkIdRv2NcotZXqan01xQUWFAislEwlGguParEYiwu11T4mqtU3dQBbfxpvxbczjdYz493YG3rAO2RHgT+5M5TJShJsz2irkNo71JD2Fzqf4AR2b4+7t1c55zKjegXzGS6Xa/rpNn9yiXUn7rUYIHNvN3cEQa9HsZiVxAV4vJgxFS+T/AxfWqKrEg1uj6xF5MsodZ2EkZ8mqliYIsxZqnFz+Re2HeWG8wvrEob0ZwRIO0TxppAemZc3HChTAPLcNt5gzeBk0oRP4wnrFAFFBDi8XjDocwTSVw++hWZb1qNHzt6bKLsMDRT057UVuuZB6M8f7EOQD79Oah0Vrx/3DUK6e9BEV8oGFNHtk1wyYEkg0i6RLhVSokGx//Qj36A4gCz3h1OjtfB0OuukbNq7xI1L/FcNQLmGYNGZwszARjGr9ESw1gVAkbQMxaV27uo/KoIq4+nR7RL8iT7t7NAaXCFIi24RR+7WGjTvKqWYjA=

1

There are 1 answers

0
Nishant Thapliyal On

First of all, the name of the folder should be assets and not asset.

  • Next, keep your assets folder inside app directory (in parallel to res folder).

  • Now try to run your application and make sure that all the files are available inside that assets folder.

Still getting that error?

By this time it should be working well but you can make the following changes to make sure that the app is working and not getting any runtime error.

Replace this

ARImageNode imageNode = new ARImageNode("BatmanLegoMovie.png");

with

ARImageNode imageNode = new ARImageNode();
imageNode.initWithPath("file:///android_asset/BatmanLegoMovie.png");

And finally, try to track the image first. You are trying to track image, video, etc all together. Don't know if that's right or not but just to make sure that at least one thing is working properly.