我有一個項目,我建立了android-bootstrap。我遵循所有步驟將google-play-services_lib添加到使用android studio的項目中。我在工作室製作和製作很棒的作品。當我在我的手機上安裝應用程序也與此錯誤無法讓谷歌地圖V2與工作室和maven一起工作
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)
,直到我試圖訪問需要的地圖活動的應用程序實際工作極大死亡。我已經遵循了mapsdemo中的所有內容,我幾乎讀過谷歌可以提供的所有內容,但沒有運氣。我真的完全卡住
當我嘗試運行maven clean package
我得到以下
[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
錯誤任何幫助是極大的讚賞。
這裏是我的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>
這裏是佈局文件
<?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>
這裏是我的活動文件
包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();
}
}
}
任何和所有的幫助,非常感謝。
在此先感謝
哪裏是你的勁歌? –
因此,出於某種原因,maven無法正確編譯google play服務。我使用這個項目,而不是谷歌播放服務安裝在maven https://github.com/JakeWharton/gms-mvn-install – Aleister