错误:找不到com.esri.android.map.MapView的MapView类文件

时间:2018-09-07 07:24:09

标签: android android-gradle arcgis esri

我在一个模块(arcgislibrary)中使用ArcGis库10.2.29,在MainActivity中,我需要在该模块中使用这些类。因此,在Module中,我创建了一个MapViewExt文件,该文件扩展了ArcGis的MapView:

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);
    }
}

这是模块的毕业文件:

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'
}

应用程序模块的成绩文件,其中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”,在MainActivity中执行ctrl + spacebar,则可以选择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库。

0 个答案:

没有答案