ArcGIS Runtime for Android 1

16 篇文章 4 订阅

Environment:

1. Java 1.8.0_241

2. Android Studio 4.0

3. Gradle 6.4.1

 

Android Studio > Create New Project > Phone and Tablet - Empty Activity

Edit: Mapfinder\build.gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath "com.android.tools.build:gradle:4.0.0"

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()
        
        // ****************************************
        maven {
            url 'https://esri.bintray.com/arcgis'
        }
        // ****************************************
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

Edit: Mapfinder\app\build.gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 29
    buildToolsVersion "29.0.3"

    defaultConfig {
        applicationId "demos.arcgisruntime.XXX.com.mapfinder"
        minSdkVersion 21
        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'
        }
    }

    // **************************************************
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    // **************************************************
}

dependencies {
    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'

    // **************************************************
    // ArcGIS Runtime Dependencies
    implementation 'com.esri.arcgisruntime:arcgis-android:100.9.0'
    implementation fileTree(dir: 'libs', includes: ['*.jar'])
    // **************************************************
}

- Sync Project with Gradle Files (Sync now)

Edit: Mapfinder\app\src\main\AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="demos.arcgisruntime.XXX.com.mapfinder">

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

// ***************************************************
    <!-- Internet required -->
    <uses-permission android:name="android.permission.INTERNET" />

    <!-- OpenGL ES -->
    <uses-feature android:glEsVersion="0x00020000" android:required="true" />
// ***************************************************
</manifest>

Edit (Layout): Mapfinder\app\src\main\res\layout\activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <!-- MapView Control -->
    <com.esri.arcgisruntime.mapping.view.MapView
        android:id="@+id/mapView"
        android:layout_width="match_parent"
        android:layout_height="match_parent" >
    </com.esri.arcgisruntime.mapping.view.MapView>

</androidx.constraintlayout.widget.ConstraintLayout>

Edit: MainActivity.java

package demos.arcgisruntime.XXX.com.mapfinder;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;

import com.esri.arcgisruntime.mapping.ArcGISMap;
import com.esri.arcgisruntime.mapping.Basemap;
import com.esri.arcgisruntime.mapping.view.MapView;


public class MainActivity extends AppCompatActivity {
    private MapView _mapView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

         _mapView = (MapView) findViewById(R.id.mapView);
         ArcGISMap map = new ArcGISMap(Basemap.Type.STREETS_VECTOR,42.81 , -73.94, 10);
         _mapView.setMap(map);
    }

    @Override
    protected void onPause(){
        _mapView.pause();
        super.onPause();
    }

    @Override
    protected void onResume(){
        super.onResume();
        _mapView.resume();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        _mapView.dispose();
    }
}

 

Solved problems:

Connection timed out: connect. If you are behind an HTTP proxy, please configure the proxy settings either in IDE or Gradle.
> Switch Network (Stable)


Duplicate class com.esri.arcgisruntime.ArcGISRuntimeEnvironment found in modules jetified-arcgis-android-100.9.0-runtime.jar (arcgis-android-100.9.0.aar) and jetified-arcgis-android-100.9.0-runtime.jar (com.esri.arcgisruntime:arcgis-android:100.9.0)
> Delete file (arcgis-android-100.9.0.aar) in libs.

Binary XML file line #19 in demos.arcgisruntime.transfinder.com.mapfinder:layout/activity_main: Error inflating class com.esri.arcgisruntime.mapping.view.MapView
> build.gradle (:app)

android {
    ...

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值