Proguard - Keep line numbers for J2ME/BlackBerry applications - eclipse

I've search all over the web and this problem is driving me crazy.
I'm building a mobile application (J2ME, BB) using ANT and Proguard.
In my javac task, I've added the debuglevel paramater, like so:
<javac srcdir="${src.dir}" destdir="${tmp.dir}${application.name}" failonerror="true" source="1.4" target="1.4" debug="true" debuglevel="lines,vars,source">
In my proguard task, I have:
<proguard defaultpackage="" usemixedcaseclassnames="false" note="false" microedition="true" verbose="true" printmapping="true" optimizationpasses="10" renamesourcefileattribute="SourceFile">
...
...
<keepattribute name="LineNumberTable" />
<keepattribute name="SourceFile" />
</proguard>
However, when I look at the output console in Eclipse (after building my application and launching it on an emulator), I don't see lines number, just stuff like that:
at com.mycomp.myapp.Main.a(+47)
at gd.a(+24)
at fq.a(+368)
at fq.b(+188)
at com.mycomp.myapp.Main.run(+29)
I'm using Proguard 4.8.
Thanks a lot for your help,

You are using the correct setting in Proguard:
<keepattribute name="LineNumberTable" />
Do you see the line numbers on the console?, that worked for me.

Related

Continously run testng in eclipse

I've inherited a java testing application written in java/eclipse/testng, I'm a .net developer. I can run the test suite just fine, but I'm having difficulty in figuring out how to rerun the tests immediately after the suite has run. Does anyone have anything to point me in the right direction?
Thanks!
rerun the tests? what do you mean by here?
Do you want to run the multiple suites one after the other?
if so
<suite name="automated suites">
<suite-files>
<suite-file path="suitea.xml" />
<suite-file path="suiteb.xml" />
...
</suite-files>
</suite>
or the same suite?
<suite name="automated suites">
<suite-files>
<suite-file path="suitea.xml" />
<suite-file path="suitea.xml" />
...
</suite-files>
</suite>

Building Windows 8 Phone App on Command Line

I'm currently porting an existing cross platform framework to Windows Phone 8.
The build process is fully automated and we are using a rock solid CI system.
I can build and deploy Windows Phone 8 samples from Visual Studio (Express 2012),
but now I need to integrate that into our build scripts.
Did anybody ever successfully build (and deploy) a Win Phone 8 app via the commandline?
(Or ant, make, scons, whatever...)
If yes, how?
Any hints are welcome.
I used the following bat file to build WP7 code (+ant automation on top of it). It may be helpful for you.
build.bat
C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe build.xml /t:BuildAndCopy /p:Revision=123
where build.xml is something like (build itself goes under BuildAll target)
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="C:\Program Files (x86)\MSBuild\MSBuildCommunityTasks\MSBuild.Community.Tasks.Targets"/>
<PropertyGroup>
<Major>1</Major>
<Minor>0</Minor>
<Build>0</Build>
<Revision>x</Revision>
<OutputPath>Build\</OutputPath>
<OutputPathDebug>..\Build\Debug\</OutputPathDebug>
<OutputPathRelease>..\Build\</OutputPathRelease>
</PropertyGroup>
<Target Name="BuildAll" DependsOnTargets="Clean; Version">
<msbuild Projects="SomeApp.sln" Properties="Configuration=Release;OutputPath=$(OutputPathRelease)"/>
<msbuild Projects="SomeApp.sln" Properties="Configuration=Debug;OutputPath=$(OutputPathDebug)"/>
</Target>
<Target Name="Clean">
<RemoveDir Directories="$(OutputPath)" Condition="Exists('$(OutputPath)')"/>
<MakeDir Directories="$(OutputPath)" Condition="!Exists('$(OutputPath)')"/>
</Target>
<Target Name="Version">
<Message Text="Version: $(Major).$(Minor).$(Build).$(Revision)"/>
<XmlUpdate
Namespace=""
XmlFileName="WindowsPhone\Properties\WMAppManifest.xml"
XPath="//App[#Version]//#Version"
Value="$(Major).$(Minor).$(Build).$(Revision)"/>
</Target>
<ItemGroup>
<AppFiles Include="$(OutputPath)\**\*.xap"/>
</ItemGroup>
<Target Name="BuildAndCopy" DependsOnTargets="BuildAll">
<Copy
SourceFiles="#(AppFiles)"
DestinationFiles="#(AppFiles->'\\fs\Public\projects\mobile\SomeAppWP\$(Major).$(Minor).$(Build).$(Revision)\%(RecursiveDir)%(Filename)%(Extension)')"
/>
<Copy
SourceFiles="#(AppFiles)"
DestinationFiles="#(AppFiles->'\\fs\Public\projects\mobile\SomeAppWP\latest\%(RecursiveDir)%(Filename)%(Extension)')"
/>
</Target>
</Project>
It should be easy. I'll assume you have the following file structure
$/WP8App/SampleApp.sln
You will have to use the paths and solution file in your project. Execute the following instructions, and make sure to update solution file and path:
Open a command prompt
Execute: %VS110COMNTOOLS%vsvars32.bat
Execute: %VS110COMNTOOLS%..\..\VC\WPSDK\WP80\vcvarsphoneall.bat
Execute: MSBuild "WP8App/SampleApp.sln" /t:rebuild
/p:Configuration=Release /p:Platform="Any CPU" /v:d
Please notice:
The computer where you're going to run these commands should have the development environment for WP8 already set up.
If your application uses native libraries (such as PlayerFramework http://playerframework.codeplex.com/ which are installed into VS, these libraries should also be installed before running the commands)
I have used this process on VS2012 Pro and VS2012 Premium and Jenkins as Build Server.
Good luck,
Herb
Thanks to Sergei's MSBuild.exe hint I was able to build a simple sample via the command line.
https://github.com/AndreasOM/wp8-directx-commandline
There is a build.bat included, which should be enough to get you started to build for "windows phone 8" with the build system of your choice.
It's fairly hacky at the moment,
but once I get the current project done
I will clean it up.
Hint:
Never define a "CL" environment variable when working with "CL.exe" ;)

TestNG test cases are not compiling when i do project -> clean

I am using Spring, TestNG, Eclipse, Maven, Mac OS
Scenario is
I am doing some changes in my test cases ( TestNG test cases ),
Then i do Project -> Clean in eclipse
Now i am running the test file, but the changes not updated.
I suspects that the test files are not compiled.
I can run the server and i can run my webservices
But if i run maven test ( mvn test ), the entire code is compiling including test cases.
So to run the test cases i am running mvn test command only.
Not able to run through eclipse.
Eclipse config:
Auto build on
In Java build path the test package is included
If you need any more info i'll provide.
org.testng.TestNGException:
Cannot find class in classpath: com.***.***.model.***.case.CaseModelImplTest
at org.testng.xml.XmlClass.loadClass(XmlClass.java:76)
at org.testng.xml.XmlClass.init(XmlClass.java:68)
at org.testng.xml.XmlClass.<init>(XmlClass.java:54)
at org.testng.xml.TestNGContentHandler.startElement(TestNGContentHandler.java:512)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(AbstractSAXParser.java:501)
at com.sun.org.apache.xerces.internal.parsers.AbstractXMLDocumentParser.emptyElement(AbstractXMLDocumentParser.java:179)
at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.emptyElement(XMLDTDValidator.java:788)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanStartElement(XMLDocumentFragmentScannerImpl.java:1343)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2755)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:648)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:511)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:808)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:737)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:119)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1205)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:522)
at javax.xml.parsers.SAXParser.parse(SAXParser.java:395)
at javax.xml.parsers.SAXParser.parse(SAXParser.java:198)
at org.testng.xml.SuiteXmlParser.parse(SuiteXmlParser.java:17)
at org.testng.xml.SuiteXmlParser.parse(SuiteXmlParser.java:10)
at org.testng.xml.Parser.parse(Parser.java:170)
at org.testng.TestNG.initializeSuitesAndJarFile(TestNG.java:304)
at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:86)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:199)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:170)
It seems , you are not included your Test case class into the build path. Right click on your Project folder, go to the project properties->src
include your Testcase src folder by checking it.
Now it should run.
Open the Problems view. In Eclipse go to Window->Show View->Problems. It will list out all the failures while compiling the code.
Are the test cases being compiled, but to the wrong directory? They need to be compiled to test-classes not classes. In your build path, you need to set your Output folder to be
PROJECT/target/test-classes
This is true for all test resources (including src/test/java & src/test/resources).
Edit your project properties in Eclipse, select Java Build Path, and then in the Source tab, you'll see all of your source directories. Each one has an output folder. This output folder needs to be as above.
Go to Project --> Clean
That worked for me with similar problem.
Please check your testNG.xml file for correct test because I got the same error and it was because the wrong test name was entered.
is your test folder added as a source folder in Eclipse? If it isn't it won't be included in the build.
I solved this by:
Changing the build path / deleting some of the wrong ones
Cleaning the project
I think some time we get this error if your test class is in default package and in Testng.xml, you specify as below -
<suite name="Suite" parallel="none">
<listeners>
<listener class-name="org.uncommons.reportng.HTMLReporter" />
<listener class-name="org.uncommons.reportng.JUnitXMLReporter" />
</listeners>
<test name="Test">
<classes>
<class name=".Test1" />
</classes>
</test> <!-- Test -->
Here in above, I moved my testclass from default package to some package and also updated testng.xml as below - and everything started working.
<suite name="Suite" parallel="none">
<listeners>
<listener class-name="org.uncommons.reportng.HTMLReporter" />
<listener class-name="org.uncommons.reportng.JUnitXMLReporter" />
</listeners>
<test name="Test">
<classes>
<class name="com.sigma.rest.api.Test1" />
</classes>
</test> <!-- Test -->
I hope this helps you... if issue still exists, try above options.
thanks!
Check if your project artifacts like excel, property files, xml files etc are open in text editors etc. ( if yes please close them and do rebuild )
When you clean and rebuild make sure all project dependent files are closed and you do build.

Why is this simple ant file being marked as an error in Eclipse?

I have a very, very simple any build script:
<project name="quiz_jar" default="all">
<target name="all">
<jar destfile="/home/mike/export/quiz_all.jar" duplicate="preserve">
<archives>
<zips>
<files includes="/home/mike/export/quiz.jar" />
<files includes="/home/mike/download/jeuclid-3.1.9/repo/*.jar" />
</zips>
</archives>
<manifest>
<attribute name="Main-Class" value="com.antlersoft.quiz.ui.QuizFrame"/>
</manifest>
</jar>
</target>
</project>
It works fine when I run it as an Ant task in Eclipse (or from the command line)
However, in the Problems tab, it is marked with the following error:
Default target all does not exist in this
project
I found that if I change any character in the file (like in a path), the error flag goes away. I added a comment to make the error go away. Would still like to know what the problem was.
The closing tag </project> is missing. After adding it I get no errors or warnings in eclipse.
One problem is that you are not closing with a </project> tag, so Eclipse might not be seeing the <target>.
When I ran this from the command line I got a more informative message:
XML document structures must start and end within the same entity.
I was able to resolve this issue for myself by updating Maven. Right click on the project->Maven->Update Project.

Java Webstart with Tibco Native Libs

I am trying to deploy an application that uses the native implementation of Tibrv through the TibrvJ library using Java Webstart.
I have packaged up all of the Windows dlls from inside c:\tibco\tibrv\bin into a Jar file and have added these to the nativelib element in the JNLP file.
I was hoping that webstart would take the dll files from thetibco-7.5.1-nativelibs.jar file and allow them to be loaded via System.loadLibrary which is called from Tibrv.open(). However it doesn't seem to want to work properly.
My JNLP file looks like this:
<?xml version="1.0" encoding="utf-8"?><!DOCTYPE jnlp PUBLIC "-//Sun Microsystems, Inc//DTD JNLP Descriptor 6.0//EN" "http://java.sun.com/dtd/JNLP-6.0.dtd">
<jnlp spec="6.0+"
codebase="http://somewhere:8080/my-gui/application"
href="launch.jnlp">
<information>
<title>My GUI</title>
<vendor>Technology</vendor>
<description>Dashboard</description>
<description kind="short">Dashboard</description>
<icon href="icon/Stocks-128x128.png" />
<offline-allowed />
<shortcut online="true">
<desktop />
<menu submenu="Dashboard" />
</shortcut>
</information>
<security>
<all-permissions />
</security>
<update check="always" policy="prompt-update" />
<resources>
<j2se version="1.6+" href="http://java.sun.com/products/autodl/j2se"
java-vm-args="-Xmx120M -ea />
<property name="log4j.configuration" value="live/log4j.xml" />
<property name="swing.aatext" value="true" />
<jar href="tibrvj-7.5.1.jar" />
<jar href="dashboard-gui.jar" main="true" />
</resources>
<resources>
<nativelib href="nativelib/tibco-7.5.1-nativelibs.jar" />
</resources>
<application-desc main-class="com.somewhere.Main">
<argument>classpath:/live/client.xml</argument>
<argument>/live/live.properties</argument>
</application-desc>
</jnlp>
The application launches but as soon as a call is made to open tib then it falls apart with an error along the lines of:
[Root exception is TibrvException[error=22,message=Version mismatch: libtibrv version 7.4 does not match version of tibrvj shared library 7.5]]
TibrvException[error=901,message=Library not found: tibrvj]]
The users have a variety of Tib installations already on their PCs from Tib 7.2 through to 7.5. The Webstart Application only works correctly on a machine with 7.5 installed which matches the Jar file inside the package. So it doesn't appear to do anything with the nativelib jar.
I would like to avoid having to deploy 3 versions of the web start application for the different versions of Tib that the users have installed.
Has anyone else managed to get this combination of TibrvJ and Webstart working?
I've managed to get it working. The trouble is that the call to System.loadLibrary when using Webstart doesn't load in the dependencies of the specified library even if they have been packaged up into a nativelib jar.
See http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6191612 for more info.
To get around this problem it is necessary to explicity load all of the dependencies in the correct order. It is also necessary to put each dll library into its own jar file.
So to use native TibrvJ you need to make the following calls before any calls to Tibrv.Open.
System.loadLibrary("msvcr71");
System.loadLibrary("tibrv");
System.loadLibrary("tibrvcm");
System.loadLibrary("tibrvft");
System.loadLibrary("tibrvcmq");
System.loadLibrary("tibrvj");
Happy Days!
I think you have encountered a problem with Webstart.
Some years ago, I had a Webstart application using Java 3D that didn't work on Macs. Eventually I found that all Macs some with an old version of Java 3D installed, and that already installed version was used over the newer version that I had included in the in my JNLP file. Your problem sounds almost exactly like this, so it could very well be the same problem.