App Engine Endpoint Library - NoClassDefFound for my Api and its $ Builder

I am stuck connecting with my api based on App Engine Endpoints framework. After I attach the generated library to my Android client, use it and create an app that always says my Api or Api $ Builder was not found (at runtime). It is highly visible and available during code development or compilation.

I tried two different approaches: - attaching the .jar generated by the maven appengine command: endpoints_get_client_lib - attaching the sources of these classes generated by the same target

Both approaches make the classes visible and usable at runtime there is a NoClassDefFound exception (when I actually call it) and an error the class could not find dalvikvm.

I have a link to the selected library in the Order / Export tab. Although it is in the last position (tried with any other). I also checked Android 5.0 lib as well as Android private libraries (got Android Dependencies and Maven Dependencies unchecked - didn't work with Maven and also checked).

It's worth noting that the moment I created test projects in Eclipse with the GAE plugin (no maven) it worked fine. I can't figure out where the problem is.

I can provide any information you would like to address to resolve this issue. Just ask in the comments, so I am updating the necessary information.

Part of my code in MainActivity of Android app:

protected TestUser callApi() throws IOException
{
    Api.Builder api = new Api.Builder(AndroidHttp.newCompatibleTransport(), new       AndroidJsonFactory(), null);
    return api.build().hello("ANY").execute();
}

      

My API code:

import com.google.api.server.spi.config.Api;
import com.google.api.server.spi.config.ApiMethod;
import com.google.api.server.spi.config.ApiNamespace;
import com.google.api.server.spi.config.Named;
import com.test.user.Contact;
import com.test.user.TestUser;
import com.test.user.status.Status;
import com.test.utils.Utils;

/** An endpoint class we are exposing */
@Api(
    name = "api", 
    version = "v1", 
    description = "My Own Api",
    namespace = @ApiNamespace(
            ownerDomain = "com.test.server", 
            ownerName = "com.test.server", 
            packagePath = ""),
    scopes = { Utils.EMAIL_SCOPE }
)
public class ApiService
{
    /**
     * Api Method for Testing purposes.
     * 
     * @param name
     * @return
     */
    @ApiMethod(name = "hello")
    public TestUser hello(@Named("name") String name)
    {
        TestUser response = new TestUser();
        response.setId(123);
        response.setName(name);

        return response;
    }
}

      

POM of my android project:

<properties>
    <!-- use UTF-8 for everything -->
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <appengine.app.version>2</appengine.app.version>
    <appengine.target.version>1.9.14</appengine.target.version>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>
    <dependency>
        <groupId>com.google.android</groupId>
        <artifactId>android</artifactId>
        <version>4.1.1.4</version>
        <scope>provided</scope>
    </dependency>
    <!-- Compile/runtime dependencies -->
    <dependency>
        <groupId>com.google.appengine</groupId>
        <artifactId>appengine-api-1.0-sdk</artifactId>
        <version>${appengine.target.version}</version>
    </dependency>
    <dependency>
        <groupId>com.google.appengine</groupId>
        <artifactId>appengine-endpoints</artifactId>
        <version>${appengine.target.version}</version>
    </dependency>
    <dependency>
        <groupId>com.google.api-client</groupId>
        <artifactId>google-api-client</artifactId>
        <version>1.19.0</version>
    </dependency>
    <dependency>
        <groupId>com.google.http-client</groupId>
        <artifactId>google-http-client</artifactId>
        <version>1.19.0</version>
    </dependency>
    <dependency>
        <groupId>com.google.http-client</groupId>
        <artifactId>google-http-client-android</artifactId>
        <version>1.19.0</version>
    </dependency>
</dependencies>
<build>
    <pluginManagement>
        <plugins>
            <plugin>
                <groupId>com.jayway.maven.plugins.android.generation2</groupId>
                <artifactId>android-maven-plugin</artifactId>
                <version>3.9.0-rc.1</version>
                <configuration>
                    <sdk>
                        <platform>21</platform>
                    </sdk>
                    <deleteConflictingFiles>true</deleteConflictingFiles>
                    <undeployBeforeDeploy>true</undeployBeforeDeploy>
                </configuration>
                <extensions>true</extensions>
            </plugin>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                </configuration>
            </plugin>
        </plugins>
    </pluginManagement>
</build>

      

POM of my API app:

<pluginRepositories>
    <pluginRepository>
        <id>google-staging</id>
        <name>Google Staging</name>
        <url>https://oss.sonatype.org/content/repositories/comgoogleappengine-1004/</url>
    </pluginRepository>
</pluginRepositories>

<properties>
    <appengine.app.version>1</appengine.app.version>
    <appengine.target.version>1.9.14</appengine.target.version>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>
    <!-- Compile/runtime dependencies -->
    <dependency>
        <groupId>com.google.appengine</groupId>
        <artifactId>appengine-api-1.0-sdk</artifactId>
        <version>${appengine.target.version}</version>
    </dependency>
    <dependency>
        <groupId>com.google.appengine</groupId>
        <artifactId>appengine-endpoints</artifactId>
        <version>1.9.14</version>
    </dependency>
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>servlet-api</artifactId>
        <version>2.5</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>javax.jdo</groupId>
        <artifactId>jdo-api</artifactId>
        <version>3.1-rc1</version>
    </dependency>
    <dependency>
        <groupId>javax.persistence</groupId>
        <artifactId>persistence-api</artifactId>
        <version>1.0.2</version>
    </dependency>

    <dependency>
        <groupId>com.googlecode.objectify</groupId>
        <artifactId>objectify</artifactId>
        <version>5.1</version>
    </dependency>
    <dependency>
        <groupId>jstl</groupId>
        <artifactId>jstl</artifactId>
        <version>1.2</version>
    </dependency>

    <!-- Test Dependencies -->
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.10</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.mockito</groupId>
        <artifactId>mockito-all</artifactId>
        <version>1.9.0</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>com.google.appengine</groupId>
        <artifactId>appengine-testing</artifactId>
        <version>${appengine.target.version}</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>com.google.appengine</groupId>
        <artifactId>appengine-api-stubs</artifactId>
        <version>${appengine.target.version}</version>
        <scope>test</scope>
    </dependency>
</dependencies>

<build>
    <outputDirectory>target/${project.artifactId}/WEB-INF/classes</outputDirectory>

    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <version>2.3</version>
            <configuration>
                <archiveClasses>true</archiveClasses>
                <webResources>
                    <!-- in order to interpolate version from pom into appengine-web.xml -->
                    <resource>
                        <directory>${basedir}/src/main/webapp/WEB-INF</directory>
                        <filtering>true</filtering>
                        <targetPath>WEB-INF</targetPath>
                    </resource>
                </webResources>
            </configuration>
        </plugin>

        <plugin>
            <groupId>com.google.appengine</groupId>
            <artifactId>appengine-maven-plugin</artifactId>
            <version>1.9.14</version>
            <configuration>
                <enableJarClasses>false</enableJarClasses>
                <port>8888</port>
                <address>0.0.0.0</address>
            </configuration>
        </plugin>
    </plugins>
</build>

      

EDIT 14:43 11.1.2014:

Android Manifest:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.test.client"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="10"
        android:targetSdkVersion="21" />

    <uses-permission android:name="android.permission.INTERNET" />
    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <meta-data android:name="com.google.android.gms.version"
                   android:value="@integer/abc_max_action_buttons" />
        <activity
            android:name="MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

      

+3


source to share


1 answer


This error usually means that the required ATM was not found on the server. You are not seeing the error in Eclipse because you have added all the required jars to your classpath.

In Eclipse select your project and go to the Problems tab. See if there are warnings that "... will not be available on the server ...". Right click on this alert and select the "Copy" option.



Note that another possibility is that there is more than one copy of the required jar in this folder, in which case you must delete all copies, add the correct jar, and clear the project.

0


source







All Articles