【发布时间】:2022-01-18 14:08:13
【问题描述】:
执行应用程序发生异常
无法定位由
引用的符号“ANativeWindow_fromSurfaceTexture”System.loadLibrary("aaa");
在aaa.so文件中使用了ANativeWindow_fromSurfaceTexture函数(错误)
但使用 ANativeWindow_fromSurface 函数(没问题)
我找到了 Android\Sdk\ndk-bundle\sysroot\usr\include\android\native_window_jni.h
#if __ANDROID_API__ >= 13
/**
* Return the ANativeWindow associated with a Java SurfaceTexture object,
* for interacting with it through native code. This acquires a reference
* on the ANativeWindow that is returned; be sure to use ANativeWindow_release()
* when done with it so that it doesn't leak.
*/
ANativeWindow* ANativeWindow_fromSurfaceTexture(JNIEnv* env, jobject surfaceTexture);
#endif
我的 build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "test.com.trytryNdk"
minSdkVersion 16
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
ndk{
ldLibs "log", "z", "m", "OpenMAXAL", "android"
}
externalNativeBuild {
ndkBuild {
arguments "APP_PLATFORM=android-16"
}
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
sourceSets {
main {
jniLibs.srcDirs = ['libs']
jni.srcDirs = []
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
}
【问题讨论】:
-
这是什么设备?
-
测试设备:Sony Z、华为、Nexus 7、Nexus 9 版本:Android 4.4、5.1、7
-
我相信@fadden 不久前回答了这个问题:stackoverflow.com/a/24313036/192373
-
呃。 API 不应该像这样被删除。我刚刚上传了从 NDK 中删除 decl 和符号的更改,因此这将是构建失败而不是运行时失败。
标签: android android-ndk