0
votes

I have a project that I built over android-bootstrap. I followed all the steps to add google-play-services_lib to project using android studio. I make and build works great in studio. When I install the app on my phone it dies with this error

08-02 11:49:26.863 22719-22719/com.donnfelker.android.bootstrap E/AndroidRuntime: FATAL EXCEPTION: main java.lang.NoClassDefFoundError: com.google.android.gms.R$styleable at com.google.android.gms.maps.GoogleMapOptions.createFromAttributes(Unknown Source) at com.google.android.gms.maps.SupportMapFragment.onInflate(Unknown Source) at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:269) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:676) at android.view.LayoutInflater.rInflate(LayoutInflater.java:746) at android.view.LayoutInflater.inflate(LayoutInflater.java:489) at android.view.LayoutInflater.inflate(LayoutInflater.java:396) at android.view.LayoutInflater.inflate(LayoutInflater.java:352) at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:256) at android.app.Activity.setContentView(Activity.java:1867) at com.donnfelker.android.bootstrap.ui.FarmActivity.onCreate(FarmActivity.java:19) at android.app.Activity.performCreate(Activity.java:5008) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084) at android.app.ActivityThread.access$600(ActivityThread.java:130) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:137) at android.app.ActivityThread.main(ActivityThread.java:4745) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:511) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553) at dalvik.system.NativeStart.main(Native Method)

The application actually works great until I try to access the Activity that requires the map. I have followed everything as it is in the mapsdemo, I've read almost everything google can provide but with no luck. I am really totally stuck

When I try to run maven clean package i get the error below

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project android-bootstrap: Compilation failure: Compilation failure: [ERROR] /home/kenneth/Documents/android/agric/app/src/main/java/com/donnfelker/android/bootstrap/ui/FarmActivity.java:[7,34] error: package com.google.android.gms.maps does not exist [ERROR] /home/kenneth/Documents/android/agric/app/src/main/java/com/donnfelker/android/bootstrap/ui/FarmActivity.java:[8,34] error: package com.google.android.gms.maps does not exist [ERROR] /home/kenneth/Documents/android/agric/app/src/main/java/com/donnfelker/android/bootstrap/ui/FarmActivity.java:[15,12] error: cannot find symbol [ERROR] class FarmActivity [ERROR] /home/kenneth/Documents/android/agric/app/src/main/java/com/donnfelker/android/bootstrap/ui/FarmActivity.java:[7,34] error: package com.google.android.gms.maps does not exist [ERROR] /home/kenneth/Documents/android/agric/app/src/main/java/com/donnfelker/android/bootstrap/ui/FarmActivity.java:[8,34] error: package com.google.android.gms.maps does not exist [ERROR] /home/kenneth/Documents/android/agric/app/src/main/java/com/donnfelker/android/bootstrap/ui/FarmActivity.java:[15,12] error: cannot find symbol [ERROR] class FarmActivity [ERROR] /home/kenneth/Documents/android/agric/app/src/main/java/com/donnfelker/android/bootstrap/ui/FarmActivity.java:[25,21] error: cannot find symbol [ERROR] -> [Help 1] org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project android-bootstrap: Compilation failure at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:213) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59) at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183) at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161) at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320) at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156) at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537) at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196) at org.apache.maven.cli.MavenCli.main(MavenCli.java:141) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290) at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230) at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409) at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352) Caused by: org.apache.maven.plugin.CompilationFailureException: Compilation failure at org.apache.maven.plugin.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:656) at org.apache.maven.plugin.CompilerMojo.execute(CompilerMojo.java:128) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209) ... 19 more [ERROR] [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException [ERROR] [ERROR] After correcting the problems, you can resume the build with the command [ERROR] mvn -rf :android-bootstrap

Any help is greatly appreciated.

Here is my AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.donnfelker.android.bootstrap"
    android:versionCode="102"
    android:versionName="1.1" >

    <permission
            android:name="com.donnfelker.android.bootstrap.permission.MAPS_RECEIVE"
            android:protectionLevel="signature"/>

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="16" />

    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
    <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.GET_ACCOUNTS" />
    <uses-permission android:name="android.permission.MANAGE_ACCOUNTS" />
    <uses-permission android:name="android.permission.AUTHENTICATE_ACCOUNTS" />
    <uses-permission android:name="android.permission.USE_CREDENTIALS" />
    <uses-permission android:name="android.permission.CAMERA"/>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
    <uses-permission android:name="com.donnfelker.android.bootstrap.permission.MAPS_RECEIVE"/>

    <application
        android:name=".BootstrapApplication"
        android:icon="@drawable/icon"
        android:label="@string/app_name"
        android:theme="@style/Theme.Bootstrap.Dark"
        android:debuggable="true">

        <activity
            android:name=".ui.CarouselActivity"
            android:configChanges="orientation|keyboardHidden|screenSize" android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />

                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>

        <activity android:name=".ui.BootstrapTimerActivity"
                  android:configChanges="orientation|keyboardHidden|screenSize" android:label="@string/app_name"
                  android:launchMode="singleTop"/>

        <service android:name=".core.TimerService" android:enabled="true" android:exported="false" />
        <service android:name=".core.UploadFileService" android:enabled="true" android:exported="false" />

        <service
            android:name=".authenticator.AccountAuthenticatorService"
            android:process=":auth" >
            <intent-filter>
                <action android:name="android.accounts.AccountAuthenticator" />
            </intent-filter>

            <meta-data
                android:name="android.accounts.AccountAuthenticator"
                android:resource="@xml/authenticator" />
        </service>

        <activity
            android:name=".authenticator.BootstrapAuthenticatorActivity"
            android:excludeFromRecents="true" >

            <!--
                No intent-filter here! This activity is only ever launched by
                someone who explicitly knows the class name
            -->
        </activity>

        <activity android:name=".ui.StreamActivity" />
        <activity android:name=".ui.UserActivity" android:label="@string/app_name" />
        <activity
                android:name=".ui.ReportActivity"
                android:label="report_activity"/>
        <activity android:name=".ui.ReportListActivity"/>
        <activity android:name=".ui.FarmActivity"/>

        <meta-data
            android:name="com.google.android.maps.V2.API_KEY"
            android:value="AIzaSyBLiicT8K3wH39vtJ85YwFegEbPU_6zO-U"/>

    </application>

</manifest>

Here is the layout file

    <?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:orientation="vertical"
              android:layout_width="match_parent"
              android:layout_height="match_parent">

    <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content">


        <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textAppearance="?android:attr/textAppearanceLarge"
                android:text="@string/label_farm_stage"
                android:id="@+id/l_farm_stage"/>

        <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textAppearance="?android:attr/textAppearanceLarge"
                android:text="@string/r_farm_stage"
                android:id="@+id/farm_stage"
                android:gravity="right"/>
    </LinearLayout>

    <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content">

        <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textAppearance="?android:attr/textAppearanceLarge"
                android:text="@string/label_farm_type"
                android:id="@+id/l_farm_type"/>

        <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textAppearance="?android:attr/textAppearanceLarge"
                android:text="@string/r_farm_type"
                android:id="@+id/farm_type"/>
    </LinearLayout>

    <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content">

        <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textAppearance="?android:attr/textAppearanceLarge"
                android:text="@string/label_farm_size"
                android:id="@+id/l_farm_size"/>

        <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textAppearance="?android:attr/textAppearanceLarge"
                android:text="@string/r_farm_size"
                android:id="@+id/farm_size"/>
    </LinearLayout>

    <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content">

        <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textAppearance="?android:attr/textAppearanceLarge"
                android:text="@string/label_farm_crops"
                android:id="@+id/l_farm_crops"/>

        <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textAppearance="?android:attr/textAppearanceLarge"
                android:text="@string/r_farm_crops"
                android:id="@+id/farm_crops"/>
    </LinearLayout>

    <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content">

        <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textAppearance="?android:attr/textAppearanceLarge"
                android:text="@string/label_farm_livestock"
                android:id="@+id/l_farm_livestock"/>

        <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textAppearance="?android:attr/textAppearanceLarge"
                android:text="@string/r_farm_livestock"
                android:id="@+id/farm_livestock"/>
    </LinearLayout>

    <fragment
            xmlns:map="http://schemas.android.com/apk/res-auto"
            android:id="@+id/map"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            class="com.google.android.gms.maps.SupportMapFragment"
            map:cameraZoom="10"
            map:cameraTargetLat="-33.87365"
            map:cameraTargetLng="151.20689"
            map:uiZoomControls="false"/>

</LinearLayout>

Here is my Activity file

package com.donnfelker.android.bootstrap.ui;

import android.os.Bundle;
import android.support.v4.app.FragmentActivity;

import com.donnfelker.android.bootstrap.R;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.SupportMapFragment;

/**
 * Agridigital the greatest application in the world
 * Created by kenneth on 7/30/13.
 */
public class FarmActivity extends FragmentActivity {
    private GoogleMap mMap;

    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.farm);
        setUpMapIfNeeded();
    }

    private void setUpMapIfNeeded() {
        if(mMap == null){
            mMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map))
                    .getMap();
        }
    }
}

Any and all help is greatly appreciated.

Thanks in advance

1
So for some reason maven could not compile the google play services correctly. I used this project instead to have google play services installed in maven github.com/JakeWharton/gms-mvn-installAleister

1 Answers

0
votes

It looks like your manifest is missing this line

<uses-feature android:glEsVersion="131072" android:required="true" />