ошибка: не удается получить доступ к файлу класса MapView для com.esri.android.map.MapView не найден - PullRequest
0 голосов
/ 07 сентября 2018

Я использую библиотеку ArcGis 10.2.29 в модуле (arcgislibrary), а в MainActivity мне нужно использовать классы в этом модуле.Итак, в модуле я создал файл MapViewExt, который расширяет MapView ArcGis:

public class MapViewExt extends MapView {

    private Context ctx;
    private GraphicsLayer gLayer;
    private static ArrayList<Point> allPoints;
    private static ArrayList<Point> selectedPoints;

    public MapViewExt(Context context, AttributeSet attrs) {
        super(context,attrs);
        this.ctx=context;
        InitializeMap();
    }

    private void InitializeMap() {
        setEsriLogoVisible(true);
        enableWrapAround(true);
        gLayer=new GraphicsLayer();
        addLayer(gLayer);
    }
}

Это файл Graddle модуля:

apply plugin: 'com.android.library'

android {
compileSdkVersion 28



defaultConfig {
    minSdkVersion 26
    targetSdkVersion 28
    versionCode 1
    versionName "1.0"

    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

}

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}

}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.esri.arcgis.android:arcgis-android:10.2.9'
implementation 'com.android.support:appcompat-v7:28.0.0-rc02'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}

Файл Gradle приложенияМодуль, в котором MainActivity:

apply plugin: 'com.android.application'

android {
compileSdkVersion 28
defaultConfig {
    applicationId "com.my.domain.arcgislib"
    minSdkVersion 26
    targetSdkVersion 28
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
packagingOptions{
    exclude 'META-INF/LGPL2.1'
    exclude 'META-INF/LICENSE'
    exclude 'META-INF/NOTICE'
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0-rc02'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation project (':arcgislibrary')
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
} 

и MainActivity, со своим макетом:

public class MainActivity extends AppCompatActivity {

private MapViewExt mapView;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    mapView = findViewById(R.id.map);
}
}

XML-макет:

<?xml version="1.0" encoding="utf-8"?>
    <android.support.constraint.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">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Hello World!"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <path.to.mapviewext.components.MapViewExt
        android:id="@+id/map"
        mapoptions.MapType="Topo"
        mapoptions.ZoomLevel="13"
        mapoptions.center="40.4893538, -3.6827461"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"/>
        />

</android.support.constraint.ConstraintLayout>

У меня нет ошибок компиляции, все выглядит нормально, если я напишу «Map», сделаю ctrl + пробел в MainActivity, я могу выбрать MapViewExt.Однако при запуске проекта я получил ошибку:

error: cannot access MapView
class file for com.esri.android.map.MapView not found

Что не так с моим проектом?Как я могу исправить эту ошибку?

РЕДАКТИРОВАТЬ:

Если я добавлю реализацию 'com.esri.arcgis.android:arcgis-android:10.2.9' в файл приложения build.gradle, приложение будет работать нормально.Но это неприемлемо, поскольку моя цель - создать файл aar с моим модулем, поэтому пользователю .aar не нужно импортировать библиотеку ESRI.

...