Is there anyone who use AppCompatActivity with AApt2 and it works in android APK?

Hello,
I wrote apps whose used AppCompatActivity version 1.2.0 before aapt2.
Now I have to move to aapt2 and simple app with the same library AppCompatActivity 1.2.0 crashed after start with message from logcat

failed resolution of Landroidx/appcompat/R$drawable

I found some posts on the internet but to fix it in Android Studdo developers upgraded gradle plugins, downgraded AppCompat to older version, or upgraded to newer versions, upgraded Android Studio.
I don’t ubnderstand how it works becuse I thought that when i use library all should work the same way.
I tried with simple AppCompaActivity with version 1.2.0, 1.4.1, 1.6 etc… without success.
The application is building buit after start I got :
failed resolution of Landroidx/appcompat/R$drawable

I have to do it because as you know when you want to add new app to playstore you need format aab.
I tried my working apk compiled with aapt to decompile and create aab but when app was packed to aab some funcionality work some doesn’t. (we are talking about decompilation and creating aab - the application itself is working fine using ofcourse old version of Remobjecst where exists parameter UseAppt2.

Has anyone dealt with this and had success or only working way is Android Studio with patches in gradle plugins, newer version (one problem have many solutions as I saw in Android Studio environment) ?
Is any workaround for this process ??

Ofcourse last version Android Studio with latest gradle plugins is working fine with AppCompacActivity but as I red there are many problems where you are not up to date…

If someone can help, give some info or direction I will be grateful.
maybe @zmattr has any working solution or some direction ?
Best regards
Mateusz

Actually, with latest (and the new Gradle repository) I get these errors in AAPP2 when using just appcompat-v7. The thing kid, these errors are valid. appcompat-v7-28.0.0 pulls in support-compat-28.0.0, and both of those define these resources.

E:                   aapt2 link: resource 'color/ripple_material_light' has a conflicting value for configuration (). [/Users/mh/Library/Application Support/RemObjects Software/EBuild/Obj/org.me.androidapplication5-95718CDD32B3A7C8EC42E7AECFCBAE7BF73B7026/Debug/Cooper-Android/aar/support-compat-28.0.0/res/values/values.xml (5)]
H:                   aapt2 link: originally defined here. [/Users/mh/Library/Application Support/RemObjects Software/EBuild/Obj/org.me.androidapplication5-95718CDD32B3A7C8EC42E7AECFCBAE7BF73B7026/Debug/Cooper-Android/aar/appcompat-v7-28.0.0/res/values/values.xml (59)]
E:                   aapt2 link: resource 'color/secondary_text_default_material_light' has a conflicting value for configuration (). [/Users/mh/Library/Application Support/RemObjects Software/EBuild/Obj/org.me.androidapplication5-95718CDD32B3A7C8EC42E7AECFCBAE7BF73B7026/Debug/Cooper-Android/aar/support-compat-28.0.0/res/values/values.xml (6)]
H:                   aapt2 link: originally defined here. [/Users/mh/Library/Application Support/RemObjects Software/EBuild/Obj/org.me.androidapplication5-95718CDD32B3A7C8EC42E7AECFCBAE7BF73B7026/Debug/Cooper-Android/aar/appcompat-v7-28.0.0/res/values/values.xml (61)]

I’m running out of ideas here. the Android tool chain and support libraries are just an inconsistent mess on every level… :(.

I believe I have a fix for the missing R classes from .aars, can you try build 20230302-161209-elements-develop [water] when its readyt in ~30-45?

I will tryn of course… Working for appcompat? Now im using androidx.appcompat suggested by google.
I will back home in 2 hours…

Did you test it on Mac or windows?
You did steps in mac fine for me and readable, can you finally di the same on windows usikg ebuild?

I have different issue now with appcompat (which I hacked around locally to test this), which is the duplicate resources (which seems a “valid” error from aapt as far as I can tell, as the two resources it complains about ARE duplicated.

The fix I did should solve the issue of com.android.*.R classes being missing at runtime, causing a crash on launch.

I only tested on Mac. As far as I am concerned, aapt2 is broken on Windows and I don’t know what do do about that (refer to the “device not responding” error from the other thread).

I think on windows aapt2 link must be run as in mac - not with a text file, but with a list of files

Won’t work. Windows doesn’t allow more than like 1024 characters on the command line, and we have way too many files to pass to with within that.

So the only way working on windows is to zip those files to link and add this zip as a parameter - not this text file as now it’s linking

Curious, I didn’t see this option. can you give me more details, and I’ll hook that up. How do you pass the zip file?

My working path on windows was :

aapt2 compile --dir res -o compiled_res/resources.zip
aapt2 link compiled_res/resources.zip -I android_sdk.jar --auto-add-overlay --manifest AndroidManifest.xml --java gen -o out\res.apk

here should process of compilation source code and dexing

zipalign.exe -v -p 4 c:\temp\apk3\out\res.apk c:\temp\apk3\out\res_aligned.apk
apksigner sign --ks CertyfikatCS.jks --min-sdk-version 26 --out c:\temp\apk3\out\res_signed.apk c:\temp\apk3\out\res_aligned.apk

Ok, cool. I’ll add that now.

it is no sure efficicnt way but you can zip dir from one aar to one.zip another to second.zip and all linkt together later but as saw in windows you copied all resources to one folder during intermeddiate process… Best approach I saw in Mac in different way but esiaer to read step by step and checking what was going on and what was genereated.

What folder structure do you use in the zip? does it matter? I cant add all files flat, as there are duplicate names…

Using this, I get

E:                   aapt2 link: resource drawable/icon (aka org.me.androidapplication5:drawable/icon) not found. [/Users/mh/Library/Application Support/RemObjects Software/EBuild/Obj/org.me.androidapplication5-95718CDD32B3A7C8EC42E7AECFCBAE7BF73B7026/Debug/Cooper-Android/AndroidManifest.xml (7)]
E:                   aapt2 link: resource string/app_name (aka org.me.androidapplication5:string/app_name) not found. [/Users/mh/Library/Application Support/RemObjects Software/EBuild/Obj/org.me.androidapplication5-95718CDD32B3A7C8EC42E7AECFCBAE7BF73B7026/Debug/Cooper-Android/AndroidManifest.xml (7)]
E:                   aapt2 link: resource string/app_name (aka org.me.androidapplication5:string/app_name) not found. [/Users/mh/Library/Application Support/RemObjects Software/EBuild/Obj/org.me.androidapplication5-95718CDD32B3A7C8EC42E7AECFCBAE7BF73B7026/Debug/Cooper-Android/AndroidManifest.xml (11)]
E:                   aapt2 link: failed processing manifest.

if I use unique folders for the files. If I don’t, it fails because I cant add dupe files to the zip.

aapt2 compile --dir res -o resources.zip

this process takes res folder (all resources compiled .flat) and zip it to resources.zip

I’m confused. this is the link thats causing problems, not the compile.

On computers running Microsoft Windows XP or later, the maximum length of the string that you can use at the command prompt is 8191 characters.

Still wont be enough.