codehasan / dex2c

🎇 AOT compiler to translate dalvikvm code into cpp code
Apache License 2.0
172 stars 40 forks source link

After turning on the default R8 obfuscation, the wrong effect is produced #33

Open crowforkotlin opened 2 weeks ago

crowforkotlin commented 2 weeks ago

image

// dcc.py config
current_dir = os.path.dirname(os.path.abspath(__file__))
APKTOOL = os.path.join(current_dir, 'tools', 'apktool.jar')
APKTOOL2 = os.path.join(current_dir, 'tools', 'apktool.bat')
APKTOOL3 = os.path.join(current_dir, 'tools', 'apktool')
SIGNJAR = os.path.join(current_dir, 'tools', 'apksigner.jar')
MANIFEST_EDITOR = os.path.join(current_dir, 'tools', 'manifest-editor.jar')
NDKBUILD = "ndk-build"

// MainActivity Source Code
package com.example.testproject

class MainActivity : AppCompatActivity() {

    val binding by lazy { ActivityMainBinding.inflate(layoutInflater) }
    override fun getResources(): Resources {
           val resources = super.getResources()
           val widthPixels = resources.displayMetrics.widthPixels.toFloat()
           val heightPixels = resources.displayMetrics.heightPixels.toFloat()
           if (widthPixels > heightPixels) {
               if (widthPixels / 1024 * 600 > heightPixels) {
                   resources.displayMetrics.density = heightPixels / 600
               } else {
                   resources.displayMetrics.density = widthPixels / 1024
               }
           } else {
               resources.displayMetrics.density = widthPixels / 1024
           }
           return resources
       }
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(binding.root)
        enableEdgeToEdge()
        ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main)) { v, insets ->
            val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
            binding.root.updateLayoutParams<FrameLayout.LayoutParams> {
                topMargin = systemBars.top
            }
            binding.root.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom)
            insets
        }
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
            window.isNavigationBarContrastEnforced = false
        }
        lifecycleScope.launch {  }
        initView()
        printHelloWorld()
    }
    private fun printHelloWorld() {
        "Hello World".log()
    }
    private fun initView() {
        // TODO....
    }
}

image image

Modify the filtering rule to: h1/AbstractC0290a;a\(.*

When I run the dex2c command again, I still get the following message: “Check your filter file.”

AbhiTheModder commented 2 weeks ago

Hello @crowforkotlin, thank you for providing detailed information.

However, I am unable to reproduce the issue following the information provided.

The recommended NDK version should be between r25b and r27b, with r26b being the most preferred.

Your provided code:

package com.example.testproject

import android.content.res.Resources
import android.os.Build
import android.os.Bundle
import android.util.Log
import android.widget.FrameLayout
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import androidx.core.view.updateLayoutParams
import androidx.lifecycle.lifecycleScope
import kotlinx.coroutines.launch
import com.example.testproject.databinding.ActivityMainBinding

class MainActivity : AppCompatActivity() {
    val binding by lazy { ActivityMainBinding.inflate(layoutInflater) }
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(binding.root)
        enableEdgeToEdge()
        ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main)) { v, insets ->
            val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
            binding.root.updateLayoutParams<FrameLayout.LayoutParams> {
                topMargin = systemBars.top
            }
            binding.root.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom)
            insets
        }
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
            window.isNavigationBarContrastEnforced = false
        }
        lifecycleScope.launch {  }
        initView()
        printHelloWorld()
    }
    override fun getResources(): Resources {
        val resources = super.getResources()
        val widthPixels = resources.displayMetrics.widthPixels.toFloat()
        val heightPixels = resources.displayMetrics.heightPixels.toFloat()
        if (widthPixels > heightPixels) {
            if (widthPixels / 1024 * 600 > heightPixels) {
                resources.displayMetrics.density = heightPixels / 600
            } else {
                resources.displayMetrics.density = widthPixels / 1024
            }
        } else {
            resources.displayMetrics.density = widthPixels / 1024
        }
        return resources
    }
    private fun printHelloWorld() {
        Log.d("TAG", "Hello World")
    }
    private fun initView() {
        // TODO....
    }
}

NDK Version & config details (in dcc.cfg):

{
    "apktool": "tools/apktool.jar",
    "ndk_dir": "/home/android-sdk/ndk/26.1.10909125",
    "signature": {
        "keystore_path": "keystore/debug.keystore",
        "alias": "androiddebugkey",
        "keystore_pass": "android",
        "store_pass": "android",
        "v1_enabled": true,
        "v2_enabled": true,
        "v3_enabled": true
    }
}

running dex2c:

╰─> python dcc.py -a input.apk -o out.apk
[INFO    ] dcc: Creating .tmp folder
[INFO    ] dcc: Backing up jni folder
[INFO    ] dcc: Adjusting Application.mk file using available abis from apk
[INFO    ] dcc: No lib abis found in apk, using the ones defined in Application.mk file
[WARNING ] androguard.core.api_specific_resources: Requested API level 35 is larger than maximum we have, returning API level 28 instead.
make: Entering directory '/home/dex2c/.tmp/dcc-project-mlRtn5su'
Android NDK: android-19 is unsupported. Using minimum supported version android-21.
.................
I: Using Apktool 2.10.0 on input.apk with 8 thread(s).
I: Baksmaling classes.dex...
I: Baksmaling classes6.dex...
I: Baksmaling classes2.dex...
I: Baksmaling classes4.dex...
I: Baksmaling classes5.dex...
I: Baksmaling classes3.dex...
I: Copying raw resources...
I: Copying raw manifest...
I: Copying assets and libs...
I: Copying unknown files...
I: Copying original files...
I: Copying META-INF/services directory
[WARNING ] androguard.core.api_specific_resources: Requested API level 35 is larger than maximum we have, returning API level 28 instead.
[INFO    ] dcc:
Application class not found in the AndroidManifest.xml or doesn't exist in dex, adding amimo.dcc.DccApplication

I: Using Apktool 2.10.0 with 8 thread(s).
I: Checking whether sources has changed...
I: Smaling smali folder into classes.dex...
I: Checking whether sources has changed...
I: Smaling smali_classes2 folder into classes2.dex...
I: Checking whether sources has changed...
I: Smaling smali_classes3 folder into classes3.dex...
I: Checking whether sources has changed...
I: Smaling smali_classes4 folder into classes4.dex...
I: Checking whether sources has changed...
I: Checking whether resources has changed...
I: Copying raw resources...
I: Smaling smali_classes5 folder into classes5.dex...
I: Checking whether sources has changed...
I: Smaling smali_classes6 folder into classes6.dex...
I: Copying libs... (/lib)
I: Copying libs... (/kotlin)
I: Copying libs... (/META-INF/services)
I: Building apk file...
I: Copying unknown files/dir...
I: Built apk into: .tmp/x5Lh96KR-unsigned.apk
[INFO    ] dcc: Zipaligning .tmp/x5Lh96KR-unsigned.apk -> out.apk
[INFO    ] dcc: Signing out.apk -> out.apk
[INFO    ] dcc: Restoring jni folder
[INFO    ] dcc: Removing .tmp folder

output apk you can review: out.zip

Is it impossible to confuse resources after using dex2c?

No, you can confuse resources even after applying dex2c, see out_obf_res.zip

crowforkotlin commented 2 weeks ago

Hello @crowforkotlin, thank you for providing detailed information.您好 @crowforkotlin ,感谢您提供详细信息。

However, I am unable to reproduce the issue following the information provided.但是,我无法根据提供的信息重现该问题。

The recommended NDK version should be between r25b and r27b, with r26b being the most preferred.建议的 NDK 版本应介于 r25b 和 r27b 之间,其中 r26b 是首选版本。

Your provided code: 您提供的代码:

package com.example.testproject

import android.content.res.Resources
import android.os.Build
import android.os.Bundle
import android.util.Log
import android.widget.FrameLayout
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import androidx.core.view.updateLayoutParams
import androidx.lifecycle.lifecycleScope
import kotlinx.coroutines.launch
import com.example.testproject.databinding.ActivityMainBinding

class MainActivity : AppCompatActivity() {
    val binding by lazy { ActivityMainBinding.inflate(layoutInflater) }
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(binding.root)
        enableEdgeToEdge()
        ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main)) { v, insets ->
            val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
            binding.root.updateLayoutParams<FrameLayout.LayoutParams> {
                topMargin = systemBars.top
            }
            binding.root.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom)
            insets
        }
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
            window.isNavigationBarContrastEnforced = false
        }
        lifecycleScope.launch {  }
        initView()
        printHelloWorld()
    }
    override fun getResources(): Resources {
        val resources = super.getResources()
        val widthPixels = resources.displayMetrics.widthPixels.toFloat()
        val heightPixels = resources.displayMetrics.heightPixels.toFloat()
        if (widthPixels > heightPixels) {
            if (widthPixels / 1024 * 600 > heightPixels) {
                resources.displayMetrics.density = heightPixels / 600
            } else {
                resources.displayMetrics.density = widthPixels / 1024
            }
        } else {
            resources.displayMetrics.density = widthPixels / 1024
        }
        return resources
    }
    private fun printHelloWorld() {
        Log.d("TAG", "Hello World")
    }
    private fun initView() {
        // TODO....
    }
}
  • filters.txt:
com/example/testproject/MainActivity;getResources\(.*

NDK Version & config details (in dcc.cfg):NDK版本和配置详情(在 dcc.cfg 中):

{
    "apktool": "tools/apktool.jar",
    "ndk_dir": "/home/android-sdk/ndk/26.1.10909125",
    "signature": {
        "keystore_path": "keystore/debug.keystore",
        "alias": "androiddebugkey",
        "keystore_pass": "android",
        "store_pass": "android",
        "v1_enabled": true,
        "v2_enabled": true,
        "v3_enabled": true
    }
}

running dex2c:

╰─> python dcc.py -a input.apk -o out.apk
[INFO    ] dcc: Creating .tmp folder
[INFO    ] dcc: Backing up jni folder
[INFO    ] dcc: Adjusting Application.mk file using available abis from apk
[INFO    ] dcc: No lib abis found in apk, using the ones defined in Application.mk file
[WARNING ] androguard.core.api_specific_resources: Requested API level 35 is larger than maximum we have, returning API level 28 instead.
make: Entering directory '/home/dex2c/.tmp/dcc-project-mlRtn5su'
Android NDK: android-19 is unsupported. Using minimum supported version android-21.
.................
I: Using Apktool 2.10.0 on input.apk with 8 thread(s).
I: Baksmaling classes.dex...
I: Baksmaling classes6.dex...
I: Baksmaling classes2.dex...
I: Baksmaling classes4.dex...
I: Baksmaling classes5.dex...
I: Baksmaling classes3.dex...
I: Copying raw resources...
I: Copying raw manifest...
I: Copying assets and libs...
I: Copying unknown files...
I: Copying original files...
I: Copying META-INF/services directory
[WARNING ] androguard.core.api_specific_resources: Requested API level 35 is larger than maximum we have, returning API level 28 instead.
[INFO    ] dcc:
Application class not found in the AndroidManifest.xml or doesn't exist in dex, adding amimo.dcc.DccApplication

I: Using Apktool 2.10.0 with 8 thread(s).
I: Checking whether sources has changed...
I: Smaling smali folder into classes.dex...
I: Checking whether sources has changed...
I: Smaling smali_classes2 folder into classes2.dex...
I: Checking whether sources has changed...
I: Smaling smali_classes3 folder into classes3.dex...
I: Checking whether sources has changed...
I: Smaling smali_classes4 folder into classes4.dex...
I: Checking whether sources has changed...
I: Checking whether resources has changed...
I: Copying raw resources...
I: Smaling smali_classes5 folder into classes5.dex...
I: Checking whether sources has changed...
I: Smaling smali_classes6 folder into classes6.dex...
I: Copying libs... (/lib)
I: Copying libs... (/kotlin)
I: Copying libs... (/META-INF/services)
I: Building apk file...
I: Copying unknown files/dir...
I: Built apk into: .tmp/x5Lh96KR-unsigned.apk
[INFO    ] dcc: Zipaligning .tmp/x5Lh96KR-unsigned.apk -> out.apk
[INFO    ] dcc: Signing out.apk -> out.apk
[INFO    ] dcc: Restoring jni folder
[INFO    ] dcc: Removing .tmp folder

output apk you can review: 输出 APK,您可以查看: out.zip

Is it impossible to confuse resources after using dex2c?使用 dex2c 后不可能混淆资源吗?

No, you can confuse resources even after applying dex2c, see不可以,即使在应用 dex2c 后,您也可能混淆资源,请参阅 out_obf_res.zip

PS C:\Users\CrowF\Desktop\dex2c-master> python .\dcc.py -a .\app-release.apk -o output.apk
[INFO    ] dcc: Creating .tmp folder
[INFO    ] dcc: Backing up jni folder
[INFO    ] dcc: Adjusting Application.mk file using available abis from apk
[INFO    ] dcc: No lib abis found in apk, using the ones defined in Application.mk file
[WARNING ] androguard.core.api_specific_resources: Requested API level 34 is larger than maximum we have, returning API level 28 instead.
make: Entering directory 'C:/Users/CrowF/Desktop/dex2c-master/.tmp/dcc-project-ip9EQGtV'
Android NDK: android-19 is unsupported. Using minimum supported version android-21.
make: Leaving directory 'C:/Users/CrowF/Desktop/dex2c-master/.tmp/dcc-project-ip9EQGtV'
make: Entering directory 'C:/Users/CrowF/Desktop/dex2c-master/.tmp/dcc-project-ip9EQGtV'
[armeabi-v7a] Compile++ thumb: stub <= Java_com_example_testproject_MainActivity_getResources__.cpp
make: Leaving directory 'C:/Users/CrowF/Desktop/dex2c-master/.tmp/dcc-project-ip9EQGtV'
make: Entering directory 'C:/Users/CrowF/Desktop/dex2c-master/.tmp/dcc-project-ip9EQGtV'
[armeabi-v7a] Compile++ thumb: stub <= Dex2C.cpp
make: Leaving directory 'C:/Users/CrowF/Desktop/dex2c-master/.tmp/dcc-project-ip9EQGtV'
make: Entering directory 'C:/Users/CrowF/Desktop/dex2c-master/.tmp/dcc-project-ip9EQGtV'
[armeabi-v7a] Compile++ thumb: stub <= well_known_classes.cpp
make: Leaving directory 'C:/Users/CrowF/Desktop/dex2c-master/.tmp/dcc-project-ip9EQGtV'
make: Entering directory 'C:/Users/CrowF/Desktop/dex2c-master/.tmp/dcc-project-ip9EQGtV'
[arm64-v8a] Compile++      : stub <= Java_com_example_testproject_MainActivity_getResources__.cpp
make: Leaving directory 'C:/Users/CrowF/Desktop/dex2c-master/.tmp/dcc-project-ip9EQGtV'
make: Entering directory 'C:/Users/CrowF/Desktop/dex2c-master/.tmp/dcc-project-ip9EQGtV'
[arm64-v8a] Compile++      : stub <= well_known_classes.cpp
make: Leaving directory 'C:/Users/CrowF/Desktop/dex2c-master/.tmp/dcc-project-ip9EQGtV'
make: Entering directory 'C:/Users/CrowF/Desktop/dex2c-master/.tmp/dcc-project-ip9EQGtV'
[arm64-v8a] Compile++      : stub <= Dex2C.cpp
make: Leaving directory 'C:/Users/CrowF/Desktop/dex2c-master/.tmp/dcc-project-ip9EQGtV'
make: Entering directory 'C:/Users/CrowF/Desktop/dex2c-master/.tmp/dcc-project-ip9EQGtV'
[armeabi-v7a] SharedLibrary  : libstub.so
make: Leaving directory 'C:/Users/CrowF/Desktop/dex2c-master/.tmp/dcc-project-ip9EQGtV'
make: Entering directory 'C:/Users/CrowF/Desktop/dex2c-master/.tmp/dcc-project-ip9EQGtV'
[armeabi-v7a] Install        : libstub.so => libs/armeabi-v7a/libstub.so
make: Leaving directory 'C:/Users/CrowF/Desktop/dex2c-master/.tmp/dcc-project-ip9EQGtV'
make: Entering directory 'C:/Users/CrowF/Desktop/dex2c-master/.tmp/dcc-project-ip9EQGtV'
[arm64-v8a] SharedLibrary  : libstub.so
make: Leaving directory 'C:/Users/CrowF/Desktop/dex2c-master/.tmp/dcc-project-ip9EQGtV'
make: Entering directory 'C:/Users/CrowF/Desktop/dex2c-master/.tmp/dcc-project-ip9EQGtV'
[arm64-v8a] Install        : libstub.so => libs/arm64-v8a/libstub.so
make: Leaving directory 'C:/Users/CrowF/Desktop/dex2c-master/.tmp/dcc-project-ip9EQGtV'
I: Using Apktool 2.10.0 on app-release.apk with 28 thread(s).
I: Baksmaling classes.dex...
I: Copying raw resources...
I: Copying raw manifest...
I: Copying assets and libs...
I: Copying unknown files...
I: Copying original files...
I: Copying META-INF/services directory
Press any key to continue . . .
[WARNING ] androguard.core.api_specific_resources: Requested API level 34 is larger than maximum we have, returning API level 28 instead.
[INFO    ] dcc:
Application class not found in the AndroidManifest.xml or doesn't exist in dex, adding amimo.dcc.DccApplication

I: Using Apktool 2.10.0 with 28 thread(s).
I: Checking whether sources has changed...
I: Smaling smali folder into classes.dex...
I: Checking whether resources has changed...
I: Copying raw resources...
I: Copying libs... (/lib)
I: Copying libs... (/kotlin)
I: Copying libs... (/META-INF/services)
I: Building apk file...
I: Copying unknown files/dir...
I: Built apk into: .tmp\cjwzyAgd-unsigned.apk
[INFO    ] dcc: Zipaligning .tmp\cjwzyAgd-unsigned.apk -> output.apk
[INFO    ] dcc: Signing output.apk -> output.apk
[INFO    ] dcc: Restoring jni folder
[INFO    ] dcc: Removing .tmp folder
PS C:\Users\CrowF\Desktop\dex2c-master> adb install .\output.apk
Performing Streamed Install
Success

Caused by: android.content.res.Resources$NotFoundException: Drawable com.example.testprojeect:drawable/abc_vector_test with resource ID #0x7f070077 Caused by: android.content.res.Resources$NotFoundException: File res/hq.xml from drawable resource ID #0x7f070077

AbhiTheModder commented 2 weeks ago

I followed your steps step by step and finally generated the product. In addition, I tried to replace android.debug.keystore with jks of my own project. After modifying the signature file twice, the product apk installation failed and crashed directly. The error message was still the same as above, that is, the resource could not be found. iii. In addition, I also encountered an error when running dex2c after replacing keystore with jks, prompting Algorithm HmacPBESHA256 not available. The solution is to set jdk17 as the preferred environment variable.

For now, you can sign the output APK (which will initially be signed with debug keystores) using your custom keystore after you've completed the dex2c processing on the APK.

iv. This is the problematic warehouse. The apk is in app/release and has been packaged. I just don't know why this problem occurs. If you have time, please take a look. Thank you!

I've tried checking it and it's fine at my side yet again, maybe it's an issue with windows side (?) I'll try checking on windows in a while to confirm things.

Edit: can't repro

Kirlif commented 1 week ago

Built from https://github.com/crowforkotlin/Dex2c-TestProject then performed dcc on getResources. Tested working fine on A14. I guess the issue has nothing to do with r8 minification.

crowforkotlin commented 3 days ago

Built from https://github.com/crowforkotlin/Dex2c-TestProject then performed dcc on getResources.从 https://github.com/crowforkotlin/Dex2c-TestProject 构建,然后在 getResources 上执行 dcc。 Tested working fine on A14. 在 A14 上测试工作正常。 I guess the issue has nothing to do with r8 minification.我想这个问题与 r8 缩小无关。

Built from https://github.com/crowforkotlin/Dex2c-TestProject then performed dcc on getResources.从 https://github.com/crowforkotlin/Dex2c-TestProject 构建,然后在 getResources 上执行 dcc。 Tested working fine on A14. 在 A14 上测试工作正常。 I guess the issue has nothing to do with r8 minification.我想这个问题与 r8 缩小无关。

Is this problem unrelated to r8? If I turn off obfuscation, everything will return to normal, but when obfuscation is turned on, the above problem will occur

AbhiTheModder commented 3 days ago

@crowforkotlin Neither @Kirlif nor I have been able to reproduce the issue with the APK you provided, or by building from source ourselves. Therefore, I've closed the issue for now. If you're able to identify the cause or provide clear, reproducible steps, or if someone else encounters the same issue, we'll revisit it.

Kirlif commented 2 days ago

Is this problem unrelated to r8? If I turn off obfuscation, everything will return to normal, but when obfuscation is turned on, the above problem will occur

This does not imply that the problem is with r8. Please, test this: Test.zip

crowforkotlin commented 2 days ago

Is this problem unrelated to r8? If I turn off obfuscation, everything will return to normal, but when obfuscation is turned on, the above problem will occur这个问题与 r8 无关吗?如果我关闭混淆,一切都会恢复正常,但是当打开混淆时,会出现上述问题

This does not imply that the problem is with r8.这并不意味着问题出在 r8 上。 Please, test this: 请测试一下: Test.zip

I installed it and it's normal! Could you please send me the system environment, SDK NDK, APKTOOL and other configurations for running dcc? I'll try it tomorrow

crowforkotlin commented 1 day ago

Is this problem unrelated to r8? If I turn off obfuscation, everything will return to normal, but when obfuscation is turned on, the above problem will occur

This does not imply that the problem is with r8. Please, test this: Test.zip

https://github.com/user-attachments/assets/daef5566-1018-4ab4-8cf0-a44499a7ed0d

  1. I used the original signature test.jks of this project to package, and directly used the generated apk in app/release/app-release.apk https://github.com/crowforkotlin/Dex2c-TestProject/blob/main/app/release/app-release.apk

  2. Here, the original signature test.jks is also configured for dex2c

  3. The next steps are the same as in the video. First, I installed app-release.apk normally, but when I entered the next step dcc and continued to install output.apk, it crashed.

  4. All the configuration and modification codes are below

// dcc.cfg
{
    "apktool": "tools/apktool.jar",
    "ndk_dir": "C:/Users/CrowF/AppData/Local/Android/Sdk/ndk/26.1.10909125",
    "signature": {
        "keystore_path": "keystore/test.jks",
        "alias": "test",
        "keystore_pass": "123456",
        "store_pass": "123456",
        "v1_enabled": true,
        "v2_enabled": true,
        "v3_enabled": true
    }
}

// edit dcc.py
current_dir = os.path.dirname(os.path.abspath(__file__))
APKTOOL = os.path.join(current_dir, 'tools', 'apktool.jar')
APKTOOL2 = os.path.join(current_dir, 'tools', 'apktool.bat')
APKTOOL3 = os.path.join(current_dir, 'tools', 'apktool')
SIGNJAR = os.path.join(current_dir, 'tools', 'apksigner.jar')
MANIFEST_EDITOR = os.path.join(current_dir, 'tools', 'manifest-editor.jar')
NDKBUILD = "ndk-build"

// filter.txt 
com/example/testproject/MainActivity;getResources\(.*

// set original signature test.jks in dex2c/keystore
// Env
// openjdk version "17.0.1" 2021-10-19
// OpenJDK Runtime Environment (build 17.0.1+12-39)
// OpenJDK 64-Bit Server VM (build 17.0.1+12-39, mixed mode, sharing)
// Windows11 x64
// Android Version 14
// ApkTools Version : apktool_2.10.0.jar
// Ndk Version : 26.1.10909125
// Apk isMinifyEnabled = true
Caused by: android.content.res.Resources$NotFoundException: Drawable com.example.testprojeect:drawable/abc_vector_test with resource ID #0x7f070077
Caused by: android.content.res.Resources$NotFoundException: File res/hq.xml from drawable resource ID #0x7f070077

you can download apk check it apk.zip

The decompiled code of output.apk looks fine, but when I launch the app it crashes. image image

AbhiTheModder commented 1 day ago

Hi @crowforkotlin,

I noticed in your video that you're using outdated code, as the API level being returned is still 28. With the recent updates, it should be returning 34. I recommend doing a git pull to fetch the latest changes and update your project accordingly.

Also, please refrain from editing dcc.py as no modifications are necessary for that file.

crowforkotlin commented 1 day ago

Hi @crowforkotlin,

I noticed in your video that you're using outdated code, as the API level being returned is still 28. With the recent updates, it should be returning 34. I recommend doing a git pull to fetch the latest changes and update your project accordingly.

Also, please refrain from editing dcc.py as no modifications are necessary for that file.

OK, I'll try again. Actually, I don't want to modify dcc.py, but if I don't modify it, I will be prompted with this long list of commands when using dcc on Windows, so I refer to #13

PS C:\Users\CrowF\Desktop\dex2c-master> python .\dcc.py -a .\app-release.apk -o output.apk
[INFO    ] dcc: Creating .tmp folder
[INFO    ] dcc: Backing up jni folder
[INFO    ] dcc: Adjusting Application.mk file using available abis from apk
[INFO    ] dcc: No lib abis found in apk, using the ones defined in Application.mk file
make: Entering directory 'C:/Users/CrowF/Desktop/dex2c-master/.tmp/dcc-project-pNvy8gwf'
Android NDK: android-19 is unsupported. Using minimum supported version android-21.
make: Leaving directory 'C:/Users/CrowF/Desktop/dex2c-master/.tmp/dcc-project-pNvy8gwf'
make: Entering directory 'C:/Users/CrowF/Desktop/dex2c-master/.tmp/dcc-project-pNvy8gwf'
[armeabi-v7a] Compile++ thumb: stub <= DynamicRegister.cpp
make: Leaving directory 'C:/Users/CrowF/Desktop/dex2c-master/.tmp/dcc-project-pNvy8gwf'
make: Entering directory 'C:/Users/CrowF/Desktop/dex2c-master/.tmp/dcc-project-pNvy8gwf'
[armeabi-v7a] Compile++ thumb: stub <= Java_com_example_testproject_MainActivity_getResources__.cpp
make: Leaving directory 'C:/Users/CrowF/Desktop/dex2c-master/.tmp/dcc-project-pNvy8gwf'
make: Entering directory 'C:/Users/CrowF/Desktop/dex2c-master/.tmp/dcc-project-pNvy8gwf'
[armeabi-v7a] Compile++ thumb: stub <= well_known_classes.cpp
make: Leaving directory 'C:/Users/CrowF/Desktop/dex2c-master/.tmp/dcc-project-pNvy8gwf'
make: Entering directory 'C:/Users/CrowF/Desktop/dex2c-master/.tmp/dcc-project-pNvy8gwf'
[armeabi-v7a] Compile++ thumb: stub <= Dex2C.cpp
make: Leaving directory 'C:/Users/CrowF/Desktop/dex2c-master/.tmp/dcc-project-pNvy8gwf'
make: Entering directory 'C:/Users/CrowF/Desktop/dex2c-master/.tmp/dcc-project-pNvy8gwf'
[arm64-v8a] Compile++      : stub <= DynamicRegister.cpp
make: Leaving directory 'C:/Users/CrowF/Desktop/dex2c-master/.tmp/dcc-project-pNvy8gwf'
make: Entering directory 'C:/Users/CrowF/Desktop/dex2c-master/.tmp/dcc-project-pNvy8gwf'
[arm64-v8a] Compile++      : stub <= Java_com_example_testproject_MainActivity_getResources__.cpp
make: Leaving directory 'C:/Users/CrowF/Desktop/dex2c-master/.tmp/dcc-project-pNvy8gwf'
make: Entering directory 'C:/Users/CrowF/Desktop/dex2c-master/.tmp/dcc-project-pNvy8gwf'
[arm64-v8a] Compile++      : stub <= Dex2C.cpp
make: Leaving directory 'C:/Users/CrowF/Desktop/dex2c-master/.tmp/dcc-project-pNvy8gwf'
make: Entering directory 'C:/Users/CrowF/Desktop/dex2c-master/.tmp/dcc-project-pNvy8gwf'
[arm64-v8a] Compile++      : stub <= well_known_classes.cpp
make: Leaving directory 'C:/Users/CrowF/Desktop/dex2c-master/.tmp/dcc-project-pNvy8gwf'
make: Entering directory 'C:/Users/CrowF/Desktop/dex2c-master/.tmp/dcc-project-pNvy8gwf'
[armeabi-v7a] SharedLibrary  : libstub.so
make: Leaving directory 'C:/Users/CrowF/Desktop/dex2c-master/.tmp/dcc-project-pNvy8gwf'
make: Entering directory 'C:/Users/CrowF/Desktop/dex2c-master/.tmp/dcc-project-pNvy8gwf'
[armeabi-v7a] Install        : libstub.so => libs/armeabi-v7a/libstub.so
make: Leaving directory 'C:/Users/CrowF/Desktop/dex2c-master/.tmp/dcc-project-pNvy8gwf'
make: Entering directory 'C:/Users/CrowF/Desktop/dex2c-master/.tmp/dcc-project-pNvy8gwf'
[arm64-v8a] SharedLibrary  : libstub.so
make: Leaving directory 'C:/Users/CrowF/Desktop/dex2c-master/.tmp/dcc-project-pNvy8gwf'
make: Entering directory 'C:/Users/CrowF/Desktop/dex2c-master/.tmp/dcc-project-pNvy8gwf'
[arm64-v8a] Install        : libstub.so => libs/arm64-v8a/libstub.so
make: Leaving directory 'C:/Users/CrowF/Desktop/dex2c-master/.tmp/dcc-project-pNvy8gwf'
'tools' is not recognized as an internal or external command,
operable program or batch file.
[ERROR   ] dcc: Compile .\app-release.apk failed!
Traceback (most recent call last):
  File "C:\Users\CrowF\Desktop\dex2c-master\dcc.py", line 1123, in <module>
    dcc_main(
  File "C:\Users\CrowF\Desktop\dex2c-master\dcc.py", line 879, in dcc_main
    decompiled_dir = ApkTool.decompile(apkfile)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\CrowF\Desktop\dex2c-master\dcc.py", line 116, in decompile
    check_call([APKTOOL2, "d", "-r", "-f", "-o", outdir, apk])
  File "D:\program\python\Lib\subprocess.py", line 413, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['tools/apktool.bat', 'd', '-r', '-f', '-o', '.tmp\\dcc-apktool-r319F7hy', '.\\app-release.apk']' returned non-zero exit status 1.
Command '['tools/apktool.bat', 'd', '-r', '-f', '-o', '.tmp\\dcc-apktool-r319F7hy', '.\\app-release.apk']' returned non-zero exit status 1.
AbhiTheModder commented 1 day ago

Okay, it makes sense now. The issue was closed, which is why it slipped our attention. It appears to be a Windows-related problem that needs resolution. Thank you for bringing it to our attention.

crowforkotlin commented 1 day ago

I use the latest master branch code, and the configuration is exactly the same as above, and now DCC fails

https://github.com/user-attachments/assets/4b095969-1bb5-498b-9a13-eca90502511f

AbhiTheModder commented 1 day ago

I use the latest master branch code, and the configuration is exactly the same as above, and now DCC fails

Yes, I've started up my Windows and can now replicate the issue, which is why I've reopened it. This appears to be an issue on the Windows side; for now, you can use WSL on Windows until it is resolved. Thank you.

AbhiTheModder commented 1 day ago

@crowforkotlin, implemented a fix on the fix/windows branch. To clone it, use git clone https://github.com/codehasan/dex2c.git -b fix/windows. Everything is working perfectly on my end now; please try it and let me know.

crowforkotlin commented 15 hours ago

image still not working

@crowforkotlin, implemented a fix on the fix/windows branch. To clone it, use git clone https://github.com/codehasan/dex2c.git -b fix/windows. Everything is working perfectly on my end now; please try it and let me know.

AbhiTheModder commented 6 hours ago

still not working

This time, the issue seems to be on your end. Please ensure that all dependencies are correctly configured and set up: IMG_20241129_154245_035

crowforkotlin commented 6 hours ago

still not working

This time, the issue seems to be on your end. Please ensure that all dependencies are correctly configured and set up: IMG_20241129_154245_035

image

AbhiTheModder commented 5 hours ago

@crowforkotlin

https://github.com/user-attachments/assets/9ae49176-0182-4571-96eb-baa74ad599cc

crowforkotlin commented 4 hours ago

@crowforkotlin

Dex2c.mp4

Ok thank you very much for the detailed steps, I will try it on windows tomorrow!