进出口工作简单的地图应用程序,我加了谷歌播放的,services.jar及其参考摇篮
Im working on simple map app, I added google-play-services.jar and its reference to gradle
dependencies {
compile files('libs/android-support-v4.jar', 'libs/google-play-services.jar')
}
主要活动:
setContentView(R.layout.activity_mapui);
GoogleMap map = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();
布局文件
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:name="com.google.android.gms.maps.MapFragment"/>
但在设备上的应用程序崩溃
But the app crashes on the device
E / AndroidRuntime:致命异常:主要 java.lang.NoClassDefFoundError的:com.google.android.gms.R $设置样式为 com.google.android.gms.maps.GoogleMapOptions.createFromAttributes(未知 源)以com.google.android.gms.maps.MapFragment.onInflate(未知 来源)
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.MapFragment.onInflate(Unknown Source)
我试了几种方法,同样的问题,我只是想谷歌的服务添加到Android 0.3工作室与摇篮0.6 +
I tried several ways, same issue, I just want to add google services to Android Studio 0.3 with Gradle 0.6+
正如@马特说,这是正确的,我在这里也包括我没有找到答案。
As @Matt said, it is correct, I am here covered also which I did not find in the answer.
要加入谷歌Play业务库的应用程序项目,请按照下列步骤操作: -
To add the Google Play Service library in your application project, follow below steps :-
1)打开应用程序的模块目录的 build.gradle
文件。见截图
1) Open the build.gradle
file of your application module directory. See screenshot
2)新增在你的依赖条件,在这里您更新无论您何时更新谷歌播放服务的版本号。
2) Add new in your dependecies, here you to update the version number whenever you update the Google Play Service.
dependencies {
...
compile 'com.google.android.gms:play-services:4.2.42'
compile files('src/main/libs/gson-2.2.4.jar')
}
3)现在,最后重要的保存文件,然后点击同步与摇篮
文件在工具栏中。
3) Now Lastly important save your file and click on Sync with Gradle
Files in the toolbar.