Using cling with Android Project

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Using cling with Android Project

xlehoc01
Dear Cling Developers.

For a long time now, I'm trying to make an Android application using Cling 2.0 alpha2.

The thing is i could not figure out to include this lib to an Android projects in ADT.

I tried two thing how to use this lib, but none of them works:
1: Creating new project for Cling, added the core src and to it. Also added to build path libs source codes includes needed
2: Adding cling jar to projects build path with seamless-http, seamless-util and seamless-xml jar files

For both methods, when I'm running the code made by the manual http://4thline.org/projects/cling/core/manual/cling-core-manual.html#chapter.Android I get an error:
"Could not find method org.seamless.util.Exceptions.unwrap, referenced from method org.fourthline.cling.UpnpServiceImpl.shutdownRouter"
and therefor the app gets a FATAL EXCEPTION

What is the correct way to use this library? Please, can I get a little manual what shoulod i do to make it work?

Thanks fore every bit of help. I'm writing my bachelors thesis related with UPnP streaming from android and I'm really frustrated that I can't make this lib work.
Reply | Threaded
Open this post in threaded view
|

Re: Using cling with Android Project

Christian Bauer
Administrator
Use Maven.

Reply | Threaded
Open this post in threaded view
|

Re: Using cling with Android Project

xlehoc01
You mean the Apache Maven? What it does?
Sorry, I don't get it.
Ole
Reply | Threaded
Open this post in threaded view
|

Re: Using cling with Android Project

Ole
First, read the manual: .../cling/core/src/manual/android/

Cling uses Maven for building the jar-files. Use your package installer to install Maven. Then execute the command "mvn clean install" in the source base folder (where the base pom.xml is located). Maven places the jars in "~/.m2/repository/org/fourthline/cling".

Good luck.

/Ole
Reply | Threaded
Open this post in threaded view
|

Re: Using cling with Android Project

xlehoc01
So, I think i managed to add Maven to my project and made a pom.xml

<project 
    xmlns="http://maven.apache.org/POM/4.0.0" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>com.xlehoc01.abc</groupId>
  <artifactId>abc</artifactId>
  <version>2.0-alpha2</version>
  <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>com.jayway.maven.plugins.android.generation2</groupId>
                    <artifactId>android-maven-plugin</artifactId>
                    <version>${android.maven.plugin.version}</version>
                    <extensions>true</extensions>
                    <configuration>
                        <sdk>
                            <!-- Don't forget to set your ANDROID_HOME environment variable to your SDK directory! -->
                            <path>${env.ANDROID_HOME}</path>
                            <platform>15</platform>
                        </sdk>
                        <androidManifestFile>${project.basedir}/src/android/AndroidManifest.xml</androidManifestFile>
                        <resourceDirectory>${project.basedir}/src/android/res</resourceDirectory>
                        <assetsDirectory>${project.basedir}/src/android/assets</assetsDirectory>
                        <nativeLibrariesDirectory>${project.basedir}/src/android/native</nativeLibrariesDirectory>
                        <resourceOverlayDirectory>${project.basedir}/src/android/overlay</resourceOverlayDirectory>
                        <extractDuplicates>true</extractDuplicates>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>
  </build>
  
  <repositories>
    <repository>
        <id>teleal-repo</id>
        <url>http://teleal.org/m2</url>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
    </repository>
  </repositories>
  
  
  <dependencies>

        <dependency>
            <groupId>org.fourthline.cling</groupId>
            <artifactId>cling-core</artifactId>
            <version>${project.version}</version>
        </dependency>

        <dependency>
            <groupId>com.google.android</groupId>
            <artifactId>android</artifactId>
            <version>4.1.1.4</version>
        </dependency>
        

        <!-- For Android we use the Jetty transport in Cling -->
        <dependency>
            <groupId>org.eclipse.jetty</groupId>
            <artifactId>jetty-server</artifactId>
            <version>8.1.8.v20121106</version>
        </dependency>
        <dependency>
            <groupId>org.eclipse.jetty</groupId>
            <artifactId>jetty-servlet</artifactId>
            <version>8.1.8.v20121106</version>
        </dependency>
        <dependency>
            <groupId>org.eclipse.jetty</groupId>
            <artifactId>jetty-client</artifactId>
            <version>8.1.8.v20121106</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-jdk14</artifactId>
            <version>1.6.1</version>
        </dependency>

    </dependencies>
</project>

In ADT in Package explorer in the project folder I can see 'Maven Dependencies' and 'cling-core-2.0-alpha2.jar' is there too with many others.

But when I make my project run it says that
VFY: unable to find class referenced in signature (Lorg/fourthline/cling/android/AndroidUpnpService;)
and therefore the error appears that "private class BrowseRegistryListener extends DefaultRegistryListener" could not be found.
 
How could I solve this problem?
Ole
Reply | Threaded
Open this post in threaded view
|

Re: Using cling with Android Project

Ole
When Christian said "Use Maven", I suppose he meant "Use maven from Command Line". I started myself trying to integrate Maven in Eclipse, but eventually gave up. Thus, I'll recommend the same: "Use Maven from Command Line".

/Ole
Reply | Threaded
Open this post in threaded view
|

Re: Using cling with Android Project

bergstr
In reply to this post by xlehoc01
It seems to me your IDE setup is correct. You should be able to export the app from within the IDE, command line is not required. Are you obfuscating your code? There are comments regarding obfuscation somewhere in the docs