使用Android Studio与ArcGIS Android SDK的开发环境部署和HelloWorld

android studio(以下简称AS)是google推荐的android专用IDE,替代目前主流的eclipse,另外arcgis也把AS作为推荐的android IDE

本文不介绍android SDK的部署和AS的安装

以下网站应该是AS的官方中国官网,有很多AS相关基础教程和AS的下载(不用FQ下载了),强烈推荐

http://www.android-studio.org/

 

本文代码以arcgis android SDK中的arcgis-android-sdk-v10.2.4\samples\Maps\HelloWorld为基础

 

环境:Android SDK API 19,android studio 1.0,arcgis android SDK 10.2.4,小米4+MIUI v6


 

首先new一个project,一直next就行

新建project后,把这里切换到project


 

打开以下文件

 

把代码改为

 1 package jls.as7;
 2 
 3 import android.app.Activity;
 4 import android.os.Bundle;
 5 import android.view.Menu;
 6 import android.view.MenuItem;
 7 
 8 import com.esri.android.map.MapView;
 9 
10 
11 public class MainActivity extends Activity {
12     MapView mMapView;
13 
14     @Override
15     protected void onCreate(Bundle savedInstanceState) {
16         super.onCreate(savedInstanceState);
17         setContentView(R.layout.activity_main);
18 
19         // After the content of this Activity is set, the map can be accessed programmatically from the layout.
20         mMapView = (MapView) findViewById(R.id.map);
21     }
22 
23     @Override
24     protected void onPause() {
25         super.onPause();
26 
27         // Call MapView.pause to suspend map rendering while the activity is paused, which can save battery usage.
28         if (mMapView != null)
29         {
30             mMapView.pause();
31         }
32     }
33 
34     @Override
35     protected void onResume() {
36         super.onResume();
37 
38         // Call MapView.unpause to resume map rendering when the activity returns to the foreground.
39         if (mMapView != null)
40         {
41             mMapView.unpause();
42         }
43     }
44 }

 

打开arcgis android SDK的压缩包,在libs目录下,找到如下几个jar包

复制到代码里如下目录


 

同样是arcgis SDK的libs目录下,把以下几个文件夹

复制到代码的如下目录(jniLibs目录默认不存在,要手动新建)


 

打开AndroidManifest.xml,在manifest节点下,添加如下内容

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

 

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


 

打开moudle的build.gradle,在android节点下添加如下代码

packagingOptions {
exclude 'META-INF/LGPL2.1'
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE'
}


 

到此配置完毕,插上手机,Run运行程序

posted @ 2015-02-26 21:36  cannel  阅读(7136)  评论(0编辑  收藏  举报