33 个解决方案
#1
android update project -p .
ant debug or ant release
ant debug or ant release
#2
你好我是用build.xml脚本来写的 请问怎么写,能说详细些吗
#3
你可以把项目下的build.xml 删除然后cd你的主项目
然后ant debug或者release
一直这样打包。不知道你怎么操作的
然后ant debug或者release
一直这样打包。不知道你怎么操作的
#4
我们这个必须要用build.xml 因为我的目的是为了解决多渠道号的问题,要一次生成n多个apk。所以你刚才的命令怎么才能转换成脚本呢,还是写脚本的
#5
你看看你的build.xml有没有问题,你先备份下。重新使用系统生成的,如果系统生成的没问题就是你build.xml写的有问题了
生成build.xml不需要脚本,应该是xml写的问题了
生成build.xml不需要脚本,应该是xml写的问题了
#6
系统生成的只有几行脚本,你对ant脚本熟悉吗,网上有人说这样写,你看看
#7
<target name="mk" >
<exec dir="./jni" executable="make" os="Linux" failonerror="true">
</exec>
</target>
<target name="mkclr" >
<exec dir="./jni" executable="make" os="Linux" failonerror="true">
<arg line=" clean" />
</exec>
</target>
可是我加了之后apk中仍然没有libs目录,也许是我配置有问题,那个dir是 so文件的目录吗?
#8
这个脚本是自己写的吧?这个就不清楚了
#9
还有没有哪位大神知道啊,帮帮忙
#10
刚才那个问题解决了,现在又遇到一个问题,就是so打包到apk后,我们自己的so没问题,但是百度地图的so在加载的时候出错了,第三方的jar包 都没问题,可以正常运行,唯独百度地图出错了,你知道什么原因吗?
01-10 14:27:44.983: E/AndroidRuntime(1853): FATAL EXCEPTION: main
01-10 14:27:44.983: E/AndroidRuntime(1853): java.lang.NullPointerException
01-10 14:27:44.983: E/AndroidRuntime(1853): at android.graphics.Canvas.throwIfRecycled(Canvas.java:972)
01-10 14:27:44.983: E/AndroidRuntime(1853): at android.graphics.Canvas.drawBitmap(Canvas.java:998)
01-10 14:27:44.983: E/AndroidRuntime(1853): at com.baidu.mapapi.MyLocationOverlay.drawCompass(Unknown Source)
01-10 14:27:44.983: E/AndroidRuntime(1853): at com.baidu.mapapi.MyLocationOverlay.draw(Unknown Source)
01-10 14:27:44.983: E/AndroidRuntime(1853): at com.baidu.mapapi.a.d(Unknown Source)
01-10 14:27:44.983: E/AndroidRuntime(1853): at com.baidu.mapapi.a.b(Unknown Source)
01-10 14:27:44.983: E/AndroidRuntime(1853): at com.baidu.mapapi.a.onDraw(Unknown Source)
01-10 14:27:44.983: E/AndroidRuntime(1853): at android.view.View.draw(View.java:6970)
01-10 14:27:44.983: E/AndroidRuntime(1853): at android.view.ViewGroup.drawChild(ViewGroup.java:1732)
01-10 14:27:44.983: E/AndroidRuntime(1853): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1459)
01-10 14:27:44.983: E/AndroidRuntime(1853): at android.view.ViewGroup.drawChild(ViewGroup.java:1730)
01-10 14:27:44.983: E/AndroidRuntime(1853): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1459)
01-10 14:27:44.983: E/AndroidRuntime(1853): at android.view.ViewGroup.drawChild(ViewGroup.java:1730)
01-10 14:27:44.983: E/AndroidRuntime(1853): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1459)
01-10 14:27:44.983: E/AndroidRuntime(1853): at android.view.View.draw(View.java:6973)
01-10 14:27:44.983: E/AndroidRuntime(1853): at android.view.ViewGroup.drawChild(ViewGroup.java:1732)
01-10 14:27:44.983: E/AndroidRuntime(1853): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1459)
01-10 14:27:44.983: E/AndroidRuntime(1853): at android.view.View.draw(View.java:6973)
01-10 14:27:44.983: E/AndroidRuntime(1853): at android.view.ViewGroup.drawChild(ViewGroup.java:1732)
01-10 14:27:44.983: E/AndroidRuntime(1853): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1459)
01-10 14:27:44.983: E/AndroidRuntime(1853): at android.view.ViewGroup.drawChild(ViewGroup.java:1730)
01-10 14:27:44.983: E/AndroidRuntime(1853): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1459)
01-10 14:27:44.983: E/AndroidRuntime(1853): at android.view.View.draw(View.java:6973)
01-10 14:27:44.983: E/AndroidRuntime(1853): at android.widget.FrameLayout.draw(FrameLayout.java:357)
01-10 14:27:44.983: E/AndroidRuntime(1853): at android.view.ViewGroup.drawChild(ViewGroup.java:1732)
01-10 14:27:44.983: E/AndroidRuntime(1853): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1459)
01-10 14:27:44.983: E/AndroidRuntime(1853): at android.view.ViewGroup.drawChild(ViewGroup.java:1730)
01-10 14:27:44.983: E/AndroidRuntime(1853): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1459)
01-10 14:27:44.983: E/AndroidRuntime(1853): at android.view.View.draw(View.java:6973)
01-10 14:27:44.983: E/AndroidRuntime(1853): at android.widget.FrameLayout.draw(FrameLayout.java:357)
01-10 14:27:44.983: E/AndroidRuntime(1853): at android.view.ViewGroup.drawChild(ViewGroup.java:1732)
01-10 14:27:44.983: E/AndroidRuntime(1853): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1459)
01-10 14:27:44.983: E/AndroidRuntime(1853): at android.view.ViewGroup.drawChild(ViewGroup.java:1730)
01-10 14:27:44.983: E/AndroidRuntime(1853): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1459)
01-10 14:27:44.983: E/AndroidRuntime(1853): at android.view.View.draw(View.java:6973)
01-10 14:27:44.983: E/AndroidRuntime(1853): at android.widget.FrameLayout.draw(FrameLayout.java:357)
01-10 14:27:44.983: E/AndroidRuntime(1853): at android.view.ViewGroup.drawChild(ViewGroup.java:1732)
01-10 14:27:44.983: E/AndroidRuntime(1853): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1459)
01-10 14:27:44.983: E/AndroidRuntime(1853): at android.view.View.draw(View.java:6973)
01-10 14:27:44.983: E/AndroidRuntime(1853): at android.widget.FrameLayout.draw(FrameLayout.java:357)
01-10 14:27:44.983: E/AndroidRuntime(1853): at android.view.ViewGroup.drawChild(ViewGroup.java:1732)
01-10 14:27:44.983: E/AndroidRuntime(1853): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1459)
01-10 14:27:44.983: E/AndroidRuntime(1853): at android.view.View.draw(View.java:6973)
01-10 14:27:44.983: E/AndroidRuntime(1853): at android.widget.FrameLayout.draw(FrameLayout.java:357)
01-10 14:27:44.983: E/AndroidRuntime(1853): at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:1961)
01-10 14:27:44.983: E/AndroidRuntime(1853): at android.view.ViewRoot.draw(ViewRoot.java:1600)
01-10 14:27:44.983: E/AndroidRuntime(1853): at android.view.ViewRoot.performTraversals(ViewRoot.java:1321)
01-10 14:27:44.983: E/AndroidRuntime(1853): at android.view.ViewRoot.handleMessage(ViewRoot.java:1957)
01-10 14:27:44.983: E/AndroidRuntime(1853): at android.os.Handler.dispatchMessage(Handler.java:99)
01-10 14:27:44.983: E/AndroidRuntime(1853): at android.os.Looper.loop(Looper.java:143)
01-10 14:27:44.983: E/AndroidRuntime(1853): at android.app.ActivityThread.main(ActivityThread.java:4263)
01-10 14:27:44.983: E/AndroidRuntime(1853): at java.lang.reflect.Method.invokeNative(Native Method)
01-10 14:27:44.983: E/AndroidRuntime(1853): at java.lang.reflect.Method.invoke(Method.java:507)
01-10 14:27:44.983: E/AndroidRuntime(1853): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
01-10 14:27:44.983: E/AndroidRuntime(1853): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
01-10 14:27:44.983: E/AndroidRuntime(1853): at dalvik.system.NativeStart.main(Native Method)
01-10 14:32:28.860: E/NetworkLocationProvider(234): releaseCheckLocationLock: wake lock has already been released
01-10 14:32:45.146: E/ActivityManager(120): fail to set top app changed!
#11
at android.graphics.Canvas.throwIfRecycled(Canvas.java:972)
你的位图回收了,然后又要在位图上绘制,看看代码吧
你的位图回收了,然后又要在位图上绘制,看看代码吧
#12
at com.baidu.mapapi.MyLocationOverlay.drawCompass(Unknown Source)
01-10 14:27:44.983: E/AndroidRuntime(1853): at com.baidu.mapapi.MyLocationOverlay.draw(Unknown Source)
01-10 14:27:44.983: E/AndroidRuntime(1853): at com.baidu.mapapi.a.d(Unknown Source)
01-10 14:27:44.983: E/AndroidRuntime(1853): at com.baidu.mapapi.a.b(Unknown Source)
01-10 14:27:44.983: E/AndroidRuntime(1853): at com.baidu.mapapi.a.onDraw(Unknown Source)
百度的jar需要keep你混淆了?
01-10 14:27:44.983: E/AndroidRuntime(1853): at com.baidu.mapapi.MyLocationOverlay.draw(Unknown Source)
01-10 14:27:44.983: E/AndroidRuntime(1853): at com.baidu.mapapi.a.d(Unknown Source)
01-10 14:27:44.983: E/AndroidRuntime(1853): at com.baidu.mapapi.a.b(Unknown Source)
01-10 14:27:44.983: E/AndroidRuntime(1853): at com.baidu.mapapi.a.onDraw(Unknown Source)
百度的jar需要keep你混淆了?
#13
嗯嗯 我再看看代码,百度地图.jar 那个是api本身混淆的。我没有加混淆
#14
问题全部解决:
1.首先打包so的脚本是这样的:
<!-- 打包成未签证的apk -->
<target name="package" depends="dex, package-res-and-assets">
<echo>打包成未签证的apk....</echo>
<exec executable="${apkbuilder}" failonerror="true">
<arg value="${out-unsigned-package-ospath}" />
<arg value="-u" />
<arg value="-z" />
<arg value="${resources-package-ospath}" />
<arg value="-f" />
<arg value="${dex-ospath}" />
<arg value="-rf" />
<arg value="${srcdir-ospath}" />
<!-- 打包*.so文件 -->
<arg line="-nf ${external-lib-ospath}"/>
</exec>
</target>
重点是这句话 <arg line="-nf ${external-lib-ospath}"/>
2.第二个问题是由于百度地图在编译的时候会想apk 的assets目录写入很多小图片,然后我用ant编译的话就不会写入那些图片了。解决方法 从一个eclipse编译的apk中把assets目录下的文件全部复制到工程目录的assets,这样就可以打包到ant 编译的apk了。
ok啦。。。到此结束!
#15
非常感谢你的回复,100分给你了
#16
楼主还是好样的,自己解决了问题出来说下方案,不像某类人自己解决了就隐身了。
不知道楼主的渠道在清单文件里吗?
我是这样做的
如果在清单文件:,ant遍历所有的渠道,然后遍历,这儿类似于多维数组
如果不在清单文件:直接打出未签名包,然后需要解压,修改渠道号,然后按照apk的压缩格式打包,签名
不知道楼主的渠道在清单文件里吗?
我是这样做的
如果在清单文件:,ant遍历所有的渠道,然后遍历,这儿类似于多维数组
如果不在清单文件:直接打出未签名包,然后需要解压,修改渠道号,然后按照apk的压缩格式打包,签名
#17
我是按照这个来做的http://blog.csdn.net/tenggangren/article/details/8051937
#18
我是按照这个来做的 http://blog.csdn.net/tenggangren/article/details/8051937
听你说的应该和我的方法一样,用正则表达式。 我觉得这样应该简单些,而且可以一次生成多个apk,很方便。
#19
对了,你做过ant 混淆吗?我现在又要研究这个,呵呵
#20
ant混淆这部分跟adt没什么两样,你在project 下面 proguard.config=proguard.cfg开启,然后配置下,至于混淆注意的东西可以看下proguard官网,第三方的jar注意keep出来最好是
#21
里面有完整的例子
#22
那个混淆文本我已经有了 ,因为之前adt混淆已经写过了,先就是不知道怎么加进去,对那个脚本不太懂, proguard.config=proguard.cfg 这个脚本具体怎么写,你知道么?
#23
# This is a configuration file for ProGuard.
# http://proguard.sourceforge.net/index.html#manual/usage.html
# Optimizations: If you don't want to optimize, use the
# proguard-android.txt configuration file instead of this one, which
# turns off the optimization flags. Adding optimization introduces
# certain risks, since for example not all optimizations performed by
# ProGuard works on all versions of Dalvik. The following flags turn
# off various optimizations known to have issues, but the list may not
# be complete or up to date. (The "arithmetic" optimization can be
# used if you are only targeting Android 2.0 or later.) Make sure you
# test thoroughly if you go this route.
-optimizations !code/simplification/arithmetic,!code/simplification/cast,!field/*,!class/merging/*
-optimizationpasses 5
-allowaccessmodification
-dontpreverify
# The remainder of this file is identical to the non-optimized version
# of the Proguard configuration file (except that the other file has
# flags to turn off optimization).
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-verbose
-keepattributes *Annotation*
-keep public class com.google.vending.licensing.ILicensingService
-keep public class com.android.vending.licensing.ILicensingService
# For native methods, see http://proguard.sourceforge.net/manual/examples.html#native
-keepclasseswithmembernames class * {
native <methods>;
}
# keep setters in Views so that animations can still work.
# see http://proguard.sourceforge.net/manual/examples.html#beans
-keepclassmembers public class * extends android.view.View {
void set*(***);
*** get*();
}
# We want to keep methods in Activity that could be used in the XML attribute onClick
-keepclassmembers class * extends android.app.Activity {
public void *(android.view.View);
}
# For enumeration classes, see http://proguard.sourceforge.net/manual/examples.html#enumerations
-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}
-keep class * implements android.os.Parcelable {
public static final android.os.Parcelable$Creator *;
}
-keepclassmembers class **.R$* {
public static <fields>;
} 我想说这个keep可以不要
# The support library contains references to newer platform versions.
# Don't warn about those in case this app is linking against an older
# platform version. We know about them, and they are safe.
-dontwarn android.support.**
http://proguard.sourceforge.net/index.html#manual/examples.html
基本就是这样子,具体看你的代码了,第三方的jar一般不需要混淆,反射的,native的统统不能混淆
官方的injar outjar那些可以无视
#24
谢谢你的帮助,我的意思是说 这个混淆文档我已经有了,什么该混淆什么不混淆已经写好了,只是不知道在build.xml怎么去调用。这个你知道么?
#25
这个倒是没改过,默认的build文件你在工程下 proguard.config=proguard.cfg开启会自动支持的,,你那份修改的build我不会了
你在 sdk下的build.xml搜索下 proguard 在obfuscate标签处,还有一堆东西,自己研究下吧,看着头晕
你在 sdk下的build.xml搜索下 proguard 在obfuscate标签处,还有一堆东西,自己研究下吧,看着头晕
#26
嗯嗯 我再看看,谢谢你了
#27
第三方jar包中的资源文件怎么打进去啊,,,我的一直打不进去。。调用第三方jar包的方法的时候就说资源找不到。。。
#28
楼主在吗。。 我也遇到了同样的问题,按照你说把assets目录下的所有文件都拷贝至 工程的 assets 文件夹里面去了。。但是 百度地图 还是用不鸟。。一点就崩溃。。
打包的时候没有报错,但是一大堆的警告,关于百度地图的。。楼主遇到过吗??
我摘抄一小段。。麻烦看到帮忙分析一下。。弄了好久了,都没解决。。之前一个用高德地图的,用楼主你的办法解决了。
但是这次百度地图 怎么就不行呢?是这个百度地图的jar包 baidumapapi_v2_1_3.jar
打包的时候没有报错,但是一大堆的警告,关于百度地图的。。楼主遇到过吗??
我摘抄一小段。。麻烦看到帮忙分析一下。。弄了好久了,都没解决。。之前一个用高德地图的,用楼主你的办法解决了。
但是这次百度地图 怎么就不行呢?是这个百度地图的jar包 baidumapapi_v2_1_3.jar
[apply] warning: Ignoring InnerClasses attribute for an anonymous inner class
[apply] (com.baidu.location.g$1) that doesn't come with an
[apply] associated EnclosingMethod attribute. This class was probably produced by a
[apply] compiler that did not target the modern .class file format. The recommended
[apply] solution is to recompile the class from source, using an up-to-date compiler
[apply] and without specifying any "-target" type options. The consequence of ignoring
[apply] this warning is that reflective operations on this class will incorrectly
[apply] indicate that it is *not* an inner class.
[apply] warning: Ignoring InnerClasses attribute for an anonymous inner class
[apply] (com.baidu.location.g$2) that doesn't come with an
[apply] associated EnclosingMethod attribute. This class was probably produced by a
[apply] compiler that did not target the modern .class file format. The recommended
[apply] solution is to recompile the class from source, using an up-to-date compiler
[apply] and without specifying any "-target" type options. The consequence of ignoring
[apply] this warning is that reflective operations on this class will incorrectly
[apply] indicate that it is *not* an inner class.
#29
这个问题怎么解决的 能够告知下 谢谢
#30
我也来麻烦楼主了,我最近我在研究ant打包,我的也许暂时没有楼上几位的复杂,我暂不用多渠道打包。。。好了正题:我的是用楼上所说的我是用命令自动生成的build.xml,我打包简单的项目是没有问题的,但是我的项目中又引用了另一个项目,另一个项目中又用到了jni技术,jni中有生成的.so文件,我单独的打主项目是没有问题,主项目引用另一个项目时,就不可以,可以打包,但是运行不了。。楼主有遇到过么?
#31
还有楼主个人得我应该是没有将.so文件打包进去,我就按照你所说的加了这个
<!-- 打包成未签证的apk -->
<target name="package" depends="dex, package-res-and-assets">
<echo>打包成未签证的apk....</echo>
<exec executable="${apkbuilder}" failonerror="true">
<arg value="${out-unsigned-package-ospath}" />
<arg value="-u" />
<arg value="-z" />
<arg value="${resources-package-ospath}" />
<arg value="-f" />
<arg value="${dex-ospath}" />
<arg value="-rf" />
<arg value="${srcdir-ospath}" />
<!-- 打包*.so文件 -->
<arg line="-nf ${external-lib-ospath}"/>
</exec>
</target>
加了这个就报错
BUILD FAILED
Target "dex" does not exist in the project "Mobile_Net_Credit". It is used from target "package".
以下的是我写的:
Total time: 603 milliseconds
<?xml version="1.0" encoding="UTF-8"?>
<project name="Mobile_Net_Credit" default="help">
<!-- 打包成未签证的apk -->
<target name="Mobile_Net_Credit" depends="dex, package-res-and-assets">
<echo>打包成未签证的apk....</echo>
<exec executable="${apkbuilder}" failonerror="true">
<arg value="${out-unsigned-package-ospath}" />
<arg value="-u" />
<arg value="-z" />
<arg value="${resources-package-ospath}" />
<arg value="-f" />
<arg value="${dex-ospath}" />
<arg value="-rf" />
<arg value="${srcdir-ospath}" />
<!-- 打包*.so文件 -->
<arg line="-nf ${external-lib-ospath}"/>
</exec>
</target> 也报错,我知道name报错,可是我不是很明白这段话,请楼主帮帮忙吧!
<!-- 打包成未签证的apk -->
<target name="package" depends="dex, package-res-and-assets">
<echo>打包成未签证的apk....</echo>
<exec executable="${apkbuilder}" failonerror="true">
<arg value="${out-unsigned-package-ospath}" />
<arg value="-u" />
<arg value="-z" />
<arg value="${resources-package-ospath}" />
<arg value="-f" />
<arg value="${dex-ospath}" />
<arg value="-rf" />
<arg value="${srcdir-ospath}" />
<!-- 打包*.so文件 -->
<arg line="-nf ${external-lib-ospath}"/>
</exec>
</target>
加了这个就报错
BUILD FAILED
Target "dex" does not exist in the project "Mobile_Net_Credit". It is used from target "package".
以下的是我写的:
Total time: 603 milliseconds
<?xml version="1.0" encoding="UTF-8"?>
<project name="Mobile_Net_Credit" default="help">
<!-- 打包成未签证的apk -->
<target name="Mobile_Net_Credit" depends="dex, package-res-and-assets">
<echo>打包成未签证的apk....</echo>
<exec executable="${apkbuilder}" failonerror="true">
<arg value="${out-unsigned-package-ospath}" />
<arg value="-u" />
<arg value="-z" />
<arg value="${resources-package-ospath}" />
<arg value="-f" />
<arg value="${dex-ospath}" />
<arg value="-rf" />
<arg value="${srcdir-ospath}" />
<!-- 打包*.so文件 -->
<arg line="-nf ${external-lib-ospath}"/>
</exec>
</target> 也报错,我知道name报错,可是我不是很明白这段话,请楼主帮帮忙吧!
#32
<target name="Mobile_Net_Credit" depends="dex, package-res-and-assets"> 意思好像是这个句里的name=“package”
#33
楼主,加我Q吧!我真心请你帮助!QQ:342329654 谢谢!一切尽在不言中。。。。。。。。
#1
android update project -p .
ant debug or ant release
ant debug or ant release
#2
你好我是用build.xml脚本来写的 请问怎么写,能说详细些吗
#3
你可以把项目下的build.xml 删除然后cd你的主项目
然后ant debug或者release
一直这样打包。不知道你怎么操作的
然后ant debug或者release
一直这样打包。不知道你怎么操作的
#4
我们这个必须要用build.xml 因为我的目的是为了解决多渠道号的问题,要一次生成n多个apk。所以你刚才的命令怎么才能转换成脚本呢,还是写脚本的
#5
你看看你的build.xml有没有问题,你先备份下。重新使用系统生成的,如果系统生成的没问题就是你build.xml写的有问题了
生成build.xml不需要脚本,应该是xml写的问题了
生成build.xml不需要脚本,应该是xml写的问题了
#6
系统生成的只有几行脚本,你对ant脚本熟悉吗,网上有人说这样写,你看看
#7
<target name="mk" >
<exec dir="./jni" executable="make" os="Linux" failonerror="true">
</exec>
</target>
<target name="mkclr" >
<exec dir="./jni" executable="make" os="Linux" failonerror="true">
<arg line=" clean" />
</exec>
</target>
可是我加了之后apk中仍然没有libs目录,也许是我配置有问题,那个dir是 so文件的目录吗?
#8
这个脚本是自己写的吧?这个就不清楚了
#9
还有没有哪位大神知道啊,帮帮忙
#10
刚才那个问题解决了,现在又遇到一个问题,就是so打包到apk后,我们自己的so没问题,但是百度地图的so在加载的时候出错了,第三方的jar包 都没问题,可以正常运行,唯独百度地图出错了,你知道什么原因吗?
01-10 14:27:44.983: E/AndroidRuntime(1853): FATAL EXCEPTION: main
01-10 14:27:44.983: E/AndroidRuntime(1853): java.lang.NullPointerException
01-10 14:27:44.983: E/AndroidRuntime(1853): at android.graphics.Canvas.throwIfRecycled(Canvas.java:972)
01-10 14:27:44.983: E/AndroidRuntime(1853): at android.graphics.Canvas.drawBitmap(Canvas.java:998)
01-10 14:27:44.983: E/AndroidRuntime(1853): at com.baidu.mapapi.MyLocationOverlay.drawCompass(Unknown Source)
01-10 14:27:44.983: E/AndroidRuntime(1853): at com.baidu.mapapi.MyLocationOverlay.draw(Unknown Source)
01-10 14:27:44.983: E/AndroidRuntime(1853): at com.baidu.mapapi.a.d(Unknown Source)
01-10 14:27:44.983: E/AndroidRuntime(1853): at com.baidu.mapapi.a.b(Unknown Source)
01-10 14:27:44.983: E/AndroidRuntime(1853): at com.baidu.mapapi.a.onDraw(Unknown Source)
01-10 14:27:44.983: E/AndroidRuntime(1853): at android.view.View.draw(View.java:6970)
01-10 14:27:44.983: E/AndroidRuntime(1853): at android.view.ViewGroup.drawChild(ViewGroup.java:1732)
01-10 14:27:44.983: E/AndroidRuntime(1853): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1459)
01-10 14:27:44.983: E/AndroidRuntime(1853): at android.view.ViewGroup.drawChild(ViewGroup.java:1730)
01-10 14:27:44.983: E/AndroidRuntime(1853): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1459)
01-10 14:27:44.983: E/AndroidRuntime(1853): at android.view.ViewGroup.drawChild(ViewGroup.java:1730)
01-10 14:27:44.983: E/AndroidRuntime(1853): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1459)
01-10 14:27:44.983: E/AndroidRuntime(1853): at android.view.View.draw(View.java:6973)
01-10 14:27:44.983: E/AndroidRuntime(1853): at android.view.ViewGroup.drawChild(ViewGroup.java:1732)
01-10 14:27:44.983: E/AndroidRuntime(1853): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1459)
01-10 14:27:44.983: E/AndroidRuntime(1853): at android.view.View.draw(View.java:6973)
01-10 14:27:44.983: E/AndroidRuntime(1853): at android.view.ViewGroup.drawChild(ViewGroup.java:1732)
01-10 14:27:44.983: E/AndroidRuntime(1853): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1459)
01-10 14:27:44.983: E/AndroidRuntime(1853): at android.view.ViewGroup.drawChild(ViewGroup.java:1730)
01-10 14:27:44.983: E/AndroidRuntime(1853): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1459)
01-10 14:27:44.983: E/AndroidRuntime(1853): at android.view.View.draw(View.java:6973)
01-10 14:27:44.983: E/AndroidRuntime(1853): at android.widget.FrameLayout.draw(FrameLayout.java:357)
01-10 14:27:44.983: E/AndroidRuntime(1853): at android.view.ViewGroup.drawChild(ViewGroup.java:1732)
01-10 14:27:44.983: E/AndroidRuntime(1853): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1459)
01-10 14:27:44.983: E/AndroidRuntime(1853): at android.view.ViewGroup.drawChild(ViewGroup.java:1730)
01-10 14:27:44.983: E/AndroidRuntime(1853): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1459)
01-10 14:27:44.983: E/AndroidRuntime(1853): at android.view.View.draw(View.java:6973)
01-10 14:27:44.983: E/AndroidRuntime(1853): at android.widget.FrameLayout.draw(FrameLayout.java:357)
01-10 14:27:44.983: E/AndroidRuntime(1853): at android.view.ViewGroup.drawChild(ViewGroup.java:1732)
01-10 14:27:44.983: E/AndroidRuntime(1853): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1459)
01-10 14:27:44.983: E/AndroidRuntime(1853): at android.view.ViewGroup.drawChild(ViewGroup.java:1730)
01-10 14:27:44.983: E/AndroidRuntime(1853): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1459)
01-10 14:27:44.983: E/AndroidRuntime(1853): at android.view.View.draw(View.java:6973)
01-10 14:27:44.983: E/AndroidRuntime(1853): at android.widget.FrameLayout.draw(FrameLayout.java:357)
01-10 14:27:44.983: E/AndroidRuntime(1853): at android.view.ViewGroup.drawChild(ViewGroup.java:1732)
01-10 14:27:44.983: E/AndroidRuntime(1853): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1459)
01-10 14:27:44.983: E/AndroidRuntime(1853): at android.view.View.draw(View.java:6973)
01-10 14:27:44.983: E/AndroidRuntime(1853): at android.widget.FrameLayout.draw(FrameLayout.java:357)
01-10 14:27:44.983: E/AndroidRuntime(1853): at android.view.ViewGroup.drawChild(ViewGroup.java:1732)
01-10 14:27:44.983: E/AndroidRuntime(1853): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1459)
01-10 14:27:44.983: E/AndroidRuntime(1853): at android.view.View.draw(View.java:6973)
01-10 14:27:44.983: E/AndroidRuntime(1853): at android.widget.FrameLayout.draw(FrameLayout.java:357)
01-10 14:27:44.983: E/AndroidRuntime(1853): at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:1961)
01-10 14:27:44.983: E/AndroidRuntime(1853): at android.view.ViewRoot.draw(ViewRoot.java:1600)
01-10 14:27:44.983: E/AndroidRuntime(1853): at android.view.ViewRoot.performTraversals(ViewRoot.java:1321)
01-10 14:27:44.983: E/AndroidRuntime(1853): at android.view.ViewRoot.handleMessage(ViewRoot.java:1957)
01-10 14:27:44.983: E/AndroidRuntime(1853): at android.os.Handler.dispatchMessage(Handler.java:99)
01-10 14:27:44.983: E/AndroidRuntime(1853): at android.os.Looper.loop(Looper.java:143)
01-10 14:27:44.983: E/AndroidRuntime(1853): at android.app.ActivityThread.main(ActivityThread.java:4263)
01-10 14:27:44.983: E/AndroidRuntime(1853): at java.lang.reflect.Method.invokeNative(Native Method)
01-10 14:27:44.983: E/AndroidRuntime(1853): at java.lang.reflect.Method.invoke(Method.java:507)
01-10 14:27:44.983: E/AndroidRuntime(1853): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
01-10 14:27:44.983: E/AndroidRuntime(1853): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
01-10 14:27:44.983: E/AndroidRuntime(1853): at dalvik.system.NativeStart.main(Native Method)
01-10 14:32:28.860: E/NetworkLocationProvider(234): releaseCheckLocationLock: wake lock has already been released
01-10 14:32:45.146: E/ActivityManager(120): fail to set top app changed!
#11
at android.graphics.Canvas.throwIfRecycled(Canvas.java:972)
你的位图回收了,然后又要在位图上绘制,看看代码吧
你的位图回收了,然后又要在位图上绘制,看看代码吧
#12
at com.baidu.mapapi.MyLocationOverlay.drawCompass(Unknown Source)
01-10 14:27:44.983: E/AndroidRuntime(1853): at com.baidu.mapapi.MyLocationOverlay.draw(Unknown Source)
01-10 14:27:44.983: E/AndroidRuntime(1853): at com.baidu.mapapi.a.d(Unknown Source)
01-10 14:27:44.983: E/AndroidRuntime(1853): at com.baidu.mapapi.a.b(Unknown Source)
01-10 14:27:44.983: E/AndroidRuntime(1853): at com.baidu.mapapi.a.onDraw(Unknown Source)
百度的jar需要keep你混淆了?
01-10 14:27:44.983: E/AndroidRuntime(1853): at com.baidu.mapapi.MyLocationOverlay.draw(Unknown Source)
01-10 14:27:44.983: E/AndroidRuntime(1853): at com.baidu.mapapi.a.d(Unknown Source)
01-10 14:27:44.983: E/AndroidRuntime(1853): at com.baidu.mapapi.a.b(Unknown Source)
01-10 14:27:44.983: E/AndroidRuntime(1853): at com.baidu.mapapi.a.onDraw(Unknown Source)
百度的jar需要keep你混淆了?
#13
嗯嗯 我再看看代码,百度地图.jar 那个是api本身混淆的。我没有加混淆
#14
问题全部解决:
1.首先打包so的脚本是这样的:
<!-- 打包成未签证的apk -->
<target name="package" depends="dex, package-res-and-assets">
<echo>打包成未签证的apk....</echo>
<exec executable="${apkbuilder}" failonerror="true">
<arg value="${out-unsigned-package-ospath}" />
<arg value="-u" />
<arg value="-z" />
<arg value="${resources-package-ospath}" />
<arg value="-f" />
<arg value="${dex-ospath}" />
<arg value="-rf" />
<arg value="${srcdir-ospath}" />
<!-- 打包*.so文件 -->
<arg line="-nf ${external-lib-ospath}"/>
</exec>
</target>
重点是这句话 <arg line="-nf ${external-lib-ospath}"/>
2.第二个问题是由于百度地图在编译的时候会想apk 的assets目录写入很多小图片,然后我用ant编译的话就不会写入那些图片了。解决方法 从一个eclipse编译的apk中把assets目录下的文件全部复制到工程目录的assets,这样就可以打包到ant 编译的apk了。
ok啦。。。到此结束!
#15
非常感谢你的回复,100分给你了
#16
楼主还是好样的,自己解决了问题出来说下方案,不像某类人自己解决了就隐身了。
不知道楼主的渠道在清单文件里吗?
我是这样做的
如果在清单文件:,ant遍历所有的渠道,然后遍历,这儿类似于多维数组
如果不在清单文件:直接打出未签名包,然后需要解压,修改渠道号,然后按照apk的压缩格式打包,签名
不知道楼主的渠道在清单文件里吗?
我是这样做的
如果在清单文件:,ant遍历所有的渠道,然后遍历,这儿类似于多维数组
如果不在清单文件:直接打出未签名包,然后需要解压,修改渠道号,然后按照apk的压缩格式打包,签名
#17
我是按照这个来做的http://blog.csdn.net/tenggangren/article/details/8051937
#18
我是按照这个来做的 http://blog.csdn.net/tenggangren/article/details/8051937
听你说的应该和我的方法一样,用正则表达式。 我觉得这样应该简单些,而且可以一次生成多个apk,很方便。
#19
对了,你做过ant 混淆吗?我现在又要研究这个,呵呵
#20
ant混淆这部分跟adt没什么两样,你在project 下面 proguard.config=proguard.cfg开启,然后配置下,至于混淆注意的东西可以看下proguard官网,第三方的jar注意keep出来最好是
#21
里面有完整的例子
#22
那个混淆文本我已经有了 ,因为之前adt混淆已经写过了,先就是不知道怎么加进去,对那个脚本不太懂, proguard.config=proguard.cfg 这个脚本具体怎么写,你知道么?
#23
# This is a configuration file for ProGuard.
# http://proguard.sourceforge.net/index.html#manual/usage.html
# Optimizations: If you don't want to optimize, use the
# proguard-android.txt configuration file instead of this one, which
# turns off the optimization flags. Adding optimization introduces
# certain risks, since for example not all optimizations performed by
# ProGuard works on all versions of Dalvik. The following flags turn
# off various optimizations known to have issues, but the list may not
# be complete or up to date. (The "arithmetic" optimization can be
# used if you are only targeting Android 2.0 or later.) Make sure you
# test thoroughly if you go this route.
-optimizations !code/simplification/arithmetic,!code/simplification/cast,!field/*,!class/merging/*
-optimizationpasses 5
-allowaccessmodification
-dontpreverify
# The remainder of this file is identical to the non-optimized version
# of the Proguard configuration file (except that the other file has
# flags to turn off optimization).
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-verbose
-keepattributes *Annotation*
-keep public class com.google.vending.licensing.ILicensingService
-keep public class com.android.vending.licensing.ILicensingService
# For native methods, see http://proguard.sourceforge.net/manual/examples.html#native
-keepclasseswithmembernames class * {
native <methods>;
}
# keep setters in Views so that animations can still work.
# see http://proguard.sourceforge.net/manual/examples.html#beans
-keepclassmembers public class * extends android.view.View {
void set*(***);
*** get*();
}
# We want to keep methods in Activity that could be used in the XML attribute onClick
-keepclassmembers class * extends android.app.Activity {
public void *(android.view.View);
}
# For enumeration classes, see http://proguard.sourceforge.net/manual/examples.html#enumerations
-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}
-keep class * implements android.os.Parcelable {
public static final android.os.Parcelable$Creator *;
}
-keepclassmembers class **.R$* {
public static <fields>;
} 我想说这个keep可以不要
# The support library contains references to newer platform versions.
# Don't warn about those in case this app is linking against an older
# platform version. We know about them, and they are safe.
-dontwarn android.support.**
http://proguard.sourceforge.net/index.html#manual/examples.html
基本就是这样子,具体看你的代码了,第三方的jar一般不需要混淆,反射的,native的统统不能混淆
官方的injar outjar那些可以无视
#24
谢谢你的帮助,我的意思是说 这个混淆文档我已经有了,什么该混淆什么不混淆已经写好了,只是不知道在build.xml怎么去调用。这个你知道么?
#25
这个倒是没改过,默认的build文件你在工程下 proguard.config=proguard.cfg开启会自动支持的,,你那份修改的build我不会了
你在 sdk下的build.xml搜索下 proguard 在obfuscate标签处,还有一堆东西,自己研究下吧,看着头晕
你在 sdk下的build.xml搜索下 proguard 在obfuscate标签处,还有一堆东西,自己研究下吧,看着头晕
#26
嗯嗯 我再看看,谢谢你了
#27
第三方jar包中的资源文件怎么打进去啊,,,我的一直打不进去。。调用第三方jar包的方法的时候就说资源找不到。。。
#28
楼主在吗。。 我也遇到了同样的问题,按照你说把assets目录下的所有文件都拷贝至 工程的 assets 文件夹里面去了。。但是 百度地图 还是用不鸟。。一点就崩溃。。
打包的时候没有报错,但是一大堆的警告,关于百度地图的。。楼主遇到过吗??
我摘抄一小段。。麻烦看到帮忙分析一下。。弄了好久了,都没解决。。之前一个用高德地图的,用楼主你的办法解决了。
但是这次百度地图 怎么就不行呢?是这个百度地图的jar包 baidumapapi_v2_1_3.jar
打包的时候没有报错,但是一大堆的警告,关于百度地图的。。楼主遇到过吗??
我摘抄一小段。。麻烦看到帮忙分析一下。。弄了好久了,都没解决。。之前一个用高德地图的,用楼主你的办法解决了。
但是这次百度地图 怎么就不行呢?是这个百度地图的jar包 baidumapapi_v2_1_3.jar
[apply] warning: Ignoring InnerClasses attribute for an anonymous inner class
[apply] (com.baidu.location.g$1) that doesn't come with an
[apply] associated EnclosingMethod attribute. This class was probably produced by a
[apply] compiler that did not target the modern .class file format. The recommended
[apply] solution is to recompile the class from source, using an up-to-date compiler
[apply] and without specifying any "-target" type options. The consequence of ignoring
[apply] this warning is that reflective operations on this class will incorrectly
[apply] indicate that it is *not* an inner class.
[apply] warning: Ignoring InnerClasses attribute for an anonymous inner class
[apply] (com.baidu.location.g$2) that doesn't come with an
[apply] associated EnclosingMethod attribute. This class was probably produced by a
[apply] compiler that did not target the modern .class file format. The recommended
[apply] solution is to recompile the class from source, using an up-to-date compiler
[apply] and without specifying any "-target" type options. The consequence of ignoring
[apply] this warning is that reflective operations on this class will incorrectly
[apply] indicate that it is *not* an inner class.
#29
这个问题怎么解决的 能够告知下 谢谢
#30
我也来麻烦楼主了,我最近我在研究ant打包,我的也许暂时没有楼上几位的复杂,我暂不用多渠道打包。。。好了正题:我的是用楼上所说的我是用命令自动生成的build.xml,我打包简单的项目是没有问题的,但是我的项目中又引用了另一个项目,另一个项目中又用到了jni技术,jni中有生成的.so文件,我单独的打主项目是没有问题,主项目引用另一个项目时,就不可以,可以打包,但是运行不了。。楼主有遇到过么?
#31
还有楼主个人得我应该是没有将.so文件打包进去,我就按照你所说的加了这个
<!-- 打包成未签证的apk -->
<target name="package" depends="dex, package-res-and-assets">
<echo>打包成未签证的apk....</echo>
<exec executable="${apkbuilder}" failonerror="true">
<arg value="${out-unsigned-package-ospath}" />
<arg value="-u" />
<arg value="-z" />
<arg value="${resources-package-ospath}" />
<arg value="-f" />
<arg value="${dex-ospath}" />
<arg value="-rf" />
<arg value="${srcdir-ospath}" />
<!-- 打包*.so文件 -->
<arg line="-nf ${external-lib-ospath}"/>
</exec>
</target>
加了这个就报错
BUILD FAILED
Target "dex" does not exist in the project "Mobile_Net_Credit". It is used from target "package".
以下的是我写的:
Total time: 603 milliseconds
<?xml version="1.0" encoding="UTF-8"?>
<project name="Mobile_Net_Credit" default="help">
<!-- 打包成未签证的apk -->
<target name="Mobile_Net_Credit" depends="dex, package-res-and-assets">
<echo>打包成未签证的apk....</echo>
<exec executable="${apkbuilder}" failonerror="true">
<arg value="${out-unsigned-package-ospath}" />
<arg value="-u" />
<arg value="-z" />
<arg value="${resources-package-ospath}" />
<arg value="-f" />
<arg value="${dex-ospath}" />
<arg value="-rf" />
<arg value="${srcdir-ospath}" />
<!-- 打包*.so文件 -->
<arg line="-nf ${external-lib-ospath}"/>
</exec>
</target> 也报错,我知道name报错,可是我不是很明白这段话,请楼主帮帮忙吧!
<!-- 打包成未签证的apk -->
<target name="package" depends="dex, package-res-and-assets">
<echo>打包成未签证的apk....</echo>
<exec executable="${apkbuilder}" failonerror="true">
<arg value="${out-unsigned-package-ospath}" />
<arg value="-u" />
<arg value="-z" />
<arg value="${resources-package-ospath}" />
<arg value="-f" />
<arg value="${dex-ospath}" />
<arg value="-rf" />
<arg value="${srcdir-ospath}" />
<!-- 打包*.so文件 -->
<arg line="-nf ${external-lib-ospath}"/>
</exec>
</target>
加了这个就报错
BUILD FAILED
Target "dex" does not exist in the project "Mobile_Net_Credit". It is used from target "package".
以下的是我写的:
Total time: 603 milliseconds
<?xml version="1.0" encoding="UTF-8"?>
<project name="Mobile_Net_Credit" default="help">
<!-- 打包成未签证的apk -->
<target name="Mobile_Net_Credit" depends="dex, package-res-and-assets">
<echo>打包成未签证的apk....</echo>
<exec executable="${apkbuilder}" failonerror="true">
<arg value="${out-unsigned-package-ospath}" />
<arg value="-u" />
<arg value="-z" />
<arg value="${resources-package-ospath}" />
<arg value="-f" />
<arg value="${dex-ospath}" />
<arg value="-rf" />
<arg value="${srcdir-ospath}" />
<!-- 打包*.so文件 -->
<arg line="-nf ${external-lib-ospath}"/>
</exec>
</target> 也报错,我知道name报错,可是我不是很明白这段话,请楼主帮帮忙吧!
#32
<target name="Mobile_Net_Credit" depends="dex, package-res-and-assets"> 意思好像是这个句里的name=“package”
#33
楼主,加我Q吧!我真心请你帮助!QQ:342329654 谢谢!一切尽在不言中。。。。。。。。