How to convert apk to jar

HDBarodi

Member
Licensed User
Longtime User
Dear All,

I have just finished my first application and try it on Android phone and it works perfectly. Then I want to convert that application to Java (jar file) to be able to use it on phones which support Java.
So, could you please help me in that?
Note: the application has some external files in DirAssets.

Best Regards,
H D Barodi
 

HDBarodi

Member
Licensed User
Longtime User
Thank you all for your responding.

Which phones do u want to run it on?
Any phone which support Java, like Nokia E5 and Samsung Chat.

Sure you can, google Dex2Jar.
I try it already, but the converted file is not working.

But this will never run on a phone that just supports Java.
I don't understand this point well. If I will not be able to use it on phone, so why I will convert it then?

So, is there any tool which can convert B4A code to Java? Actually, my application code is so simple, and I am sure that any person who knows Java will help me in converting it, but I need to have something for the future applications.
 
Upvote 0

HDBarodi

Member
Licensed User
Longtime User
By the way, the code that I want to change it currently is not with me right now, but it will be included in the following code:
B4X:
Sub Globals
      Dim myPanel As Panel
      Dim myWebView As WebView
End Sub


Sub Activity_Create(FirstTime As Boolean)
      Activity.LoadLayout("Layout1")
      myPanel.SetLayout(0dip, 0dip, 100%x, 100%y)
      myWebView.RemoveView
      myPanel.AddView(myWebView, 5dip, 5dip, 100%x - 10dip, 100%y -10dip)
      Dim myTextReader As TextReader
      myTextReader.Initialize(File.OpenInput(File.DirAssets, "1.txt"))
      myWebView.JavaScriptEnabled = True
      myWebView.LoadHtml(myTextReader.ReadAll)
      myTextReader.Close
End Sub
 
Upvote 0

corwin42

Expert
Licensed User
Longtime User

You will have to tell us why you want to convert it .

B4A itself converts you B4A code to Java. Just look into the Objects\src tree in your project folder.

But the code uses the Android framework, so if there is no Android framework on your Java phone it will not work.


sent from my Galaxy Nexus
 
Upvote 0

HDBarodi

Member
Licensed User
Longtime User
You will have to tell us why you want to convert it.
Just to make my application covering more mobile phone.

B4A itself converts you B4A code to Java. Just look into the Objects\src tree in your project folder.
And that is why I thought that I can convert it.

it will not work. apk uses android libraries like the webview. it wont work on java phones for this and other reasons.
But the code uses the Android framework, so if there is no Android framework on your Java phone it will not work.
I become sad now.
I hope if I can do something for that, and I will be appreciate if you can help me to do so.
 
Upvote 0

susu

Well-Known Member
Licensed User
Longtime User
Maybe you confused between Java and J2ME?
 
Upvote 0

Theera

Expert
Licensed User
Longtime User

Hi HDBarodi,
Try use this commands on DOS,example d2j-dex2jar <targetapp.apk> and press enter key
 
Upvote 0

susu

Well-Known Member
Licensed User
Longtime User
Hi HDBarodi,
Try use this commands on DOS,example d2j-dex2jar <targetapp.apk> and press enter key

He can't do this because it only converts dex to jar (not apk file).
 
Upvote 0

Theera

Expert
Licensed User
Longtime User
He can't do this because it only converts dex to jar (not apk file).

Hi susu,
He need to covert apk to jar,doesn't he? I had ever done it.
 
Upvote 0

susu

Well-Known Member
Licensed User
Longtime User
You need to extract classes.dex from apk file (rename file.apk to file.rar or file.zip then use Winrar or Winzip to extract).
Use dex2jar to convert classes.dex -> classes.jar.
Use JD-Gui to decompile classes.jar to Java code.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…