gpt4 book ai didi

java - 如何修复 java.util.zip.ZipException : duplicate entry while doing android studio cocos compile?

转载 作者:行者123 更新时间:2023-12-01 09:50:11 25 4
gpt4 key购买 nike

对proj.android-studio进行cocos编译时

cocos compile -m debug  -p android -NDK-MODE debug --app-abi armeabi --android-studio 

我收到以下异常。

任务“:BreakPots:transformClassesWithJarMergingForDebug”执行失败。

com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: android/support/v4/util/LongSparseArray.class

请查看 Android Studio 中 licocos2dx 模块中的 build.gradle。

apply plugin: 'com.android.library'

android {
compileSdkVersion 22
buildToolsVersion '22.0.1'
defaultConfig {
versionCode 1
versionName "1.0"
minSdkVersion 15
targetSdkVersion 22

}
sourceSets.main {
aidl.srcDir "../java/src"
java.srcDir "../java/src"
manifest.srcFile "AndroidManifest.xml"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
}

dependencies {

compile fileTree(include: ['*.jar'], dir: '../java/libs')
compile project(':facebook_lib')


}

显示库屏幕截图的项目结构: enter image description here我的 Android.mk 文件内容

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

$(call import-add-path,$(LOCAL_PATH)/../../../cocos2d)
$(call import-add-path,$(LOCAL_PATH)/../../../cocos2d/external)
$(call import-add-path,$(LOCAL_PATH)/../../../cocos2d/cocos)
$(call import-add-path, $(LOCAL_PATH))

LOCAL_MODULE := cocos2dcpp_shared

LOCAL_MODULE_FILENAME := libcocos2dcpp

LOCAL_SRC_FILES := hellocpp/main.cpp \
../../../Classes/AppDelegate.cpp \
../../../Classes/GameScene.cpp

LOCAL_CPPFLAGS := -DSDKBOX_ENABLED
LOCAL_LDLIBS := -landroid \
-llog

LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../../Classes

LOCAL_WHOLE_STATIC_LIBRARIES := PluginSdkboxAds \
sdkbox \
PluginReview \
PluginAdMob \
PluginFacebook \
PluginOneSignal \
PluginSdkboxPlay

# _COCOS_HEADER_ANDROID_BEGIN
# _COCOS_HEADER_ANDROID_END


LOCAL_STATIC_LIBRARIES := cocos2dx_static

##LOCAL_WHOLE_STATIC_LIBRARIES += PluginAdMob
##LOCAL_WHOLE_STATIC_LIBRARIES += sdkbox
##LOCAL_WHOLE_STATIC_LIBRARIES += android_native_app_glue
##LOCAL_LDLIBS += -landroid
##LOCAL_LDLIBS += -llog
##LOCAL_WHOLE_STATIC_LIBRARIES += PluginSdkboxPlay
##LOCAL_WHOLE_STATIC_LIBRARIES += PluginOneSignal
##LOCAL_WHOLE_STATIC_LIBRARIES += sdkbox

# _COCOS_LIB_ANDROID_BEGIN
# _COCOS_LIB_ANDROID_END

include $(BUILD_SHARED_LIBRARY)

$(call import-add-path,$(LOCAL_PATH))

$(call import-module,.)

$(call import-module, ./sdkbox)
$(call import-module, ./pluginsdkboxads)
$(call import-module, ./pluginreview)
$(call import-module, ./pluginadmob)
$(call import-module, ./pluginfacebook)
$(call import-module, ./pluginonesignal)
$(call import-module, ./pluginsdkboxplay)

# _COCOS_LIB_IMPORT_ANDROID_BEGIN
# _COCOS_LIB_IMPORT_ANDROID_END

最佳答案

我自己回答这个问题,因为没有人回复。

我自己修好了。解决办法就是这么简单。我有两个 build.gradle 文件。每个模块都有一个。

在“App”模块的build.gradle文件中,让android编译sdk版本和目标为23。但是在“libcocos2dx”模块的build.gradle文件中,让android编译sdk版本和目标为22。这就是所有的原因这部剧。

在两个 build.gradle 文件中,将版本设为 22,并且效果非常好。

更新:

后来我将版本增加到23,并提出了另一个“org.apache.....”的gradle构建问题。我通过在“libcocos2dx”模块的 build.gradle 文件中添加以下行来修复它。

android {
useLibrary 'org.apache.http.legacy'
}

关于java - 如何修复 java.util.zip.ZipException : duplicate entry while doing android studio cocos compile?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37643761/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com