首页 / 浏览问题 / 移动GIS / 问题详情
java.lang.IllegalArgumentException报错
Ma
3EXP 2021年11月18日

修改了很多错误 最后还是提示我 keep stopping 

报错信息是 at com.example.supermapimobile3d.MainActivity.onCreate(MainActivity.java:23)

1个回答

您好,麻烦提供详细的报错信息
9,232EXP 2021年11月18日

我写了

ndk {
    abiFilters 'armeabi-v7a','x86','x86-64'
}以后

又报错了

Installation did not succeed.
The application could not be installed: INSTALL_FAILED_NO_MATCHING_ABIS

List of apks:
[0] 'D:\SuperMapiMobile3D\app\build\outputs\apk\debug\app-debug.apk'
Installation failed due to: 'INSTALL_FAILED_NO_MATCHING_ABIS: Failed to extract native libraries, res=-113'
这是错误原因

android {
    compileSdk 31

    defaultConfig {
        applicationId "com.example.supermapimobile3d"
        minSdk 21
        targetSdk 21
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        ndk {
            abiFilters 'armeabi-v7a','x86'
        }
    splits {
        abi {
            enable true
            reset()
            include 'x86', 'armeabi-v7a', 'x86-64'
            universalApk true
        }
    }
}
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    sourceSets {
        main{
            jniLibs.srcDirs=['libs']
        }
    }


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

dependencies {

    implementation 'androidx.appcompat:appcompat:1.2.0'
    implementation 'com.google.android.material:material:1.3.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
    implementation files('libs\\com.supermap.data_v1020.jar')
    implementation files('libs\\com.supermap.realspace_v1020.jar')
    testImplementation 'junit:junit:4.+'
    androidTestImplementation 'androidx.test.ext:junit:1.1.2'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}

写了ndk后还是有错误 然后百度写了

splits {
    abi {
        enable true
        reset()
        include 'x86', 'armeabi-v7a', 'x86-64'
        universalApk true
    }

然后又报错

E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.example.supermapimobile3d, PID: 17139
    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.supermapimobile3d/com.example.supermapimobile3d.MainActivity}: java.lang.NullPointerException: Attempt to get length of null array
Caused by: java.lang.NullPointerException: Attempt to get length of null array
        at com.supermap.data.Environment.checkAndLoadLibrary64(Environment.java:1736)
        at com.supermap.data.Environment.initialization(Environment.java:584)
        at com.example.supermapimobile3d.MainActivity.onCreate(MainActivity.java:24)

at com.example.supermapimobile3d.MainActivity.onCreate(MainActivity.java:24)还是这行报错

你那边看下libs里面的so文件的文件夹名称是啥?ndk里面就设置这个文件夹名称
是armeabi-v7a  那还需要x86吗
不需要了,只设置armeabi-v7a 就可以
...