MapView is blank

2117
7
01-02-2021 10:29 PM
AmitKahn1
New Contributor II

Hello,

I am using 

com.esri.arcgisruntime:arcgis-android:100.9.0

 In our project we have other libraries that are using ndk code. This code is https://voicelayer.io library. I had compile issues that were solved by adding to Gradle:

packagingOptions {
pickFirst "**/libc++_shared.so"
}

sourceSets {
main {
jniLibs.srcDirs 'src/main/cpp/libs'
}
}

 

However, thaw project compiles, during runtime MapView is blank. There is runtime error:

Fatal Exception: java.lang.UnsatisfiedLinkError
dlopen failed: cannot locate symbol "_ZTISt12bad_any_cast" referenced by "/data/app/~~uUhKQILyWGcrKBnY0Jt6ag==/com.snap.android.apis.dev-QExIXjmVL_fg0C3XYZJrIQ==/base.apk!/lib/x86/libruntimecore.so"... 

com.esri.arcgisruntime.ArcGISRuntimeEnvironment.a (SourceFile:230)
com.esri.arcgisruntime.ArcGISRuntimeEnvironment.initialize (SourceFile:204)
com.esri.arcgisruntime.internal.jni.CoreMap.<clinit> (SourceFile:49)
com.esri.arcgisruntime.mapping.ArcGISMap.<init> (SourceFile:370)
 
....MainActivity.onCreate (MainActivity.kt:295)

 

I've tried to work around it any possible way, by removing libraries from project and test it over and over again. I could not find the source of the problem.

I've created a sample project with the exact same libraries in Gradle and MapView shown as expected.

I suspect that in the original project we actually load and use the third party NDK before we use the ESRI MapView and maybe that cause the problem.

I assume having ESRI deployed side by side with other libraries that are using NDK is common and I was surprised ESRI Documentation skipped this possibility.

You can find below a copy of the Gradle. 

Thank you in advance for any assistance.

Best regards,

Gabriel

Gabriel.Noam@Cognyte.com

 

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
apply plugin: 'com.google.firebase.crashlytics'

android {
compileSdkVersion 29
buildToolsVersion '29.0.3'
defaultConfig {
applicationId "....."
minSdkVersion 23
targetSdkVersion 29
versionCode 507100001
versionName "5.7.100.001"
ndk {
abiFilters "armeabi", "armeabi-v7a", "arm64-v8a", "x86", "x86_64"
}
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'

kotlinOptions {
jvmTarget = '1.8'
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

javaCompileOptions {
annotationProcessorOptions {
arguments += [
"room.schemaLocation":"$projectDir/schemas".toString(),
"room.incremental":"true",
"room.expandProjection":"true"]
}
}

buildTypes {
debug {
minifyEnabled false
debuggable true
}

release {
debuggable false
// Cannot minifyEnabled true, causes runtime exceptions
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}

flavorDimensions "version"
productFlavors {
dev {
applicationIdSuffix ".dev"
dimension "version"
}
stable {
applicationIdSuffix ".stable"
dimension "version"
}
prod {
dimension "version"
}
}
}

/**** SIGNING CONFIG HERE ***/

lintOptions {
abortOnError true
}

packagingOptions {
pickFirst "**/libc++_shared.so"
}

sourceSets {
main {
jniLibs.srcDirs 'src/main/cpp/libs'
}
}

buildFeatures{
dataBinding = true
viewBinding = true
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

testOptions {
unitTests.includeAndroidResources = true
}

// StampBuild - generate a file with the build date as constant.
task markVersion(type: Exec) {
commandLine('pwd')
commandLine "python", "../../tools/stampBuild.py", "${defaultConfig.applicationId}"
}
task checkDebugDelinquency(type: Exec) {
logging.captureStandardOutput LogLevel.WARN
commandLine "python", "../../tools/checkDelinquentBuild.py", "${defaultConfig.applicationId}"
}

preBuild.dependsOn markVersion, checkDebugDelinquency
}

repositories {
maven { url 'https://raw.github.com/applanga/sdk-android/master/maven/releases/'}
maven { url 'https://jitpack.io' }
}

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation fileTree(dir: 'libs', include: ['*.jar'])
//noinspection GradleDynamicVersion
implementation 'com.opentok.android:opentok-android-sdk:2.16.4'
implementation('io.socket:socket.io-client:1.0.0') {
// excluding org.json which is provided by Android
exclude group: 'org.json', module: 'json'
}

//implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.exifinterface:exifinterface:1.3.0'
implementation "androidx.appcompat:appcompat:$appcompat_version"
implementation "androidx.constraintlayout:constraintlayout:$constraintlayout_version"
implementation "androidx.vectordrawable:vectordrawable:$vectordrawable_version"

//noinspection GradleDependency,GradleDynamicVersion
//implementation 'io.intercom.android:intercom-sdk-base:6.+'

implementation "com.google.guava:guava:$guava_version"
implementation "com.google.protobuf:protobuf-java:$protobuf_version"

//AppLanga
implementation "com.applanga.android:Applanga:$applanga_version"
// Lock pattern


// implementation 'com.bcgdv.asia.lib:connectpattern:0.3'


// PTT
//implementation 'com.skyfishjy.ripplebackground:library:1.0.1'


implementation 'io.jsonwebtoken:jjwt:0.9.1'
implementation "com.squareup.okhttp3:okhttp:$okhttp3_version"
implementation "com.google.code.gson:gson:$gson_version"

// Misc
implementation 'jp.wasabeef:richeditor-android:1.2.2'

implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$kotlin_coroutine_version"
implementation 'com.squareup.picasso:picasso:2.71828'

// EddyStone
implementation 'com.neovisionaries:nv-bluetooth:1.8'

// Barcode scanner
// implementation 'com.journeyapps:zxing-android-embedded:3.6.0'

// ESRI
implementation "androidx.browser:browser:1.0.0"
implementation "com.esri.arcgisruntime:arcgis-android:$esri_version"
//implementation (name: 'arcgis-android-100.9.0', ext: 'aar')

// Testing
testImplementation 'junit:junit:4.13.1'
testImplementation 'com.google.truth:truth:1.0'

testImplementation 'androidx.test:core:1.3.0'
testImplementation 'org.mockito:mockito-core:3.1.0'

// Testfairy
debugImplementation 'testfairy:testfairy-android-sdk:1.+@aar'

// timber v4
implementation "com.jakewharton.timber:timber:$timber_version"

implementation "androidx.media:media:$media_version"
implementation "androidx.fragment:fragment-ktx:$fragment_ktx_version"
implementation "com.google.android.material:material:$material_version"
implementation "androidx.recyclerview:recyclerview:$recyclerview_version"


implementation "org.koin:koin-androidx-scope:$koin_version"
implementation "org.koin:koin-androidx-viewmodel:$koin_version"
implementation "org.koin:koin-androidx-fragment:$koin_version"

// Firebase
api "com.google.firebase:firebase-messaging:$firebase_messaging_version"
implementation "com.firebase:firebase-jobdispatcher:$firebase_jobdispatcher_version"
api "com.google.firebase:firebase-core:$firebase_core_version"
api "com.google.firebase:firebase-analytics:$firebase_version"

// Import the BoM for the Firebase platform
api platform("com.google.firebase:firebase-bom:$firebase_bom_version")

// When using the BoM, don't need to specify versions in Firebase library dependencies
implementation 'com.google.firebase:firebase-crashlytics-ktx'
implementation 'com.google.firebase:firebase-analytics-ktx'

implementation "androidx.work:work-runtime-ktx:$work_version"

implementation "com.github.bumptech.glide:glide:$glide_version"
kapt "com.github.bumptech.glide:compiler:$glide_version"

implementation "com.squareup.retrofit:retrofit:$retrofit_version"
implementation "com.squareup.retrofit:converter-gson:$retrofit_version"

implementation "com.squareup.retrofit2:retrofit:$retrofit2_version"
implementation "com.squareup.retrofit2:converter-gson:$retrofit2_version"
implementation "com.squareup.retrofit2:converter-jackson:$retrofit2_version"
implementation "com.squareup.retrofit2:converter-scalars:$retrofit2_version"

implementation "com.google.android.gms:play-services-analytics:$play_services_analytics_version"
implementation "com.google.android.gms:play-services-gcm:$play_services_gcm_version"
implementation "com.google.android.gms:play-services-maps:$play_services_maps_version"
implementation "com.google.android.gms:play-services-location:$play_services_location_version"

implementation "androidx.room:room-ktx:$room_version"
implementation "androidx.room:room-runtime:$room_version"
//noinspection GradleDependency
testImplementation "androidx.room:room-testing:$room_version"

kapt "androidx.room:room-compiler:$room_version"

implementation "androidx.lifecycle:lifecycle-livedata-ktx:$lifecycle_version"
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version"
implementation "androidx.lifecycle:lifecycle-runtime-ktx:$lifecycle_version"
implementation "androidx.lifecycle:lifecycle-reactivestreams-ktx:$lifecycle_version"
implementation "androidx.lifecycle:lifecycle-service:$lifecycle_version"
implementation "androidx.lifecycle:lifecycle-process:$lifecycle_version"
implementation "androidx.lifecycle:lifecycle-extensions:$lifecycle_version"
implementation "androidx.lifecycle:lifecycle-viewmodel-savedstate:$lifecycle_version"
implementation "androidx.lifecycle:lifecycle-common-java8:$lifecycle_version"
implementation "androidx.lifecycle:lifecycle-process:$lifecycle_version"

//noinspection LifecycleAnnotationProcessorWithJava8
kapt "androidx.lifecycle:lifecycle-compiler:$lifecycle_version"
kapt "com.android.databinding:compiler:$databinding_compiler_version"

implementation project(path: ':fliclib')
implementation project(path: ':viziblezone')
implementation project(':voicelayersdk')
}

buildscript {
repositories {
maven {
url 'https://raw.github.com/applanga/sdk-android/master/maven/releases/'
}
jcenter()
}
dependencies {
classpath "com.applanga.android:plugin:$applanga_version"
}
}

apply plugin: 'com.google.gms.google-services'

 

buildscript {
ext.gradle_version = '4.2.0-beta01'
ext.kotlin_version = '1.4.10'
ext.kotlin_coroutine_version = '1.3.6'
ext.applanga_version = '3.0.132'
ext.gson_version = '2.8.5'
ext.appcompat_version = '1.2.0'
ext.core_ktx_version = '1.3.2'
ext.constraintlayout_version = '2.0.2'
ext.material_version = '1.2.1'
ext.lifecycle_version = "2.2.0"
ext.google_services_version = '4.3.4'
ext.crashlytics_gradle_version = '2.4.1'
ext.realm_version = '6.0.2'
ext.protobuf_version = '3.11.0'
ext.okhttp3_version = '4.2.2'
ext.recyclerview_version = '1.1.0'
ext.room_version = '2.2.5'
ext.play_services_gcm_version = "17.0.0"
ext.play_services_maps_version = "17.0.0"
ext.play_services_location_version = "17.1.0"
ext.play_services_analytics_version = "17.0.0"
ext.retrofit_version = "2.0.0-beta2"
ext.retrofit2_version = "2.9.0"
ext.glide_version = "4.11.0"
ext.work_version = "2.4.0"
ext.fragment_ktx_version = '1.2.5'
ext.databinding_compiler_version = '3.1.4'
ext.firebase_messaging_version = '21.0.0'
ext.media_version = '1.2.0'
ext.vectordrawable_version = '1.1.0'
ext.guava_version = '27.0.1-android'
ext.koin_version = '2.2.0-alpha-1'
ext.timber_version = '4.7.1'
ext.firebase_bom_version = "26.1.0"
ext.firebase_version = "18.0.0"
ext.firebase_core_version = "18.0.0"
ext.firebase_crashlytics_version = "17.3.0"
ext.firebase_jobdispatcher_version = "0.8.5"
ext.esri_version = "100.9.0"

repositories {
jcenter()
google()
maven {
url 'https://dl.bintray.com/intercom/intercom-maven'
}
}
dependencies {
classpath "io.realm:realm-gradle-plugin:$realm_version"
classpath "com.android.tools.build:gradle:$gradle_version"
classpath "com.google.gms:google-services:$google_services_version"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version"
classpath "com.google.firebase:firebase-crashlytics-gradle:$crashlytics_gradle_version"
}
}

allprojects {
repositories {
jcenter()
maven {
url 'https://esri.jfrog.io/artifactory/arcgis'
}
maven {
url 'https://tokbox.bintray.com/maven'
}
maven {
url "https://maven.google.com"
}
maven {
url 'https://jitpack.io'
}
flatDir {
dirs 'libs', '../viziblezone/libs'
}

google()
}
}

 

7 Replies
GuntherHeppner
Esri Contributor

Hi Gabriel,

 

I noticed the following line in your gradle file:

abiFilters "armeabi", "armeabi-v7a", "arm64-v8a", "x86", "x86_64"

Note that ArcGIS Runtime only supports "armeabi-v7a", "arm64-v8a" and "x86". If you change the line to the following, does it work?

abiFilters "armeabi-v7a", "arm64-v8a", "x86"
0 Kudos
AmitKahn1
New Contributor II

Thank you for your suggestion, this has been tried as well, no success. 

Our application contains another library that uses native code: https://voicelayer.io

The problem is that both Esri and Voicelayer.io has the libc++_shared.so file from different versions.

So looking for the most common things between to was indeed using just 

abiFilters "armeabi-v7a", "arm64-v8a", "x86"

 However, having both on com.esri.arcgisruntime:arcgis-android and voicelayer.io created a collision during the build. Using 

packagingOptions {
pickFirst "**/libc++_shared.so"
}

Created a runtime error in which voicelayer was "happy" (manage to load), but esri had runtime  linkage issue for "missing symbols" ... and this is because esri NDK version is different than voicelayer. .... looks like esri is more advanced.

Next, I've decided to work with ARR files only of esri and voicelayer.io. I've RE-PACKED them (!) where in which only libc++_shared.so of esri is used .... 

However, another runtime error happened ... 😞 looks like packaging is not enough, I *assume* that the one library should be built and pack with the exact NDK version of the other.

The error was java.lang.UnsatisfiedLinkError: dlopen failed: "........so"

 

Summary: 3 things were tested:

- using limited abiFilters that supported by esri

- pickFirst "**/libc++_shared.so"

- Work with repacked AARs of esri and voicelayer each time do it with one of the libc++_shared.so of them

Looking forward for any advise.

Best regards,

Gabriel 

 

0 Kudos
MarkBaird
Esri Regular Contributor
0 Kudos
AmitKahn1
New Contributor II

Thank you for your suggestion, we aware of using bundles. However our app is legacy architecture we should keep for now. On future plan to change it to be packed as bundle. 

0 Kudos
OnSSIDev
New Contributor

Hi,

Did you manage to solve this issue?

0 Kudos
ahmedelsawwah
New Contributor

how do you fix this issue 

0 Kudos
ahmedelsawwah
New Contributor

please if you can help on this did you fix it

 

0 Kudos