satishkale123 / de-tiny-sip

Automatically exported from code.google.com/p/de-tiny-sip
0 stars 0 forks source link

Conversion to Dalvik format failed with error 1 #2

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Checkout the source via SVN
2. Import the project in Eclipse
3. Try to launch TinySipDemoActivity

What is the expected output? What do you see instead?
Following the description, the TinySipDemo should run without further 
modification. In my case I receive a Conversion to Dalvik format failed with 
error 1. 

What version of the product are you using? On what operating system?

I am using Eclipse 3.7.2 on Windows 7 64 bit.

Please provide any additional information below.

Full console output:

[2012-03-30 10:33:47 - TinySip] Dx 
trouble processing "javax/sip/address/Address.class":

Ill-advised or mistaken usage of a core class (java.* or javax.*)
when not building a core library.

This is often due to inadvertently including a core library file
in your application's project, when using an IDE (such as
Eclipse). If you are sure you're not intentionally defining a
core class, then this is the most likely explanation of what's
going on.

However, you might actually be trying to define a class in a core
namespace, the source of which you may have taken, for example,
from a non-Android virtual machine project. This will most
assuredly not work. At a minimum, it jeopardizes the
compatibility of your app with future versions of the platform.
It is also often of questionable legality.

If you really intend to build a core library -- which is only
appropriate as part of creating a full virtual machine
distribution, as opposed to compiling an application -- then use
the "--core-library" option to suppress this error message.

If you go ahead and use "--core-library" but are in fact
building an application, then be forewarned that your application
will still fail to build or run, at some point. Please be
prepared for angry customers who find, for example, that your
application ceases to function once they upgrade their operating
system. You will be to blame for this problem.

If you are legitimately using some code that happens to be in a
core package, then the easiest safe alternative you have is to
repackage that code. That is, move the classes in question into
your own package namespace. This means that they will never be in
conflict with core system classes. JarJar is a tool that may help
you in this endeavor. If you find that you cannot do this, then
that is an indication that the path you are on will ultimately
lead to pain, suffering, grief, and lamentation.

Original issue reported on code.google.com by armincom...@gmail.com on 30 Mar 2012 at 9:17

GoogleCodeExporter commented 8 years ago
Did anyone find a solution to this

Original comment by jkard...@gmail.com on 16 May 2012 at 4:45

GoogleCodeExporter commented 8 years ago
same for me =(

Original comment by nonameden on 17 May 2012 at 9:12

GoogleCodeExporter commented 8 years ago
No one solve this problem?

Original comment by xmarc...@gmail.com on 21 Jun 2012 at 4:59

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
There are packages starting with "javax" in the source code. Renaming them may 
allow to compile. But it seems to be quite a tedious task.

Original comment by theedge...@gmail.com on 14 Oct 2012 at 8:48

GoogleCodeExporter commented 8 years ago
1. clean project
2. delete folder "bin/classes" from explorer (if using windows)

Original comment by semirxar...@gmail.com on 5 Nov 2012 at 7:46

GoogleCodeExporter commented 8 years ago
Hm, tried to clean and remove bin/classes, now I can compile, but I immediately 
get a RuntimeException:

01-06 16:48:22.015: E/AndroidRuntime(3469): FATAL EXCEPTION: main
01-06 16:48:22.015: E/AndroidRuntime(3469): java.lang.RuntimeException: Unable 
to instantiate activity 
ComponentInfo{de.tinysip.sipdemo/de.tinysip.sipdemo.TinySipDemoActivity}: 
java.lang.ClassNotFoundException: de.tinysip.sipdemo.TinySipDemoActivity in 
loader dalvik.system.PathClassLoader[/data/app/de.tinysip.sipdemo-2.apk]
01-06 16:48:22.015: E/AndroidRuntime(3469):     at 
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1569)
01-06 16:48:22.015: E/AndroidRuntime(3469):     at 
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
01-06 16:48:22.015: E/AndroidRuntime(3469):     at 
android.app.ActivityThread.access$1500(ActivityThread.java:117)
01-06 16:48:22.015: E/AndroidRuntime(3469):     at 
android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
01-06 16:48:22.015: E/AndroidRuntime(3469):     at 
android.os.Handler.dispatchMessage(Handler.java:99)
01-06 16:48:22.015: E/AndroidRuntime(3469):     at 
android.os.Looper.loop(Looper.java:130)
01-06 16:48:22.015: E/AndroidRuntime(3469):     at 
android.app.ActivityThread.main(ActivityThread.java:3683)
01-06 16:48:22.015: E/AndroidRuntime(3469):     at 
java.lang.reflect.Method.invokeNative(Native Method)
01-06 16:48:22.015: E/AndroidRuntime(3469):     at 
java.lang.reflect.Method.invoke(Method.java:507)
01-06 16:48:22.015: E/AndroidRuntime(3469):     at 
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
01-06 16:48:22.015: E/AndroidRuntime(3469):     at 
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
01-06 16:48:22.015: E/AndroidRuntime(3469):     at 
dalvik.system.NativeStart.main(Native Method)
01-06 16:48:22.015: E/AndroidRuntime(3469): Caused by: 
java.lang.ClassNotFoundException: de.tinysip.sipdemo.TinySipDemoActivity in 
loader dalvik.system.PathClassLoader[/data/app/de.tinysip.sipdemo-2.apk]
01-06 16:48:22.015: E/AndroidRuntime(3469):     at 
dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
01-06 16:48:22.015: E/AndroidRuntime(3469):     at 
java.lang.ClassLoader.loadClass(ClassLoader.java:551)
01-06 16:48:22.015: E/AndroidRuntime(3469):     at 
java.lang.ClassLoader.loadClass(ClassLoader.java:511)
01-06 16:48:22.015: E/AndroidRuntime(3469):     at 
android.app.Instrumentation.newActivity(Instrumentation.java:1021)
01-06 16:48:22.015: E/AndroidRuntime(3469):     at 
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1561)
01-06 16:48:22.015: E/AndroidRuntime(3469):     ... 11 more

Original comment by armincom...@gmail.com on 5 Nov 2012 at 8:20

GoogleCodeExporter commented 8 years ago
The class not found error is due to all the classes not being included when 
building the .apk, its due to the classes folder being deleted and not being 
remade correctly.  cleaning the project and deleting the classes folded is not 
a workable solution unfortunately.  The only way to get this project to work is 
to repackage the JAIN library.  I am trying to do that right now, but running 
into problems, see issue 7

Original comment by crysi...@googlemail.com on 12 Nov 2012 at 10:12

GoogleCodeExporter commented 8 years ago
It is late but, I think I've managed to refactor JAIN libraries. You may want 
to check this out.

Original comment by alim.gok...@gmail.com on 27 May 2013 at 8:37

Attachments:

GoogleCodeExporter commented 8 years ago
Hi, thank you for the modified Version, this one finally compiles and starts 
correctly. As soon as I find some time, I will test it for good! Thanks again!

Original comment by armincom...@gmail.com on 27 May 2013 at 11:31

GoogleCodeExporter commented 8 years ago
I didn't test it with making calls, because I've given up after I find out that 
it is not a tiny task to add RTP support. I am looking for other libraries 
right now.
I hope my version is useful for anyone

Original comment by alim.gok...@gmail.com on 27 May 2013 at 1:40

GoogleCodeExporter commented 8 years ago
Did anyone find a solution to this

Original comment by shak...@adodis.com on 13 Mar 2014 at 5:24

GoogleCodeExporter commented 8 years ago
I finally managed to make this project run. As someone said here, the 
"Conversion to Dalvik format failed with error 1" issue is caused because the 
built-in android sip stack (which is not reliable) was built using JAIN-SIP so 
classnames collide. To solve this problem we need to rename the packages. I did 
the following steps:

1) Using eclipse's refactor -> rename feature, I renamed all javax.* packages 
to android.javax.* and gov.nist.* to android.gov.nist.*. To do this check the 
first two options ("Update references" and "Rename subpackages") but don't 
check the third option ("Update textual occurrences in comments and strings 
(forces preview)") because this can introduce more problems.

After this you will be able to run the project but you will get a 
NullPointerException, the problem stated in issue #7. This happens because we 
still need some renaming (so the reflection in JAIN-SIP works) and the 
SipManager's constructor has a try/catch block that hides the problem and does 
not initialize its class members correctly due to the exception (which I think 
was a bad desing). To debug the problem I printed the stack trace inside the 
catch block . The other steps are:

2) Inside SipMessageHandler's constructor you need to call setPathName in the 
SipFactory instance:
    // Create SipFactory
    SipFactory sipFactory = SipFactory.getInstance();
    sipFactory.setPathName("android.gov.nist");

3) After this you will have another exception complaining that 
org.apache.log4j.Logger was not found. This happens because this project is old 
and still uses a folder called assets to store the libraries. Rename the folder 
assets to libs (I suggest removing all libraries from the build path before 
doing this to avoid problems).

4) Inside SipStackImpl's constructor rename the default path for the router:
    /** Retrieve the router path */
    String routerPath = configurationProperties.getProperty("javax.sip.ROUTER_PATH");
    if (routerPath == null)
        routerPath = "android.gov.nist.javax.sip.stack.DefaultRouter";

A better way to do this and not change the JAIN-SIP is to set the property 
inside SipMessageHandler's constructor:
    // Create unique name properties for SipStack
    Properties properties = new Properties();
    properties.setProperty("javax.sip.STACK_NAME", "tinysip");
    properties.setProperty("javax.sip.ROUTER_PATH", "android.gov.nist.javax.sip.stack.DefaultRouter");

These are all the necessary steps.

Another option is to use JAIN-SIP as a 3rd party library
https://jsip.java.net/
The renaming for Android is already available in the section "Android builds". 
I don't know why de-tiny-sip included JAIN-SIP as its source instead of using 
it as a jar. For this option (which is quicker) do the following steps:

1) Remove the folders gov and javax from src and add "android-sip-stack.jar" to 
the libs folder (Do step 3 of the other solution, that is, rename assets to 
libs)

2) Update the imports to android.* (Just check the errors eclipse will point 
out)

3) Update the STACK_NAME property inside SipMessageHandler's constructor to use 
the android prefix:
    // Create unique name properties for SipStack
    Properties properties = new Properties();
    properties.setProperty("android.javax.sip.STACK_NAME", "tinysip");

4) Do step 2 of the other solution (setPathName)

That's it. The advantage of this approach is that we use the newest JAIN-SIP 
implementation.

Unfortunately, either way the final result is not so good. First, in fact issue 
#1 happens. And second, I was able to make calls only to locally registered 
accounts (e.g. something@192.168.14.1). If I try an account with a domain name 
(e.g. something@ekiga.net) the application gets stuck. So far I could conclude 
that the STUN discovery works but the app gets stuck when trying to create a 
SipManager instance. Console keeps showing messages like this:

11-14 12:08:46.709: D/dalvikvm(2357): GC_FOR_ALLOC freed 510K, 18% free 
3032K/3656K, paused 17ms, total 17ms

If somebody is able to solve this problem, please share. I hope this helps. 
Regards.

Original comment by diego.cd...@gmail.com on 14 Nov 2014 at 6:41