Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Qt Android demo 报错 Resource and asset merger: Duplicate resources #1875

Closed
Zmmfly opened this issue Dec 2, 2021 · 2 comments
Closed

Comments

@Zmmfly
Copy link
Contributor

Zmmfly commented Dec 2, 2021

xmake f -p android --ndk=R:\Tools\AndroidSDK\android-sdk-windows\ndk\21.3.6528147 --android_sdk=R:\Tools\AndroidSDK\android-sdk-windows -c

checking for architecture ... armeabi-v7a
checking for Android SDK directory ... R:\Tools\AndroidSDK\android-sdk-windows
checking for Build Tools Version of Android SDK ... 30.0.2
checking for NDK directory ... R:\Tools\AndroidSDK\android-sdk-windows\ndk\21.3.6528147
checking for SDK version of NDK ... 21
checking for Qt SDK directory ... R:/Qt/5.15.2/android
checking for Qt SDK version ... 5.15.2

xmake -v

checking for the shared library linker (sh) ... clang++
checking for the linker (ld) ... clang++
checking for clang++ ... R:\Tools\AndroidSDK\android-sdk-windows\ndk\21.3.6528147\toolchains\llvm\prebuilt\windows-x86_64\bin\clang++
checking for the c++ compiler (cxx) ... clang++
checking for the c++ compiler (cxx) ... clang++
checking for R:\Tools\AndroidSDK\android-sdk-windows\ndk\21.3.6528147\toolchains\llvm\prebuilt\windows-x86_64\bin\clang++ ... ok
checking for flags (-Oz) ... ok
checking for flags (-DNDEBUG) ... ok
checking for flags (-fPIC) ... no
checking for ccache ... no
[ 20%]: compiling.release src\main.cpp
R:\Tools\AndroidSDK\android-sdk-windows\ndk\21.3.6528147\toolchains\llvm\prebuilt\windows-x86_64\bin\clang++ -c --sysroot=R:\Tools\AndroidSDK\android-sdk-windows\ndk\21.3.6528147\toolchains\llvm\prebuilt\windows-x86_64\sysroot -isystem R:\Tools\AndroidSDK\android-sdk-windows\ndk\21.3.6528147\toolchains\llvm\prebuilt\windows-x86_64\sysroot\usr\include\arm-linux-androideabi -nostdinc++ -Qunused-arguments -target armv7-none-linux-androideabi21 -gcc-toolchain R:\Tools\AndroidSDK\android-sdk-windows\ndk\21.3.6528147\toolchains\arm-linux-androideabi-4.9\prebuilt\windows-x86_64 -D__ANDROID_API__=21 -mthumb -fPIC -Oz -std=c++11 -DQT_NO_DEBUG -DQT_DEPRECATED_WARNINGS -DQT_GUI_LIB -DQT_QUICK_LIB -DQT_QML_LIB -DQT_CORE_LIB -DQT_NETWORK_LIB -isystem R:\Qt\5.15.2\android\include\QtGui -isystem R:\Qt\5.15.2\android\include\QtGui\5.15.2 -isystem R:\Qt\5.15.2\android\include\QtGui\5.15.2\QtGui -isystem R:\Qt\5.15.2\android\include\QtQuick -isystem R:\Qt\5.15.2\android\include\QtQuick\5.15.2 -isystem R:\Qt\5.15.2\android\include\QtQuick\5.15.2\QtQuick -isystem R:\Qt\5.15.2\android\include\QtQml -isystem R:\Qt\5.15.2\android\include\QtQml\5.15.2 -isystem R:\Qt\5.15.2\android\include\QtQml\5.15.2\QtQml -isystem R:\Qt\5.15.2\android\include\QtCore -isystem R:\Qt\5.15.2\android\include\QtCore\5.15.2 -isystem R:\Qt\5.15.2\android\include\QtCore\5.15.2\QtCore -isystem R:\Qt\5.15.2\android\include\QtNetwork -isystem R:\Qt\5.15.2\android\include\QtNetwork\5.15.2 -isystem R:\Qt\5.15.2\android\include\QtNetwork\5.15.2\QtNetwork -isystem R:\Qt\5.15.2\android\include -isystem R:\Qt\5.15.2\android\mkspecs\android-clang -isystem R:\Tools\AndroidSDK\android-sdk-windows\ndk\21.3.6528147\sources\cxx-stl\llvm-libc++\include -isystem R:\Tools\AndroidSDK\android-sdk-windows\ndk\21.3.6528147\sources\cxx-stl\llvm-libc++\libs\armeabi-v7a\include -isystem R:\Tools\AndroidSDK\android-sdk-windows\ndk\21.3.6528147\sources\cxx-stl\llvm-libc++abi\include -DNDEBUG -o build\.objs\appdemo\android\armeabi-v7a\release\src\main.cpp.o src\main.cpp
[ 20%]: compiling.qt.qrc src\qml.qrc
R:\Qt\5.15.2\android\bin\rcc.exe -name qml src\qml.qrc -o build\.gens\appdemo\android\armeabi-v7a\release\rules\qt\qrc\qml.cpp
R:\Tools\AndroidSDK\android-sdk-windows\ndk\21.3.6528147\toolchains\llvm\prebuilt\windows-x86_64\bin\clang++ -c --sysroot=R:\Tools\AndroidSDK\android-sdk-windows\ndk\21.3.6528147\toolchains\llvm\prebuilt\windows-x86_64\sysroot -isystem R:\Tools\AndroidSDK\android-sdk-windows\ndk\21.3.6528147\toolchains\llvm\prebuilt\windows-x86_64\sysroot\usr\include\arm-linux-androideabi -nostdinc++ -Qunused-arguments -target armv7-none-linux-androideabi21 -gcc-toolchain R:\Tools\AndroidSDK\android-sdk-windows\ndk\21.3.6528147\toolchains\arm-linux-androideabi-4.9\prebuilt\windows-x86_64 -D__ANDROID_API__=21 -mthumb -fPIC -Oz -std=c++11 -DQT_NO_DEBUG -DQT_DEPRECATED_WARNINGS -DQT_GUI_LIB -DQT_QUICK_LIB -DQT_QML_LIB -DQT_CORE_LIB -DQT_NETWORK_LIB -isystem R:\Qt\5.15.2\android\include\QtGui -isystem R:\Qt\5.15.2\android\include\QtGui\5.15.2 -isystem R:\Qt\5.15.2\android\include\QtGui\5.15.2\QtGui -isystem R:\Qt\5.15.2\android\include\QtQuick -isystem R:\Qt\5.15.2\android\include\QtQuick\5.15.2 -isystem R:\Qt\5.15.2\android\include\QtQuick\5.15.2\QtQuick -isystem R:\Qt\5.15.2\android\include\QtQml -isystem R:\Qt\5.15.2\android\include\QtQml\5.15.2 -isystem R:\Qt\5.15.2\android\include\QtQml\5.15.2\QtQml -isystem R:\Qt\5.15.2\android\include\QtCore -isystem R:\Qt\5.15.2\android\include\QtCore\5.15.2 -isystem R:\Qt\5.15.2\android\include\QtCore\5.15.2\QtCore -isystem R:\Qt\5.15.2\android\include\QtNetwork -isystem R:\Qt\5.15.2\android\include\QtNetwork\5.15.2 -isystem R:\Qt\5.15.2\android\include\QtNetwork\5.15.2\QtNetwork -isystem R:\Qt\5.15.2\android\include -isystem R:\Qt\5.15.2\android\mkspecs\android-clang -isystem R:\Tools\AndroidSDK\android-sdk-windows\ndk\21.3.6528147\sources\cxx-stl\llvm-libc++\include -isystem R:\Tools\AndroidSDK\android-sdk-windows\ndk\21.3.6528147\sources\cxx-stl\llvm-libc++\libs\armeabi-v7a\include -isystem R:\Tools\AndroidSDK\android-sdk-windows\ndk\21.3.6528147\sources\cxx-stl\llvm-libc++abi\include -DNDEBUG -o build\.objs\appdemo\android\armeabi-v7a\release\gens\rules\qt\qrc\qml.cpp.o build\.gens\appdemo\android\armeabi-v7a\release\rules\qt\qrc\qml.cpp
checking for flags (-MMD -MF) ... ok
checking for flags (-fdiagnostics-color=always) ... ok
checking for flags (-Wl,-rpath=R:\Qt\5.15.2\android\lib) ... ok
[ 60%]: linking.release libappdemo.so
R:\Tools\AndroidSDK\android-sdk-windows\ndk\21.3.6528147\toolchains\llvm\prebuilt\windows-x86_64\bin\clang++ -o build\android\armeabi-v7a\release\libappdemo.so build\.objs\appdemo\android\armeabi-v7a\release\src\main.cpp.o build\.objs\appdemo\android\armeabi-v7a\release\gens\rules\qt\qrc\qml.cpp.o -shared -fPIC -llog -target armv7-none-linux-androideabi21 -gcc-toolchain R:\Tools\AndroidSDK\android-sdk-windows\ndk\21.3.6528147\toolchains\arm-linux-androideabi-4.9\prebuilt\windows-x86_64 -nostdlib++ -mthumb -LR:\Qt\5.15.2\android\lib -Wl,-rpath=R:\Qt\5.15.2\android\lib -s -LR:\Tools\AndroidSDK\android-sdk-windows\ndk\21.3.6528147\sources\cxx-stl\llvm-libc++\libs\armeabi-v7a -lQt5Gui_armeabi-v7a -lQt5Quick_armeabi-v7a -lQt5Qml_armeabi-v7a -lQt5Core_armeabi-v7a -lQt5Network_armeabi-v7a -lc++_static -lc++abi -lunwind -latomic
[ 80%]: generating.qt.app appdemo.apk
R:\Qt\5.15.2\android\bin\androiddeployqt.exe --input build\.qt\app\android\appdemo\android-deployment-settings.json --output build\.qt\app\android\appdemo\android-build --android-platform android-21 --jdk "C:\\Program Files\\Java\\jdk1.8.0_301" --gradle --no-gdbserver
Generating Android Package
  Input file: build\.qt\app\android\appdemo\android-deployment-settings.json
  Output directory: C:/Users/Zmmfly/Desktop/xmake_test/appdemo/build/.qt/app/android/appdemo/android-build/
  Application binary: appdemo
  Android build platform: android-21
  Install to device: No
  -- Skipping R:/Qt/5.15.2/android/plugins/iconengines/libplugins_iconengines_qsvgicon_armeabi-v7a.so. It has unmet dependencies: lib/libQt5Svg_armeabi-v7a.so,lib/libQt5Widgets_armeabi-v7a.so.
  -- Skipping R:/Qt/5.15.2/android/plugins/imageformats/libplugins_imageformats_qsvg_armeabi-v7a.so. It has unmet dependencies: lib/libQt5Svg_armeabi-v7a.so,lib/libQt5Widgets_armeabi-v7a.so.
> Task :preBuild UP-TO-DATE
> Task :preDebugBuild UP-TO-DATE
> Task :compileDebugAidl UP-TO-DATE
> Task :compileDebugRenderscript NO-SOURCE
> Task :generateDebugBuildConfig UP-TO-DATE
> Task :javaPreCompileDebug UP-TO-DATE
> Task :mainApkListPersistenceDebug UP-TO-DATE
> Task :generateDebugResValues UP-TO-DATE
> Task :generateDebugResources UP-TO-DATE

Warning: Mapping new ns http://schemas.android.com/repository/android/common/02 to old ns http://schemas.android.com/repository/android/common/01
Warning: Mapping new ns http://schemas.android.com/repository/android/generic/02 to old ns http://schemas.android.com/repository/android/generic/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/02 to old ns http://schemas.android.com/sdk/android/repo/addon2/01
> Task :mergeDebugResources FAILEDemas.android.com/sdk/android/repo/repository2/02 to old ns http://schemas.android.com/sdk/android/repo/repository2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/02 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01
[string/ministro_not_found_msg] R:\Qt\5.15.2\android\src\android\java\res\values\strings.xml [string/ministro_not_found_msg] C:\Users\Zmmfly\Desktop\xmake_test\appdemo\build\.qt\app\android\appdemo\android-build\res\values\strings.xml: Resource and asset merger: Duplicate resources
[string/ministro_needed_msg] R:\Qt\5.15.2\android\src\android\java\res\values\strings.xml [string/ministro_needed_msg] C:\Users\Zmmfly\Desktop\xmake_test\appdemo\build\.qt\app\android\appdemo\android-build\res\values\strings.xml: Resource and asset merger: Duplicate resources
[string/fatal_error_msg] R:\Qt\5.15.2\android\src\android\java\res\values\strings.xml [string/fatal_error_msg] C:\Users\Zmmfly\Desktop\xmake_test\appdemo\build\.qt\app\android\appdemo\android-build\res\values\strings.xml: Resource and asset merger: Duplicate resources
[string/unsupported_android_version] R:\Qt\5.15.2\android\src\android\java\res\values\strings.xml [string/unsupported_android_version] C:\Users\Zmmfly\Desktop\xmake_test\appdemo\build\.qt\app\android\appdemo\android-build\res\values\stri6 actionable tasks: 1 executed, 5 up-to-datee resources


FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':mergeDebugResources'.
> [string/ministro_not_found_msg] R:\Qt\5.15.2\android\src\android\java\res\values\strings.xml  [string/ministro_not_found_msg] C:\Users\Zmmfly\Desktop\xmake_test\appdemo\build\.qt\app\android\appdemo\android-build\res\values\strings.xml: Error: Duplicate resources
  [string/ministro_needed_msg] R:\Qt\5.15.2\android\src\android\java\res\values\strings.xml     [string/ministro_needed_msg] C:\Users\Zmmfly\Desktop\xmake_test\appdemo\build\.qt\app\android\appdemo\android-build\res\values\strings.xml: Error: Duplicate resources
  [string/fatal_error_msg] R:\Qt\5.15.2\android\src\android\java\res\values\strings.xml [string/fatal_error_msg] C:\Users\Zmmfly\Desktop\xmake_test\appdemo\build\.qt\app\android\appdemo\android-build\res\values\strings.xml: Error: Duplicate resources
  [string/unsupported_android_version] R:\Qt\5.15.2\android\src\android\java\res\values\strings.xml     [string/unsupported_android_version] C:\Users\Zmmfly\Desktop\xmake_test\appdemo\build\.qt\app\android\appdemo\android-build\res\values\strings.xml: Error: Duplicate resources

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 1s
Building the android package failed!
  -- For more information, run this command with --verbose.
error: execv(R:\Qt\5.15.2\android\bin\androiddeployqt.exe --input build\.qt\app\android\appdemo\android-deployment-settings.json --output build\.qt\app\android\appdemo\android-build --android-platform android-21 --jdk "C:\\Program Files\\Java\\jdk1.8.0_301" --gradle --no-gdbserver) failed(14)
warning: add_cxflags("-fPIC") is ignored, please pass `{force = true}` or call `set_policy("check.auto_ignore_flags", false)` if you want to set it.
@waruqi
Copy link
Member

waruqi commented Dec 2, 2021

if qt_sdkver and qt_sdkver:ge("5.14") then
-- @note we need patch values/res/strings.xml for Qt 5.14.0
local valuesdir = path.join(android_buildir, "java", "res", "values")
if not os.isdir(valuesdir) then
os.mkdir(valuesdir)
end
os.cp(path.join(qt.sdkdir, "src", "android", "java", "res", "values", "*"), valuesdir)
android_srcs = path.join(android_buildir, "java")
end

if android_srcs then
settings_file:print(' "android-package-source-directory": "%s",', _escape_path(android_srcs))

主要是这两地方,指定后,androiddeployqt 会自动在 build 模流生成 strings.xml,用于打包apk,但是里面跟 Qt 安装目录下的 strings.xml 几个资源名重复导致了问题。。

这块在低版本的 Qt 上之前测试是 ok 的,我不确定高版本上 Qt 又改了啥,我这暂时没 qt for android 环境测试,暂时无解。

你可以自己调下这块代码逻辑,或者可以用 QtCreator 编译打包 apk 后,抓下里面的 详细部署命令,贴下,对比下参数差异

@waruqi
Copy link
Member

waruqi commented Jan 4, 2022

dev 分支改了下,应该可以,xmake update dev

@waruqi waruqi closed this as completed Jan 4, 2022
@waruqi waruqi added this to the v2.6.3 milestone Jan 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants