Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release version of SettingsActivity does not work #2005

Closed
hrap1919 opened this issue Apr 14, 2021 · 14 comments · Fixed by hrap1919/termux-app#3
Closed

Release version of SettingsActivity does not work #2005

hrap1919 opened this issue Apr 14, 2021 · 14 comments · Fixed by hrap1919/termux-app#3

Comments

@hrap1919
Copy link

hrap1919 commented Apr 14, 2021

Problem description

The release build (0.109) crashes after choosing any item in settings menu (Debugging and Terminal I/O).

Steps to reproduce

Build the release apk in Android Studio, run it, go to Settings/Debugging or Terminal I/O. The debug build works fine.

Expected behavior

The behavior similar to debug build.

Additional information

  • Termux application version: 0.109
  • Android OS version: 9.0
  • Device model: Motorola g7 Power
@hrap1919
Copy link
Author

hrap1919 commented Apr 14, 2021

The release build becomes fine after removing

minifyEnabled true
shrinkResources true

from the apps gradle script

And moving these strings into debug section breaks the debug build.

@agnostic-apollo
Copy link
Member

Did you not get a crash report notification when opening termux again or a stacktrace in logcat?

@hrap1919
Copy link
Author

hrap1919 commented Apr 14, 2021

This is after clicking on Terminal I/O

androidx.fragment.app.Fragment$InstantiationException: Unable to instantiate fragment com.termux.app.fragments.settings.TerminalIOPreferencesFragment: make sure class name exists
        at androidx.fragment.app.FragmentFactory.loadFragmentClass(FragmentFactory.java:91)
        at androidx.fragment.app.Fragment.instantiate(Fragment.java:546)
        at androidx.fragment.app.FragmentContainer.instantiate(FragmentContainer.java:57)
        at androidx.fragment.app.FragmentManager$3.instantiate(FragmentManager.java:390)
        at androidx.preference.PreferenceFragmentCompat.onPreferenceTreeClick(PreferenceFragmentCompat.java:419)
        at androidx.preference.Preference.performClick(Preference.java:1192)
        at androidx.preference.Preference.performClick(Preference.java:1166)
        at androidx.preference.Preference$1.onClick(Preference.java:181)
        at android.view.View.performClick(View.java:6600)
        at android.view.View.performClickInternal(View.java:6577)
        at android.view.View.access$3100(View.java:781)
        at android.view.View$PerformClick.run(View.java:25912)
        at android.os.Handler.handleCallback(Handler.java:873)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:193)
        at android.app.ActivityThread.main(ActivityThread.java:6923)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:870)
Caused by: java.lang.ClassNotFoundException: com.termux.app.fragments.settings.TerminalIOPreferencesFragment
        at java.lang.Class.classForName(Native Method)
        at java.lang.Class.forName(Class.java:453)
        at androidx.fragment.app.FragmentFactory.loadClass(FragmentFactory.java:47)
        at androidx.fragment.app.FragmentFactory.loadFragmentClass(FragmentFactory.java:88)
        ... 18 more
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.termux.app.fragments.settings.TerminalIOPreferencesFragment" on path: DexPathList[[zip file "/data/app/com.termux-f-UbQ9FnPAl6UHG_ZSuUuw==/base.apk"],nativeLibraryDirectories=[/data/app/com.termux-f-UbQ9FnPAl6UHG_ZSuUuw==/lib/arm64, /data/app/com.termux-f-UbQ9FnPAl6UHG_ZSuUuw==/base.apk!/lib/arm64-v8a, /system/lib64]]
        at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:134)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
        ... 22 more

crashreport.txt

@agnostic-apollo
Copy link
Member

Interesting, thanks. I'll look into it.

@agnostic-apollo
Copy link
Member

agnostic-apollo commented Apr 14, 2021

The Tasker latest beta was also having problems due to proguard not working properly causing random issues, wonder if this is related. Those 2 options are like default for release APKs, I additionally disabled obfuscation in this release, which again shouldn't haven't thrown a ClassNotFound exception.

Those classes are referred in resource files in res/xml, does running shortcuts also cause the issue, it also refers to classes in shortcuts.xml?

@hrap1919
Copy link
Author

hrap1919 commented Apr 14, 2021

I am not sure that this is related to proguard. I have a broken debug apk if

debug {
            minifyEnabled true
            shrinkResources true
            signingConfig signingConfigs.debug
        }

And I have a correctly working release apk if

release {
            //minifyEnabled true
            //shrinkResources true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }

@agnostic-apollo
Copy link
Member

Proguard/R8 handles those as well.

https://developer.android.com/studio/build/shrink-code

@hrap1919
Copy link
Author

Ok, thanks for the info. BTW the issue is minifyEnabled. I tried to to remove only one line shrinkResources, with the same crash

@agnostic-apollo
Copy link
Member

The shrinkResources only takes effect if minifyEnabled is true.

@hrap1919
Copy link
Author

Yes, but I tried

release {
            minifyEnabled true
            //shrinkResources true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }

The problem still exists.

BTW I have installed the apk on Android 7 (armv7) with the same issue.

@agnostic-apollo
Copy link
Member

It would, cause minifyEnabled does the code shrinking and obfuscation, removing shrinkResources wouldn't change anything.

The TerminalIOPreferencesFragment and DebuggingPreferencesFragment classes are not being used inside java code and are getting removed, they don't exist inside the apk.

I can reproduce the issue though. proguard rules need to be added. Looking into it.

@agnostic-apollo
Copy link
Member

You can pull the latest changes from master branch and test it out for release builds. Thanks again.

@hrap1919
Copy link
Author

Thanks, it works.

@agnostic-apollo
Copy link
Member

Great, welcome.

@ghost ghost locked and limited conversation to collaborators Oct 17, 2021
AdamMickiewich pushed a commit to VolyaTeam/dzida-app that referenced this issue Aug 8, 2022
shrihankp pushed a commit to reisxd/termux-app that referenced this issue Oct 20, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants