检查APK是否打进Jar包
1.apk用winrar打开,提取class.dex文件,用dex2jar转换为jar文件
Temp目录
数据缓存(Data caches),写入临时文件和其他操作系统维护相关的东西就扔到 Temp 目录。如果是安卓出包,可以初步检查里面jar包是否打入
Jar包移动路径后重复打入jar
值得注意:如果一个cloudcore.jar包直接放入Assets/Plugins/Android目录下,识别为了native文件,为一个拼图icon
再移入例如Assets/Plugins/Android/GCloudCore/ib目录下,
打apk失败,报错
CommandInvokationFailure: Unable to convert classes into dex format.
E:/AndroidSdk/jre\bin\java.exe -Xmx4096M -Dcom.android.sdkmanager.toolsdir=“E:/AndroidSdk/UnityAndroidSdk/sdk\tools” -Dfile.encoding=UTF8 -jar “D:\Program Files\Unity2017.4.40\Editor\Data\PlaybackEngines\AndroidPlayer/Tools\sdktools.jar” -
stderr[
warning: Ignoring InnerClasses attribute for an anonymous inner class
(com.tencent.tp.h) that doesn’t come with an
associated EnclosingMethod attribute.
可以查看temp临时出包目录出现2个cloudcore.jar
解决:移动到子目录后,右键重导入
变为普通jar包,icon也从拼图变为jar包样式
再build,出包正常,temp目录也只有一个GCloudCore.jar
接入不同sdk版本需求
例如gcloud
● minSdkVersion:>=15
● targetSdkVersion:28
先到本地 Android SDK 目录下,打开sdk manager 下载 android-28。
在菜单栏file->Build Settings中,进入Player Settings,设置Minimum API Level和Target API Level
所有接入sdk,要仔细阅读文档对sdk需求确定
导出AS工程打包调试
stderr[
warning: Ignoring InnerClasses attribute for an anonymous inner class
(com.tencent.tp.h) that doesn’t come with an
associated EnclosingMethod attribute. This class was probably produced by a
compiler that did not target the modern .class file format. The recommended
solution is to recompile the class from source, using an up-to-date compiler
and without specifying any “-target” type options. The consequence of ignoring
this warning is that reflective operations on this class will incorrectly
indicate that it is not an inner class.
有时报这错,一直找到不哪个类被重复打包,只能导出as工程进行调试,会比editor输出更多错误信息
Program type already present : com.xxx.xxxx.BuildConfig
jar包被重复打包,他内部自带了BuildConfig,再打包时又生成了BuildConfig
解决办法:改AndroidMainifest里的包名,然后重新生成