Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Aapt add library resources

Tags:

android

aapt

I'm trying to build apk manually (without gradle) according to this manual, but I don't understand how to use libraries with resources. I've downloaded Android Support Library, unzipped appcopmpat directory and specified -classpath in javac. I'm trying also to specify path to resources in aapt, but it reports name conflict. Should I just rename my app's resources, or is there a better solution?

Here's the command ($MANIFEST and $ANDROID are just paths):

aapt package -f -m -J app/src -M ${MANIFEST} -I ${ANDROID} -S appcompat/res app/res

And the error message:

app/res/values/strings.xml: error: Duplicate file.
appcompat/res/values/strings.xml: Original is here.
like image 979
hant0508 Avatar asked Jul 18 '26 02:07

hant0508


1 Answers

You can use --auto-add-overlay for duplicate resources but the problem is that, it is very difficult to figure out the proper resources commands and use. You also need to specify multiple -S res path for external Support Library, which are included in res inside .aar zip file.

Also, you can use --extra-packages <package_name> where you replace <package_name> with any package name, e.g. com.foo.bla. This will create an additional R.java file of the package. Instead of using a support library (e.g. AppCompatv7), you can use a theme available in android.jar which you would be using in main Manifest.xml, pointing a theme to Styles.xml in values folder. In this case, you would be able to use 'AAPT' tool without any support library.

Here is an article to create APK in a best way: https://geosoft.no/development/android.html.

See my answer on a similar question to use android's general theme (not available in a support library), so that you wouldn't have to integrate other libraries: How to compile an Android app with aapt2 without using any build tools?

like image 167
Rupesh Kumar Avatar answered Jul 24 '26 23:07

Rupesh Kumar



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!