使用Android Studio與ArcGIS Android SDK的開發環境部署和HelloWorld


android studio(以下簡稱AS)是google推薦的android專用IDE,替代目前主流的eclipse,另外arcgis也把AS作為推薦的android IDE

本文不介紹android SDK的部署和AS的安裝

以下網站應該是AS的官方中國官網,有很多AS相關基礎教程和AS的下載(不用翻牆下載了),強烈推薦

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運行程序


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM