我正在尝试集成第三方sdk(deepar)。但是当我构建它的时候,它显示了一个错误。我试着修好它。如果我创建一个简单的新项目,它的工作正常。但我现有的应用程序我使用相机和ndk。请帮我找出错误。
这是cmakelist文件。
# For more information about using CMake with Android Studio, read the
# documentation: https://d.android.com/studio/projects/add-native-code.html
# Sets the minimum version of CMake required to build the native library.
cmake_minimum_required(VERSION 3.4.1)
# Creates and names a library, sets it as either STATIC
# or SHARED, and provides the relative paths to its source code.
# You can define multiple libraries, and CMake builds them for you.
# Gradle automatically packages shared libraries with your APK.
add_library( # Sets the name of the library.
native-lib
# Sets the library as a shared library.
SHARED
# Provides a relative path to your source file(s).
src/main/cpp/native-lib.cpp)
# Searches for a specified prebuilt library and stores the path as a
# variable. Because CMake includes system libraries in the search path by
# default, you only need to specify the name of the public NDK library
# you want to add. CMake verifies that the library exists before
# completing its build.
find_library( # Sets the name of the path variable.
log-lib
# Specifies the name of the NDK library that
# you want CMake to locate.
log)
# Specifies libraries CMake should link to your target library. You
# can link multiple libraries, such as libraries you define in this
# build script, prebuilt third-party libraries, or system libraries.
target_link_libraries( # Specifies the target library.
native-lib
# Links the target library to the log library
# included in the NDK.
${log-lib})
活动类
public class DeeparActivity extends AppCompatActivity implements AREventListener {
private CameraGrabber cameraGrabber;
private int defaultCameraDevice = Camera.CameraInfo.CAMERA_FACING_FRONT;
private int cameraDevice = defaultCameraDevice;
private DeepAR deepAR;
private int currentMask = 0;
private int currentEffect = 0;
private int currentFilter = 0;
private int screenOrientation;
ArrayList<String> masks;
ArrayList<String> effects;
ArrayList<String> filters;
private int activeFilterType = 0;
private boolean recording = false;
private boolean currentSwitchRecording = false;
private String recordingPath = Environment.getExternalStorageDirectory() + File.separator + "video.mp4";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_deepar);
deepAR = new DeepAR(this);
deepAR.setLicenseKey("foobarbaz");
deepAR.initialize(this, this);
setupCamera();
}
private void setupCamera() {
cameraGrabber = new CameraGrabber(cameraDevice);
screenOrientation = getScreenOrientation();
switch (screenOrientation) {
case ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE:
cameraGrabber.setScreenOrientation(90);
break;
case ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE:
cameraGrabber.setScreenOrientation(270);
break;
default:
cameraGrabber.setScreenOrientation(0);
break;
}
// Available 1080p, 720p and 480p resolutions
cameraGrabber.setResolutionPreset(CameraResolutionPreset.P1280x720);
final Activity context = this;
cameraGrabber.initCamera(new CameraGrabberListener() {
@Override
public void onCameraInitialized() {
cameraGrabber.setFrameReceiver(deepAR);
cameraGrabber.startPreview();
}
@Override
public void onCameraError(String errorMsg) {
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setTitle("Camera error");
builder.setMessage(errorMsg);
builder.setCancelable(true);
builder.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
dialogInterface.cancel();
}
});
AlertDialog dialog = builder.create();
dialog.show();
}
});
}
}
下面给出了准确的误差
2020-11-20 00:17:37.274 7565-7728/com.songsterbd.songster E/IJKMEDIA: Option ijkiomanager not found.
2020-11-20 00:17:39.691 7565-7565/com.songsterbd.songster E/sterbd.songste: No implementation found for void ai.deepar.ar.DeepAR.setLicenseKeyN(java.lang.String) (tried Java_ai_deepar_ar_DeepAR_setLicenseKeyN and Java_ai_deepar_ar_DeepAR_setLicenseKeyN__Ljava_lang_String_2)
2020-11-20 00:17:39.692 7565-7565/com.songsterbd.songster E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.songsterbd.songster, PID: 7565
java.lang.UnsatisfiedLinkError: No implementation found for void ai.deepar.ar.DeepAR.setLicenseKeyN(java.lang.String) (tried Java_ai_deepar_ar_DeepAR_setLicenseKeyN and Java_ai_deepar_ar_DeepAR_setLicenseKeyN__Ljava_lang_String_2)
at ai.deepar.ar.DeepAR.setLicenseKeyN(Native Method)
at ai.deepar.ar.DeepAR.setLicenseKey(DeepAR.java:223)
at com.songsterbd.songster.view.activity.DeeparActivity.initializeDeepAR(DeeparActivity.java:363)
at com.songsterbd.songster.view.activity.DeeparActivity.initialize(DeeparActivity.java:105)
at com.songsterbd.songster.view.activity.DeeparActivity.onCreate(DeeparActivity.java:79)
at android.app.Activity.performCreate(Activity.java:7136)
at android.app.Activity.performCreate(Activity.java:7127)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1271)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2893)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
我试着修好它。如果需要更多的信息,一定要告诉我。我很感激你。谢谢
1条答案
按热度按时间zaq34kh61#
一周后我找到了解决办法。它与库产生冲突。我将cmakelists文件更改为新文件,然后删除冲突。
现在工作的cmakelist文件是: