Error when running self-contained sample AGA app

Added by Apostolos Apostolidis over 3 years ago

Hi, 

I m trying to run a sample app on my android device and I get this error:
     Caused by: java.lang.ClassNotFoundException: Didn't find class "android.swedspot.automotive.AutomotiveManager" on path: DexPathList[[zip file "/data/app/com.example.apostolis.myapplication-2/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
            at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
            at com.example.apostolis.myapplication.MainActivity.onCreate(MainActivity.java:18)
            at android.app.Activity.performCreate(Activity.java:5933)
            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2298)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2407)
            at android.app.ActivityThread.access$800(ActivityThread.java:149)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1324)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:211)
            at android.app.ActivityThread.main(ActivityThread.java:5321)
            at java.lang.reflect.Method.invoke(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:372)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1016)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:811)
    Suppressed: java.lang.ClassNotFoundException: android.swedspot.automotive.AutomotiveManager
            at java.lang.Class.classForName(Native Method)
            at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
            at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
            ... 15 more
     Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available
Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available
 
I m trying to run it in the self-contained mode where no ROM is needed. It seems that for some reason the libraries I included are not read?
 

Replies (3)

RE: Error when running self-contained sample AGA app - Added by Apostolos Apostolidis over 3 years ago

Solved it.
One has to import classes from the jars when running the self-contained version 

RE: Error when running self-contained sample AGA app - Added by Christopher Pavlic over 3 years ago

As you said when using the self-contained version (we call it JAR version). You should only import the artifacts for Automotive-API, SDP and VIL projects from this page http://developer.lindholmen.se/repo/artifacts and add them into your libs folder in the Android project (make sure that the IDE registers that you added them).

You also do not need the AGA SDK when developing for the JAR version. The problem with the JAR version is that you will be handicaped by the fact that there is no AGA proxy taking care of connections for you. Instead you will have to make sure that the connection is upheld correctly on your own.

Best Regards
Christopher Pavlic of the AGA team

 

RE: Error when running self-contained sample AGA app - Added by Christopher Pavlic over 3 years ago

I missed some vital information when switching from ROM to JAR version.
Since you no longer have the AGA SDK when developing with JARs you run into the problem that the automotive service is no longer inside the context (since that is added when building AGA)
 
Instead you need to use the AutomotiveFactory to create an AutomotiveManager instance from the Automotive-API project. And that will look a little something like this:
AutomotiveManager manager = AutomotiveFactory.createAutomotiveManagerInstance(
new AutomotiveCertificate(new byte[0]), new AutomotiveListener() {
    @Override public void receive(AutomotiveSignal signal) {

    }

    @Override public void timeout(int signalId) {

    }

    @Override public void notAllowed(int signalId) {

    }
}, new DriverDistractionListener() {
    @Override public void levelChanged(DriverDistractionLevel newLevel) {

    }

    @Override public void lightModeChanged(LightMode lightMode) {

    }

    @Override public void stealthModeChanged(StealthMode stealthMode) {

    }
});
Do not worry about the AutomotiveCertificate as we are currently running an "everything is permitted" policy. You need to do your signal handling inside the AutomotiveListener's receive method. You can if you so desire leave the DriverDistractionListener empty, but not null.

Best Regards
Christopher Pavlic of the AGA team

 

(1-3/3)