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

來源:互聯網
上載者:User

標籤:

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

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.