建立专案时,取得来源和目的地必须是不同的错误 [英] Getting source and destination must be different error while building project
问题描述
我在构建项目时遇到此错误.尝试在android-studio中添加新库.基本上有一个主意的人,我正在尝试在这里创建一个新库.
I am getting this error while building project. Trying to add a new library in android-studio. Is there anybody who has an idea basically I am trying to create a new library here.
尝试的选项:
-
手动删除的版本
Manually deleted build
启动/重启缓存
逐步清除构建缓存
构建->清洁项目
但是构建失败.
源C:\ Users \ abc \ AndroidStudioProjects \ Events \ app \ build \ intermediates \ cmake \ debug \ obj \ armeabi-v7a \ libnative-lib.so和目标C:\ Users \ abc \ AndroidStudioProjects \ Events \ app \ build \ intermediates \ cmake \ debug \ obj \ armeabi-v7a \ libnative-lib.so必须不同
Source C:\Users\abc\AndroidStudioProjects\Events\app\build\intermediates\cmake\debug\obj\armeabi-v7a\libnative-lib.so and destination C:\Users\abc\AndroidStudioProjects\Events\app\build\intermediates\cmake\debug\obj\armeabi-v7a\libnative-lib.so must be different
我使用的是同样的CMakeLists.txt:
CMakeLists.txt I am using for the same:
# 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).
native-lib.cpp
)
add_library (
testLib
SHARED
TestClassesManager.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}
)
target_link_libraries(
testLib
native-lib
)
如果我要更换
target_link_libraries(
testLib
native-lib
)
通过
target_link_libraries(
testLib
${log-lib}
)
但是我想链接两个库.但这给了上面的错误.请帮忙.
But I want to link both libraries. But it is giving above error. Please help.
推荐答案
这是一个奇怪错误,但感谢您的简洁repro项目.其实有一天有人告诉我,但是我没有运气来重现失败.
This is a weird bug, but thank you for the concise repro project. Actually had someone mention this to me the other day but I hadn't had any luck reproducing the failure.
我仍在调查此处,但是目前看来,一种解决方法是运行干净,然后刷新链接的c ++项目,然后进行构建.如果需要使用刷新链接的c ++项目"按钮,请再次运行clean first .
I'm still investigating here, but for now it seems that a workaround is to run clean, then refresh linked c++ projects, then build. If you need to use the "refresh linked c++ projects" button, again, run clean first.
已修复补丁,将在4.0.1中发布.
A fix has been cherry-picked and will be in 4.0.1.
这篇关于建立专案时,取得来源和目的地必须是不同的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!