注意:华为手机需要添加如下配置(build.gradle(Module.app)),否则闪退因为华为不兼容arcgis,主要原因是so文件不兼容,对so文件有兴趣可以看看这篇文章
https://www.jianshu.com/p/cb05698a1968
在线配置:
-
android {
-
compileSdkVersion 29
-
buildToolsVersion "29.0.3"
-
defaultConfig {
-
applicationId "com.chy.esrimap"
-
minSdkVersion 19
-
targetSdkVersion 29
-
versionCode 1
-
versionName "1.0"
-
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
-
ndk{abiFilters"armeabi","armeabi-v7a"}
-
}
*建议使用Gradle进行安装配置(在线配置)*
1.在Project的build.gradle文件中进行以下配置:
-
allprojects {
-
repositories {
-
google()
-
jcenter()
-
// Add the following ArcGIS repository
-
maven {
-
url 'https://esri.bintray.com/arcgis'
-
}
-
}
-
}
2.在module的build.gradle中添加依赖:
-
// Add ArcGIS Runtime SDK for Android dependency
-
implementation 'com.esri.arcgisruntime:arcgis-android:100.3.0'
3.
AndroidManifest.xml文件:
-
<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"/>
离线配置:
1.下载ArcGIS Runtime SDK for Android, 前往https://developers.arcgis.com/downloads/apis-and-sdks?product=android下载(需要先注册,登录后才能下载)
2.配置本地环境
解压资源包后观察文件目录,我们需要的资源文件在libs文件夹下
进入libs目录,文件与文件夹分为三类,aar文件夹,系统依赖包文件夹和jar包。这里不是每个文件和文件夹都用得到,只需要aar文件夹下的文件和gson-2.8.5.jar文件。
aar文件夹下的文件都要加入到项目中,aar文件相当于另一个完整的android项目,作为依赖包的形式可引入到其他项目中,作用于jar包类似,但在jar包的基础上还包含了项目的其他必要文件,比如各种资源文件(drawable和layout等)。
在build.gradle(Module:app)文件中配置
-
apply plugin: 'com.android.application'
-
android {
-
compileSdkVersion 29
-
buildToolsVersion "29.0.3"
-
defaultConfig {
-
applicationId "com.chy.arcgisforpipeline"
-
minSdkVersion 19
-
targetSdkVersion 29
-
versionCode 1
-
versionName "1.0"
-
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
-
}
-
buildTypes {
-
release {
-
minifyEnabled false
-
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
-
}
-
}
-
packagingOptions {
-
exclude 'META-INF/LGPL2.1'
-
exclude 'META-INF/LICENSE'
-
exclude 'META-INF/NOTICE'
-
}
-
repositories {
-
flatDir{
-
dirs 'libs'
-
}
-
}
-
}
-
dependencies {
-
implementation fileTree(dir: 'libs', include: ['*.jar'])
-
implementation 'androidx.appcompat:appcompat:1.1.0'
-
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
-
testImplementation 'junit:junit:4.12'
-
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
-
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
-
implementation(name:'arcgis-android-100.3.0', ext:'aar')
-
}
因为加载网络地图需要配置网络权限,因此需要在权限清单中加入网络权限。
<uses-permission android:name="android.permission.INTERNET"></uses-permission