当前位置: 首页 > 工具软件 > autonavi > 使用案例 >

高德地图报Native method not found: com.autonavi.amap.mapcore.MapCore.nativeNewInstance:

朱渝
2023-12-01

在集成高德地图demo时候遇到一个奇怪的问题,我是按照官网上的demo完全集成的, 却死活加载不出地图详情,并且抛出如下异常;

01-02 14:36:40.890 19044-19101/duck.mapdemo W/dalvikvm: No implementation found for native Lcom/autonavi/amap/mapcore/MapCore;.nativeNewInstance:(Ljava/lang/String;Ljava/lang/String;)J
01-02 14:36:40.890 19044-19101/duck.mapdemo W/System.err: java.lang.UnsatisfiedLinkError: Native method not found: com.autonavi.amap.mapcore.MapCore.nativeNewInstance:(Ljava/lang/String;Ljava/lang/String;)J
01-02 14:36:40.890 19044-19101/duck.mapdemo W/System.err:     at com.autonavi.amap.mapcore.MapCore.nativeNewInstance(Native Method)
01-02 14:36:40.890 19044-19101/duck.mapdemo W/System.err:     at com.autonavi.amap.mapcore.MapCore.newMap(MapCore.java:101)
01-02 14:36:40.890 19044-19101/duck.mapdemo W/System.err:     at com.amap.api.mapcore.util.b.C(AMapDelegateImp.java:443)
01-02 14:36:40.890 19044-19101/duck.mapdemo W/System.err:     at com.amap.api.mapcore.util.b.a(AMapDelegateImp.java:133)
01-02 14:36:40.890 19044-19101/duck.mapdemo W/System.err:     at com.amap.api.mapcore.util.b$1.run(AMapDelegateImp.java:340)
01-02 14:36:40.890 19044-19101/duck.mapdemo W/System.err:     at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1462)
01-02 14:36:40.890 19044-19101/duck.mapdemo W/System.err:     at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1240)


百度发现一哥门也跟我遇到同样的问题,他的解决办法是:

对比了一下高德提供的demo 发现少了x86的文件夹,将x86文件夹粘贴到lib目录下运行就好了

可是我在官网提供的demo上死活找不到X86文件夹~~~于是尴尬症又犯了~~只好接着找

果然功夫不负有心人,还真被我找到了这篇文章点击查看 ,错误原因是SO文件导入错了

正确的解决办法是:打开在APP下的build.gradle文件,在android下加入

   task nativeLibsToJar(type: Zip, description: "create a jar archive of the native libs") {
        destinationDir file("$projectDir/libs")
        baseName "Native_Libs2"
        extension "jar"
        from fileTree(dir: "libs", include: "**/*.so")
        into "lib"
    }

    tasks.withType(JavaCompile) {
        compileTask -> compileTask.dependsOn(nativeLibsToJar)
    }
完整的build.gradle文件如下:

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"
    defaultConfig {
        applicationId "duck.mapdemo"
        minSdkVersion 9
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        externalNativeBuild {
            cmake {
                cppFlags "-frtti -fexceptions"
            }
        }
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    externalNativeBuild {
        cmake {
            path "CMakeLists.txt"
        }
    }
    task nativeLibsToJar(type: Zip, description: "create a jar archive of the native libs") {
        destinationDir file("$projectDir/libs")
        baseName "Native_Libs2"
        extension "jar"
        from fileTree(dir: "libs", include: "**/*.so")
        into "lib"
    }

    tasks.withType(JavaCompile) {
        compileTask -> compileTask.dependsOn(nativeLibsToJar)
    }
}








 类似资料: