Open connglli opened 4 years ago
Hello, i try using
./android-sdk-linux/build-tools/30.0.3/d8 --output amogus.dex helloworld.jar
but an error occured, any idea? :(
Error: Invalid output: amogus.dex Output must be a .zip or .jar archive or an existing directory Compilation failed
Java information
openjdk 11.0.22 2024-01-16 OpenJDK Runtime Environment (build 11.0.22+7-post-Ubuntu-0ubuntu222.04.1) OpenJDK 64-Bit Server VM (build 11.0.22+7-post-Ubuntu-0ubuntu222.04.1, mixed mode, sharing)
Nevermind :D, i solved the issue change amogus.dex to name of the folder and the classes.dex will appear inside the folder
Introduction
app_process
ordalvikvm
directly instead of by Android framework itselfframework.jar
for compiling (implementation offramework.jar
can be empty or throwingRuntimeException
, doesn’t matter); theframework.jar
can be obtained from Android SDK directory (theandroid.jar
), or compiling AOSP directly, or pulled from emulators or devices (located at/system/framework/framework.jar
), or using a gradle/maven dependency built by robolectric team; but remember to usecompileOnly
keyword instead ofimplementation
if you'd like to package then into a uber jar (see here on the differences of these keywords)dx
ord8
app_process
ordalvikvm
Example
src/com/example
src
:$ javac –cp /path/to/framework.jar com/example/HelloWorld.java
$ jar cvfe HelloWorld-jar.jar com.example.HelloWorld com/example/HelloWorld.class
$ d8 --output HelloWorld.dex HelloWorld-jar.jar
$ adb push HelloWorld.dex /data/local/tmp
Run it in devices shell by either
app_process
ordalvikvm
The Simplest Way
As long as a system-level app has no differences from a common app (except running in command line). The simplest way is no more easier than reusing the Android Studio tool chain.
HelloWorld
Debugging A System-Level App
JDWP provides the ability of debugging to JVM, which also works in dalvik/ART. Like CDP (chrome devtools protocol), JDWP defines a debugging protocol of any debugger frontend and the backend. So any client/server that implements the protocol can connect to each other.
Step1: Start debugging server
On devices with Android 8 and/or lower, JDWP is implemented using the java agent, i.e., the
-agentlib
option. To enable JDWP:Above options "transport=dt_socket,suspend=y,server=y,address=5005" tells JVM to enable JDWP as a TCP server at port 5005, and suspend the app once start.
On devices with Android 8+, use:
Step2: Forward the debugger
Forward that port to the desktop:
Step3: Set breakpoints and connect to the debugger
Set your breakpoints in Android Studio.
Then in the menu: Run > Debug > Edit configurations.... Click on
+
> Remote, and fill the following:localhost
5005
Then click Debug.