標籤:
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 @Override15 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 @Override24 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 @Override35 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運行程式
使用Android Studio與ArcGIS Android SDK的開發環境部署和HelloWorld