2013年9月24日星期二

ant packaged android engineering problems

By ant packaged android project , other issues are resolved , that is my project has JNI, standard apk in the root directory has a libs folder , which put the so file, but I can not be so to break into , That has not even my generation apk libs directory , solving ah , ant how packaged jni. Neighborhoods ah ! !
------ Solution - -------------------------------------------
android update project-p.
ant debug or ant release
------ For reference only ------------------------- --------------


Hello I am using the build.xml script to write to ask how to write , you can say some details
------ For reference only --------- ------------------------------
you can delete the project 's build.xml under your main project then cd
then ant debug or release
been so packed . You do not know how to operate
------ For reference only -------------------------------- -------

we must use this build.xml because my purpose is to solve the problem of multi-channel number to more than one generation n apk. So how can you just converted into a command script , or is it to write the script
------ For reference only ---------------------- -----------------
you look at your build.xml have no problem, you first back up the next . Re- use system-generated , if the system generates no problem is that you have a problem write build.xml
generated build.xml does not require script should be written in xml problem
------ For reference only ------------------- --------------------

system generates only a few lines of script , you ant script familiar to you , the Internet was said to write , you see look
------ For reference only ------------------------------------- -
<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> 



But after I added apk is still no libs directory , maybe I configuration problems , so that dir is the directory where the file do ?
------ For reference only -------------------------------------- -
this script is written in their own right ? This is not clear
------ For reference only --------------------------------- ------
Does any god knows ah , help out
------ For reference only ------------------ ---------------------

just that issue is resolved, and now encounter a problem, that is so packed into apk after ourselves the so no problem, but Baidu map so wrong at load time , third-party jar package no problem , you can run , except Baidu map wrong, you know why?

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!

------ For reference only ----------------------------------- ----
at android.graphics.Canvas.throwIfRecycled (Canvas.java: 972)
recycle your bitmap , and then draw on the bitmap again , look at the code it
------ For reference only -------------- -------------------------
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.ad (Unknown Source)
01-10 14:27:44.983: E / AndroidRuntime (1853): at com.baidu.mapapi.ab (Unknown Source)
01-10 14:27:44.983: E / AndroidRuntime (1853): at com.baidu.mapapi.a.onDraw (Unknown Source)
Baidu 's jar need keep you confused ?
------ For reference only -------------------------------------- -
huh I look at the code , Baidu map . jar api itself that is confusing . I have not confuse
------ For reference only ---------------------------------- -----



solve all the problems :
1. Firstly packaged so the script is this:
 <!-- 打包成未签证的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>  


focus is this sentence


2. The second problem is due to Baidu map at compile time apk 's assets will want to write a lot of small images directory , and then I compile with ant , then it does not write those pictures. Workaround apk compiled from an eclipse in the assets directory copy all files to the project directory of assets, so that you can pack into the ant compile the apk .
ok friends. . . This is the end !
------ For reference only -------------------------------------- -

Thank you for your reply , give you 100 points
------ For reference only ---------------------------------------
landlord or the good kind, own solved the problem out that under the scheme , unlike certain people own solution on stealth .
landlord does not know where you channel in the manifest file ?
I was doing
If the manifest file :, ant through all channels , then traverse , here is similar to multidimensional arrays
If you do not manifest file : direct hit unsigned package, and then need to extract , modify, channel number, and then follow the apk package compression format , signatures
------ For reference only ---------------------------------------
I was to do in accordance with this http://blog.csdn.net/tenggangren/article/details/8051937
------ For reference only --------------------- ------------------

I have to do is follow this http://blog.csdn.net/tenggangren/article/details/8051937
listen to you and I should say the same way , using regular expressions. I think this should be simpler , and can generate multiple time apk, very convenient.
------ For reference only -------------------------------------- -

Yes, you did ant confuse you ? I now have to study this , huh
------ For reference only ------------------------------ ---------
ant confuse this part with adt no different , in your project below proguard.config = proguard.cfg open and configuration, as things can be confusing note facie proguard official website , third-party jar is best to pay attention to keep out
------ For reference only -------------------------- -------------

which has a complete example
------ For reference only ------------- --------------------------

confusing text that I already have , as has been written before adt confusion , first just do not know how to be added, for that script do not understand , proguard.config = proguard.cfg specifically how to write the script , you know what ?
------ For reference only -------------------------------------- -
# 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

basically is like this, you see the specific code , third-party jar generally do not need confusion , reflection , native of all can not be confused
official injar outjar who can ignore
------ For reference only -------------------------- -------------

Thank you for your help, I mean I've got this confused with the document , not to be confused what to confuse what has been written well, just do not know how to call in the build.xml . This you know what ?
------ For reference only -------------------------------------- -
this actually did not turn over , the default build file you are in the works to proguard.config = proguard.cfg open automatically supported , you modify the build I will not share the
sdk the build.xml you search for the next proguard obfuscate label in place , there are a bunch of things , their study under the bar , watching the dizziness
------ For reference only ---------------------------------------

huh I see , thank you
------ For reference only ---------------------------- -----------
third-party jar package resource file how to break into ah, I have not get through . . The method of calling party jar package when said resource not found. . .

没有评论:

发表评论