I am getting the following error while obfuscating my application.
How can i define the output jar in my build.xml?
[java] Shrinking...
[java] java.io.IOException: The output jar is empty. Did you specify the proper '-keep' options?
[java] at proguard.shrink.Shrinker.execute(Shrinker.java:148)
[java] at proguard.ProGuard.shrink(ProGuard.java:294)
[java] at proguard.ProGuard.execute(ProGuard.java:100)
[java] at proguard.ProGuard.main(ProGuard.java:499)
Use Android SDK Tools revision 8 or later
If you do not have build.xml for your project, run command like this in some empty directory
android create project --name <Your Project Name> --package <Your Company Name> --target 7 --path . --activity dummy Find build.xml which you can copy to root directory of the project.
In default.properties add reference to proguard settings (proguard.config=proguard.cfg)
Turn off android:debuggable in application manifest.
Run 'ant release' command
You should find directory called ./bin/proguard and ./bin/-release.apk. You can find more details here.
The tutorial here has never gone wrong for me.
Related
As you can see from the project below, I want to know how to generate the java file in the gen folder:
Create R.java
In order for the application source code to be able to access the resources within the res/ directory, a class called R.java (for Resources) is created.
Use the Android Asset Packaging Tool (aapt) to create the R.java file:
ANDROID_HOME/platform-tools/aapt
package
-v
-f
-m
-S DEV_HOME/res
-J DEV_HOME/src
-M DEV_HOME/AndroidManifest.xml
-I ANDROID_HOME/platforms/android-7/android.jar
Building Android programs on the command line
I'm trying to build an apk file from command line. I created a sample project usng the following command:
android create project --target 1 --name MyApp --path ./MyProject --activity MyActivity --package com.example.myapp
Which created the following structure:
/bin
/res
/src
/libs
AndroidManifest.xml
ant.properties
build.xml
local.properties
proguard-project.txt
project.properties
Now when I try to build the project, I get:
$ gradle build
gradle will not execute and completion _gradle exists.
I couldn't find any info on this error, so I ran:
$ _gradle build
_arguments:comparguments:312: can only be called from completion function
user has logged on pts/7 from :0.0.
Any hints on what am I doing wrong? Thanks!
android create project creates project in structure expected by Eclipse, not gradle based (Android Studio) projects.
I was able to build the apk using the following lines:
ant debug
adb install bin/HelloWorld-debug.apk
I am new to ant and Android uiautomator. When using ant to build my testing program I get:
-dex:
[dex] input: c:\Eclipse\workspace\Android\bin\classes
[dex] Converting compiled files and external libraries into c:\Eclipse\wor
kspace\Android\bin\classes.dex...
[dx] no classfiles specified
BUILD FAILED
C:\Android\sdk\tools\ant\uibuild.xml:198: null returned: 1
This is on the sample test code at: http://developer.android.com/tools/testing/testing_ui.html#sample
The full output from running the 'android create uitest...' and 'ant build' commands follows:
c:\Eclipse\workspace\Android>android create uitest-project -n AllAppsTest -t 7 -
p C:\Eclipse\workspace\Android\
Updated file C:\Eclipse\workspace\Android\build.xml
c:\Eclipse\workspace\Android>ant build
Buildfile: c:\Eclipse\workspace\Android\build.xml
-check-env:
[checkenv] Android SDK Tools Revision 23.0.2
[checkenv] Installed at C:\Android\sdk
-build-setup:
[getbuildtools] Using latest Build Tools: 19.1.0
[echo] Resolving Build Target for AllAppsTest...
[getuitarget] Project Target: Android 4.2.2
[getuitarget] API level: 17
[echo] ----------
[echo] Creating output directories if needed...
-pre-compile:
compile:
-post-compile:
-dex:
[dex] input: c:\Eclipse\workspace\Android\bin\classes
[dex] Converting compiled files and external libraries into c:\Eclipse\wor
kspace\Android\bin\classes.dex...
[dx] no classfiles specified
BUILD FAILED
C:\Android\sdk\tools\ant\uibuild.xml:198: null returned: 1
Total time: 0 seconds
My problem is similar to Android ant build project failure which didn't seem to have an answer (or at least one that I could descern from the responses.
I can't post an image (not enough mojo yet) but my test project is set up as:
AllAppsTest
src
com.uia.example.my
LaunchSettings.java
JRE System Library[JavaSE-1.6] (there are number of jar files here but I am not
listing them here)
Referenced Libraries
android.jar
uiautomator.jar
JUnit 4
I executed the following:
c:\Eclipse\workspace\Android>android create uitest-project -n AllAppsTest -t 7 -
p C:\Eclipse\workspace\Android\
Updated file C:\Eclipse\workspace\Android\build.xml
c:\Eclipse\workspace\Android>ant build
Buildfile: c:\Eclipse\workspace\Android\build.xml
Which resulted in the 'ant build' error output at the top of this post.
Any ideas?
Thanks
Eric
Not sure this is kosher answering my own question but...
I believe there is an error in the documentation (or the create step) for executing the build.xml file. The build.xml must be copied to the project directory, in my case AllAppsTest, and the 'ant build' command executed from there.
So the sequence of events to get this to work (in Windows command window):
Run the 'android create' command
c:\Eclipse\workspace\Android>android create uitest-project -n AllAppsTest -t 7 -
p C:\Eclipse\workspace\Android\
Switch to the AllAppsTest directory
cd AllAppsTest
Copy the build.xml file from the parent directory
copy ../build.xml
(which for some reason copies local.properties and project.properties also)
Run the 'ant build' command
When I first tried this the build failed as it didn't like the single and double quotes I had that were on comment lines. Not sure why that was but I removed them and the ant build worked OK.
I downloaded the ActionBarSherlock ViewPagerTutorial from here:
http://www.androidbegin.com/tutorial/android-actionbarsherlock-viewpager-tabs-tutorial/
But when I try to build the package it errors out saying:
$ ant debug
Buildfile: build.xml does not exist!
Build failed
Where can I find the build.xml file for this package?
Where can I find the build.xml file for this package?
You create it, by running the android update project command.
i want to know how can we generate apk file using ant script. i came to know that we can use "ant debug" command to do that.but when i am running this command it is returning error that " Target "debug" does not exist in the project". i am using ant1.7.0.is it the issue?i have tried given below code to generate apk.
<target depends="build-subprojects,build-project" name="build">
<jar destfile="bin/test.apk" basedir="bin/classes" >
<manifest>
<attribute name="Main-Class" value="test.Main" />
</manifest>
</jar>
</target>
but the generated apk is different from auto generated apk while build the app using eclipse.Please guide me.
but when i am running this command it is returning error that " Target "debug" does not exist in the project"
Then you did not create your Android project properly, or you modified your build.xml file, or something else is broken.
As a test, I just ran the following command from my /tmp directory on Linux:
android create project --target android-17 --path Foo --package com.foo --activity Foo
I then changed into the Foo directory and ran ant debug. The app compiled, and in my bin/ directory is Foo-debug.apk.
If you are not getting this sort of result, delete your build.xml file and run android update project --path ..., where ... is the path to your project, to create a fresh build.xml file.